You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Projects Gantt tab: request values written unescaped into document.write() (reflected XSS) #542
Several values go into a single-quoted JavaScript string without any escaping:
Variable
Source
$user_id
w2PgetParam($_GET, 'user_id', …) (L13)
$addPwOiD
w2PgetParam($_POST, 'add_pwoid', …) (L22)
$proFilter
raw $_POST['proFilter'], saved in session state (L37–40)
$dept_ids, $department
globals set by the including tab
w2PgetParam() only runs strip_tags(), which leaves ' and ) alone. A value such as user_id=1');alert(document.cookie);// closes the string and runs script, so a crafted link is enough for the GET case. The proFilter value is kept in the session, so it runs again on every later visit to the tab in that session.
Found by code reading on master 8727ad5; not yet reproduced in a browser.
Proposed fix
Cast the numeric values (user_id, addPwOiD, proFilter, company_id, department) with (int), and reduce dept_ids to a comma list of ints.
Check proFilter against the keys of $projFilter before saving it to state.
Build the query string with http_build_query().
Replace document.write() with a plain <img id="ganttImg"> and set its src from JS: pass the server-built URL through json_encode(..., JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) and append &width= in JS. The same helper can serve the task and project designer gantts (see the related issues).
Testing
Open the Projects Gantt tab with &user_id=1');alert(1);// before and after: no alert after the fix, and the chart still renders.
POST proFilter containing a quote; the saved state should come back as an int.
For normal values the generated image URL is unchanged.
Activity