/

CVE-2026-42197

Severity:

HIGH RISK

(8.7)

Stored XSS in RELATE Participation Admin

CVE-2026-42197

Deferred

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Authenticated Stored XSS leading to potential admin account takeover

Severity:

HIGH RISK

(8.7)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

RELATE courseware versions prior to commit 555f0efb1c5bd7531c07cd73724d7e566a81f620 contain a stored cross-site scripting (XSS) flaw in the Django admin Participation listing.

Any enrolled student can inject arbitrary JavaScript via their profile name fields, which executes when an administrator views the Participation list, potentially leading to full admin account takeover.

Affected context

The vulnerability arises in RELATE's Django admin interface, specifically in the ParticipationAdmin list where user information is rendered for staff and administrators.

It affects deployments where:

  • The RELATE admin panel is enabled and used to manage course participation.
  • Users can edit their profile (first_name and last_name) without sanitization.
  • The ParticipationAdmin.get_user() display logic uses mark_safe and string formatting, bypassing Django's automatic HTML-escaping.

Under these conditions, malicious content stored in profile fields is rendered directly into admin pages.

Exploit preconditions

  • Attack surface: Web-based RELATE application, specifically the Django admin Participation list.
  • Required access: Authenticated user account with permission to update their own profile (first_name and last_name).
  • Trigger point: An administrator or staff member opens the Participation list page in the Django admin, causing the crafted name value to be rendered.
  • Why exploitation is possible: The get_user() method in ParticipationAdmin marks user-controlled values as safe via mark_safe and formats them into HTML using Python's % operator. This disables Django's default escaping and allows arbitrary HTML/JavaScript contained in the first_name/last_name fields to be injected and stored, which then executes in the admin's browser when the list is viewed.

Why this happens

This issue stems from improper output encoding of user-controlled data in an HTML context, a classic CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).

Instead of relying on Django's automatic escaping in templates, the code:

  • Constructs HTML fragments manually in ParticipationAdmin.get_user().
  • Uses mark_safe to assert that the constructed string is safe.
  • Interpolates values derived from the User model's first_name and last_name fields using % string formatting.

Because these fields are directly editable by users through /profile/ and are not sanitized or encoded, attacker-supplied HTML/JavaScript is treated as trusted content and sent back to the browser, where it executes in the context of the admin session.

Potential impact

  • An attacker-controlled student account may execute arbitrary JavaScript in an administrator's browser session.
  • Attackers could steal administrator session cookies or tokens, potentially leading to full admin account takeover.
  • Malicious scripts can perform privileged actions in the admin panel using the victim's credentials (e.g., modifying course settings, user roles, or content).
  • Persistent browser-side malware could be injected to log keystrokes or exfiltrate sensitive admin-only information.
  • Further compromise of application integrity, such as tampering with course materials or student records, may be possible through hijacked admin privileges.

General mitigation guidance

Mitigation focuses on enforcing proper output encoding and eliminating unsafe HTML construction patterns:

  • Avoid using mark_safe on strings that incorporate any user-controlled data; prefer letting Django templates handle escaping automatically.
  • If manual HTML generation is unavoidable, ensure that all dynamic content is passed through context-appropriate escaping helpers before concatenation.
  • Restrict or validate inputs for profile fields that are rendered in administrative or sensitive views, using server-side validation to reject obvious script content and disallow HTML markup.
  • Simplify admin display logic by using standard Django admin field display mechanisms instead of custom string formatting paths that bypass built-in protections.
  • Apply the principle of least privilege for admin accounts and ensure separate, dedicated admin accounts are used to reduce impact if a session is compromised.

How teams detect issues like this

Detection can be approached through both code-level and runtime monitoring techniques:

  • Static analysis and code review:
  • Search for usage of mark_safe, format, or % string formatting involving user model fields, especially in admin or template helpers.
  • Flag any pattern where user-controlled data is interpolated into HTML strings outside of template contexts.
  • Include secure coding guidelines in review checklists that discourage manual HTML concatenation with unescaped data.
  • Automated tooling:
  • Use static analysis tools or linters configured to detect unsafe calls to mark_safe and other constructs that bypass escaping.
  • Integrate security scanning in CI pipelines to identify XSS-prone patterns in Django views and admin classes.
  • Runtime observation:
  • Monitor logs and browser console warnings for unexpected script execution or errors originating from admin pages.
  • Capture and review content of profile fields or other user-editable text that appear in admin views for suspicious markup.

Sources

SourceLink
github.comgithub.com/inducer/relate/blob/550b8c54eb4d5f3e5f6698dcba361bf34d715599/course/admin.py#L347-L368
github.comgithub.com/inducer/relate/commit/555f0efb1c5bd7531c07cd73724d7e566a81f620
github.comgithub.com/inducer/relate/security/advisories/GHSA-37xm-vhx8-g6w3

Frequently asked

questions

The vulnerability is exploitable by any authenticated student or user who can modify their profile name fields and relies on an administrator viewing the Participation list in the Django admin for the payload to execute. It is not exploitable by completely unauthenticated users.

The attacker needs a valid RELATE account with access to the /profile/ page, allowing them to update their first_name and last_name. No elevated privileges are required beyond standard enrollment; the attack is triggered when an administrator subsequently views the affected admin list.

The safest pattern is to avoid manual HTML construction for user data and rely on Django's templating system, which HTML-escapes by default. Any time dynamic content must be inserted into HTML, apply strict context-aware escaping and remove or tightly limit mark_safe usage, especially in admin or high-privilege views.

Establish coding standards that prohibit unescaped insertion of user-controlled data into HTML, require justification and review for any use of mark_safe, and integrate automated checks for XSS-prone patterns into CI. Training developers and reviewers to recognize unsafe output encoding scenarios in Django, combined with routine security reviews of admin customizations, reduces the likelihood of reintroducing similar issues.

Find out what's already
exploitable in your codebase.