-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Version Information
- Branch/Release: Latest commit from the repository ea19dd: https://github.com/vedees/wcms/blob/master/wcms/wex/cssjs.php.
Issue Description
Two vulnerabilities were identified in /wcms/wex/cssjs.php:
-
Improper Handling of the
pathParameter:- Sink: Line #62
- The value of
$_GET['path']is directly passed tojson_encode()and echoed without sanitization. - This allows attackers to inject malicious content via the
pathparameter.
-
Improper Handling of the
typeParameter:- Sink: Line #64
- The value of
$_GET['type']is directly echoed into the HTML output without sanitization. - This can lead to a reflected XSS attack if an attacker injects malicious JavaScript into the
typeparameter.
Steps to Reproduce
-
Reproducing the
pathVulnerability (Line #62):- Send a GET request to the vulnerable endpoint with the following payload:
path="/valid/path";}\u003cscript\u003ealert(1)\u003c/script\u003e - Example using
curl:curl "http://localhost/wcms/wex/cssjs.php?path=/valid/path;}\u003cscript\u003ealert(1)\u003c/script\u003e" - Expected Result: Malicious script will be executed in the user's browser.
- Send a GET request to the vulnerable endpoint with the following payload:
-
Reproducing the
typeVulnerability (Line #64):- Send a GET request to the vulnerable endpoint with the following payload:
type=\"\u003cscript\u003ealert(2)\u003c/script\u003e - Example using
curl:curl "http://localhost/wcms/wex/cssjs.php?type=\"\u003cscript\u003ealert(2)\u003c/script\u003e" - Expected Result: Malicious script will be executed in the user's browser.
- Send a GET request to the vulnerable endpoint with the following payload:
Expected Behavior
- The
pathparameter should be validated and sanitized before being processed or output. - The
typeparameter should be encoded before being included in the HTML response.
Actual Behavior
- Unsanitized input from the
pathandtypeparameters is processed and directly reflected in the response. - This can lead to the execution of arbitrary JavaScript in the user's browser.
Proposed Fix
-
Sanitize the
pathParameter (Line #62):- Validate and sanitize the input to ensure it contains only allowed characters:
$path = filter_var($_GET['path'], FILTER_SANITIZE_STRING); $path = htmlspecialchars($path, ENT_QUOTES, 'UTF-8');
- Validate and sanitize the input to ensure it contains only allowed characters:
-
Sanitize the
typeParameter (Line #64):- Use
htmlspecialchars()to encode the output:$type = htmlspecialchars($_GET['type'], ENT_QUOTES, 'UTF-8');
- Use
-
General Security Improvements:
- Implement a Content Security Policy (CSP) header to mitigate XSS attacks:
Content-Security-Policy: script-src 'self'; - Validate all user inputs before processing or including them in the response.
- Implement a Content Security Policy (CSP) header to mitigate XSS attacks:
Impact
- These vulnerabilities have a critical impact as they allow attackers to execute arbitrary JavaScript in the user's browser.
- This can lead to session hijacking, phishing, or theft of sensitive information.
Screenshots
Metadata
Metadata
Assignees
Labels
No labels