Skip to content

Stored Cross-Site Scripting (XSS) in Teacher Management Module via username, first name and last name parameters #10

@Sjf12

Description

@Sjf12

Description

A Stored Cross-Site Scripting (XSS) vulnerability was discovered in the Teacher Management module of the School Management System PHP.
User-controlled fields (username, fname, lname) are stored in the database without sanitization and rendered without output encoding in multiple pages (including the teacher list and teacher view).
An authenticated administrator can inject malicious JavaScript that executes when other users (including other admins) view the teacher list or profile.

Vulnerable Component

File: Admin/teacher-view.php (and likely teacher.php / list view)
Affected parameters:

  • username
  • fname (First Name)
  • lname (Last Name)

Vulnerable code example:

<h5 class="card-title text-center">@<?=$teacher['username']?></h5>
<li class="list-group-item">First name: <?=$teacher['fname']?></li>
<li class="list-group-item">Last name: <?=$teacher['lname']?></li>

Proof of Concept (PoC)

  1. Log in as administrator.
  2. Go to Teachers → Edit an existing teacher (or create new).
  3. Inject the payload in the Last Name field:
    <script>alert(document.cookie)</script>
  4. Save the changes.
Image
  1. Go back to the Teachers list page (teacher.php).
Image

Result: The JavaScript executes immediately, stealing the victim's PHPSESSID (session cookie).

Impact

  • Session hijacking / Account takeover (full admin access)
  • Execution of arbitrary JavaScript in authenticated user context
  • Potential data theft and unauthorized actions

Vulnerability Type

Stored Cross-Site Scripting (CWE-79)

Suggested Fix

Use proper output escaping everywhere user data is displayed:
PHP<?= htmlspecialchars($teacher['lname'], ENT_QUOTES, 'UTF-8') ?>

Do this for all fields (username, fname, lname, etc.) in all teacher-related views.

Affected Repository

Repository: https://github.com/codingWithElias/school-management-system-php
Affected file: Admin/teacher-view.php + teacher listing pages
Affected version: Up to commit f1ac334

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions