/

CVE-2025-69231

Severity:

HIGH RISK

(8.7)

Stored XSS in OpenEMR GAD-7 Anxiety Assessment Form

CVE-2025-69231

Analyzed

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Session Hijacking and Privilege Escalation via Stored XSS

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

A stored cross-site scripting vulnerability in OpenEMR's GAD-7 anxiety assessment form allows authenticated clinician users to inject malicious JavaScript into assessment data.

When other users view the compromised form, the attacker-controlled script executes in their browser, enabling session hijacking, account takeover, and potential privilege escalation to administrator.

Affected context

The vulnerability occurs within OpenEMR's GAD-7 anxiety assessment workflow, where clinician-entered data is later rendered to other users in the web interface.

It is exposed when:

  • Clinician users can enter or update assessment fields that are later displayed to other users (e.g., clinicians, staff, or administrators).
  • The stored content is rendered in HTML responses without adequate output encoding or contextual escaping.
  • Browsers execute embedded scripts in the context of the OpenEMR domain, inheriting the victim user's authenticated session.

Exploit preconditions

  • Attack surface: Web-based user interface for GAD-7 anxiety assessments in OpenEMR.
  • Required access: Authenticated account with clinician-level privileges capable of creating or editing GAD-7 assessment entries.
  • Trigger point: Any user (including administrators) viewing the compromised GAD-7 assessment via the standard OpenEMR UI.
  • Why exploitation is possible: User-supplied assessment data is stored server-side and later rendered into HTML without proper context-aware output encoding, allowing attacker-injected JavaScript to execute in the victim's browser.

Why this happens

The underlying issue aligns with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).

The application stores clinician-supplied data from the GAD-7 form and later embeds this data into HTML responses without sufficient output encoding or HTML/JavaScript context escaping.

Because the data is treated as display-ready content rather than untrusted input, an attacker can inject HTML/JavaScript payloads that the browser interprets as active script.

This pattern reflects a classic stored XSS bug: persistent untrusted input is rendered as part of the page's DOM in a script-capable context.

Potential impact

  • Attacker-controlled JavaScript may run in the context of other users' authenticated sessions.
  • Session hijacking could allow takeover of clinician, staff, or administrator accounts.
  • Privilege escalation from clinician to administrator may occur if an admin views a malicious GAD-7 entry.
  • Unauthorized access to sensitive electronic health records and patient data could result from compromised accounts.
  • Modification or deletion of medical records and configuration settings is possible via impersonated high-privilege users.
  • Further client-side attacks, such as credential harvesting or CSRF abuse, can be orchestrated from the victim's browser.

General mitigation guidance

Effective mitigation centers on context-aware output encoding and strict handling of untrusted data:

  • Apply HTML, attribute, or JavaScript context-specific output encoding to all user-supplied fields rendered in the GAD-7 form views and similar templates.
  • Treat all stored form data as untrusted, regardless of the user's role, and sanitize or validate it before storage and/or before rendering.
  • Use templating engines or view helpers that automatically encode values by default and explicitly mark safe-only, vetted content.
  • Avoid directly concatenating user input into HTML, JavaScript, or inline event handlers; separate code from data.
  • Consider adopting a Content Security Policy (CSP) to reduce the impact of any remaining script injection vectors.
  • Enforce least-privilege principles for roles (e.g., clinicians should not inherently have configuration-level capabilities) to limit the damage if a session is compromised.

How teams detect issues like this

Detecting this class of vulnerability generally involves a combination of static and dynamic approaches:

  • Static analysis: Configure SAST tools to flag unencoded variables rendered into HTML templates or views, especially in form/result display logic.
  • Code review: During manual review, look for direct insertion of database fields or request parameters into HTML pages, script blocks, or event handlers without encoding helpers.
  • Dynamic testing: Use automated or manual web application scanning to submit benign script markers in GAD-7 and similar forms, then verify whether they are executed when viewed.
  • Security testing policies: Integrate XSS-focused test cases into CI/CD pipelines, and require security review for new forms or UI features that render stored user input.
  • Runtime monitoring: Employ web application firewalls or RASP-like controls configured with rules to detect and possibly block common XSS payload patterns, while being aware of false positives.

Sources

SourceLink
github.comgithub.com/openemr/openemr/commit/5f20b756441fc9868f43410a9ef97536c38b2ba6
github.comgithub.com/openemr/openemr/security/advisories/GHSA-mf62-q2xc-hxm3

Frequently asked

questions

Yes, but exploitation requires an authenticated clinician account. Once an attacker has or compromises such an account, they can inject malicious content that executes in the browsers of other remote users who access the affected GAD-7 assessments.

The attacker needs clinician-level access (or any role with equivalent abilities to create or edit GAD-7 assessments). From there, they can target higher-privileged users such as administrators who view the tampered assessments.

The safest approach is to apply context-aware output encoding everywhere user-controlled data is rendered, backed by a secure-by-default templating approach. Treat all stored data as untrusted and avoid mixing user data directly with HTML or JavaScript without appropriate encoding.

Standardize on secure view helpers or templating engines that encode by default, enforce code review checklists focusing on XSS risks, integrate SAST/DAST tools tuned for XSS detection into the development pipeline, and provide developer training on output encoding and the principle of treating all input as untrusted.

Find out what's already
exploitable in your codebase.