/

CVE-2026-32121

Severity:

HIGH RISK

(7.7)

XSS in OpenEMR Patient Portal Rendering

CVE-2026-32121

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Execution of arbitrary JavaScript in users' browsers, potentially leading to credential theft, account compromise, and unauthorized actions within OpenEMR.

Severity:

HIGH RISK

(7.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

OpenEMR prior to 8.0.0.1 contains a cross-site scripting (XSS) vulnerability where unsanitized patient names are rendered into HTML both on the server side and in client-side JavaScript.

An attacker who can control patient demographic data may inject malicious script that executes in a user's browser when viewing prescription print views or portal signing interfaces, potentially leading to session theft or unauthorized actions in the application.

Affected context

The vulnerability occurs wherever patient names from the patient_data table are rendered directly into HTML without proper encoding.

Two main contexts are affected:

  • The prescription CSS/HTML print view, which uses raw PHP echo to output patient names on the server side.
  • The patient portal signing component (portal/sign/assets/signer_api.js), which uses jQuery's .html() API to inject patient names into the DOM on the client side.

The issue is exposed when patient demographic data is treated as trusted display content, particularly in workflows involving prescription printing and portal signing.

Exploit preconditions

  • Attack surface: Web browser clients accessing OpenEMR features such as prescription print views or the patient portal signing interface.
  • Required access: Ability to create or modify patient demographic records (e.g., patient name fields) through any workflow or API that persists data to patient_data.
  • Trigger point (server-side sink): A user opens the prescription CSS/HTML print view that renders the compromised patient name via raw PHP output.
  • Trigger point (DOM-based sink): A user accesses the portal signing feature where signer_api.js injects the compromised patient name into the DOM using $(...).html(...).
  • Why exploitation is possible: User-controlled patient name fields are stored persistently and later rendered into HTML without context-appropriate encoding or sanitization, allowing embedded script-like content to be interpreted and executed by the browser.

Why this happens

The root cause is improper output handling of untrusted data from patient_data, specifically patient names, which are used directly in HTML contexts without encoding.

On the server side, PHP outputs patient names using raw echo, placing attacker-controlled strings directly into the prescription print view markup.

On the client side, the portal signing code in signer_api.js uses jQuery's .html() method to inject patient names into the DOM, which interprets embedded HTML and script-capable constructs.

These patterns map to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), where application logic fails to neutralize or encode user-supplied data before rendering it in a browser-executable context.

Potential impact

  • Execution of arbitrary JavaScript in the browser of clinicians, administrative staff, or patients viewing affected pages.
  • Theft of session cookies or other sensitive browser-stored credentials associated with OpenEMR.
  • Unauthorized actions performed in the victim's context (e.g., changing records, initiating workflows, or exfiltrating data), potentially leading to broader compromise of patient data.
  • Alteration of on-screen content or user interface elements, which can be abused for phishing or misleading clinical decisions.
  • Lateral movement within the application via XSS-driven request forgery or token theft.

General mitigation guidance

Effective mitigation centers on strict output encoding and avoiding unsafe rendering APIs:

  • Apply context-appropriate output encoding to all patient-supplied fields, especially names and other demographics, before inserting them into HTML, attributes, or JavaScript.
  • On the server side, replace raw echo of patient data with templating helpers or framework functions that HTML-encode output by default.
  • On the client side, avoid using .html() with any untrusted data; prefer .text() or other APIs that treat values as plain text, not markup.
  • Centralize sanitization/encoding of data originating from patient_data so that all paths consuming these fields benefit from consistent protections.
  • Adopt a "safe-by-default" rendering strategy where templates, components, and APIs require explicit opt-in to render raw HTML, and reserve that for strictly controlled content.
  • Limit the privileges and capabilities of browser sessions where possible (e.g., enforcing strict Content Security Policy) to reduce the impact of any residual XSS.

How teams detect issues like this

Detection can leverage both code-level and behavioral techniques:

  • Use static analysis to identify uses of raw echo, print, or equivalent output functions that directly embed database fields, focusing on templates and views that render patient demographics.
  • Add rules to flag instances of jQuery .html() or similar DOM APIs (innerHTML, dangerouslySetInnerHTML) when the source is user-controlled data or database fields.
  • During code review, treat any rendering of patient_data (especially names, addresses, notes) as suspicious unless it passes through a known encoding/sanitization layer.
  • Implement automated tests that inject benign but XSS-revealing payload patterns into patient records, then navigate workflows such as prescription printing and portal signing to surface unencoded output.
  • Use Content Security Policy report-only mode to gather telemetry on attempted script execution from inline or unexpected sources as a signal of potential XSS.

Sources

SourceLink
github.comgithub.com/openemr/openemr/security/advisories/GHSA-68fr-xm3v-p4vw

Frequently asked

questions

Yes. If an attacker can remotely create or modify patient demographic records, they can store malicious content that executes in the browser of any user who later views affected pages such as prescription print views or the portal signing interface.

Exploitation requires the ability to influence the patient name or related demographic fields stored in patient_data. This might involve authenticated access to patient-management features, compromised accounts, or any integration that writes patient records without robust validation.

The most robust fix is to apply strict, context-aware output encoding to all patient data before it is rendered, replace unsafe DOM APIs like .html() with safer alternatives like .text(), and ensure that server-side templates never output raw user-controlled content without encoding.

Establish a secure-by-default rendering approach where all templates and client-side components use centralized encoding helpers, enforce coding standards that prohibit unsafe DOM insertion of user data, and incorporate automated security testing and static analysis checks for XSS-prone patterns into the development workflow.

Find out what's already
exploitable in your codebase.