Skip to content

Project designer Gantt: build the image URL without document.write() string concatenation #543

Open

Description

@caseysoftware

Where

modules/projectdesigner/vw_gantt.php L15–16:

$src = '?m=tasks&a=gantt&suppressHeaders=1&showLabels=0&f=all&project_id=' . $project_id . '&width=\' + (...) + \'';
echo '<script>document.write(\'<img src="' . $src . '">\')</script>';

Problem

This is the same pattern as #542: a PHP value concatenated into a single-quoted JavaScript string that is passed to document.write(), with no escaping for either context.

It is not exploitable today: $project_id is a global that modules/projectdesigner/index.php casts with (int) (L48–49). But the safety depends on a cast in another file, and anyone adding a parameter here will copy the unsafe pattern.

Proposed fix

Use the same helper as the fix for #542: build the query with http_build_query(), output a plain <img>, and set its src from JS with the server part passed through json_encode() (with the JSON_HEX_* flags) and the width appended in JS. All three gantt views (projects, tasks, project designer) can share one helper.

Testing

  • Project designer → Gantt renders at about 90% of the window width, before and after.
  • The generated image URL is unchanged apart from encoding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions