Skip to content

Reflected Cross-Site Scripting (XSS) in /admin/Add notice/add notice.php via $_SERVER['PHP_SELF'] #239

@duckpigdog

Description

@duckpigdog

Reflected Cross-Site Scripting (XSS) in /admin/Add notice/add notice.php via $_SERVER['PHP_SELF']

Describe the bug
Multiple reflected Cross-Site Scripting (XSS) vulnerabilities exist in /admin/Add notice/add notice.php. The script uses the unsanitized $_SERVER['PHP_SELF'] variable in the action attribute of two forms (line 122 and line 157), allowing an attacker to inject arbitrary JavaScript code through a crafted URL.

Steps to reproduce

  1. Log in to the admin panel using the preset admin account (username: admin, password: admin123).
  2. Access the following crafted URL in a browser (the vulnerable page is only accessible after login):

http://127.0.0.1:3000/admin/Add%20notice/add%20notice.php/"><script>alert('XSS')/script>

  1. The browser will execute the injected JavaScript and display an alert box with the text XSS, confirming the vulnerability.

The malicious code can be replaced with more harmful scripts (e.g., to steal cookies, perform phishing, or hijack the admin session).

Describe the solution
To fix this vulnerability, the action attribute should not directly output user-controllable input. Instead, use a hardcoded relative URL or properly sanitize the output.

Recommended fix:

  • Replace <?php echo $_SERVER['PHP_SELF']; ?> with a static value, such as "" (post to same page) or "add notice.php".
  • If dynamic values are necessary, use htmlspecialchars() to encode output:
    <?php echo htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'); ?>

Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions