CVE-2022-4766 (PHP, published 2022-12-27T13:15Z)
Description: value: A vulnerability was found in dolibarr_project_timesheet up to 4.5.5. It has been declared as problematic. This vulnerability affects unknown code of the component Form Handler. The manipulation leads to cross-site request forgery. The attack can be initiated remotely. Upgrading to version 4.5.6.a is able to address this issue. The name of the patch is 082282e9dab43963e6c8f03cfaddd7921de377f4. It is recommended to upgrade the affected component. The identifier of this vulnerability is VDB-216880.
Severity: nan (CVSS v3 base score: 6.5)
Weakness: CWE-352 \u2014 Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
Repository: https://github.com/delcroip/dolibarr_project_timesheet
Files changed:
htdocs/timesheet/AttendanceEventAdmin.php
htdocs/timesheet/ChangeLog.md
htdocs/timesheet/TimesheetProjectInvoice.php
htdocs/timesheet/TimesheetReportProject.php
htdocs/timesheet/TimesheetReportUser.php
htdocs/timesheet/TimesheetTeamApproval.php
htdocs/timesheet/TimesheetUserTasksAdmin.php
htdocs/timesheet/admin/timesheetsetup.php
htdocs/timesheet/class/AttendanceEvent.class.php
htdocs/timesheet/class/TimesheetUserTasks.class.php
htdocs/timesheet/core/modules/modtimesheet.class.php
Commit message: csrf token in all form


Vulnerable code:
    ."&hidetab=".$hidetab.'&ungroup='.$ungroup.'" >'.$langs->trans('TimesheetPDF').'</a>';
    ."&hidetab=".$hidetab.'&ungroup='.$ungroup.'" >'.$langs->trans('Export').'</a>';
    ."&hidetab=".$hidetab.'&ungroup='.$ungroup.'" >'.$langs->trans('Refresh').'</a>';
        . '" >' . $langs->trans( 'Export' ) . '</a>';
    . '" >' . $langs->trans( 'PDF' ) . '</a>';
    //$tail = '&wlm='.$this->whitelistmode;
//     $Nav .= '<a id = "navPrev" onClick = "loadXMLTimesheet(\''.getStartDate($this->date_start, -1).'\', 0);';
//  if ($ajax)
//  {
    //    $Nav .= '<form name = "goToDate" onsubmit = "return toDateHandler();" action="?action=goToDate&wlm='.$this->whitelistmode.'" method = "POST">'."\n\t\t\t";
    //} else{
        $Nav .= '<form name = "goToDate" action="?action=goToDate'.$tail.'" method = "POST" >'."\n\t\t\t";
    //}
    //if ($ajax)
//    {
    //    $Nav .= '<a id = "navNext" onClick = "loadXMLTimesheet(\''.getStartDate($this->date_start, 1).'\', 0);';
    //} else{
        $Nav .= '<a href="?dateStart='.getStartDate($this->date_start, 1).$tail;
    //}
                $this->version = '4.5.4';

Fixed code:
    print '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

4.5.6
- fix csrf issue in other pages
- fix box issue

$token = getToken();
            $Form .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

            $Form .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';
$token = getToken();
$form_output .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

    ."&hidetab=".$hidetab.'&ungroup='.$ungroup.'&token='.$token.'" >'.$langs->trans('TimesheetPDF').'</a>';
    ."&hidetab=".$hidetab.'&ungroup='.$ungroup.'&token='.$token.'" >'.$langs->trans('Export').'</a>';
    ."&hidetab=".$hidetab.'&ungroup='.$ungroup.'&token='.$token.'" >'.$langs->trans('Refresh').'</a>';
$token = getToken();
$form_output .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

        . '&token='.$token.'" >' . $langs->trans( 'Export' ) . '</a>';
    . '&token='.$token.'" >' . $langs->trans( 'PDF' ) . '</a>';
    $Nav .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

            print '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';
$token = getToken();
echo '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';
    //FIXME should take token as input
    $token = getToken();
    $HTML .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';
    $Nav .= '<form name = "goToDate" action="?action=goToDate'.$tail.'" method = "POST" >'."\n\t\t\t";
    //FIXME should take token as input
    $token = getToken();
    $Nav .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

    $Nav .= '<a href="?dateStart='.getStartDate($this->date_start, 1).$tail;
        //FIXME should take token as input
        $token = getToken();
        $HTML .= '<input type = "hidden" id="csrf-token" name = "token" value = "'.$token.'"/>';

        
                $this->version = '4.5.6';