/

CVE-2026-46518

Severity:

HIGH RISK

(7.7)

Stored XSS (CWE-79) in OpenEMR prescription multiprint

CVE-2026-46518

Analyzed

Vulnerability type

Category:

Stored Cross-Site Scripting

CWE:

CWE-79, CWE-862

Impact:

Authenticated Session Hijacking and Web UI Compromise

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

A stored cross-site scripting flaw in OpenEMR's prescription CSS/HTML multi-print feature allows attacker-controlled patient data to be rendered without proper output encoding.

A malicious portal user can inject JavaScript that later executes in a clinician's authenticated browser session, potentially enabling actions as that clinician and exposure of session data.

Affected context

The vulnerability appears when OpenEMR is used with the patient portal enabled and clinicians rely on the prescription multi-print feature that renders patient demographic data into HTML/CSS.

It specifically affects flows where patient demographic fields (such as name and address) are displayed without encoding, and where portal users can update their own demographic records directly through the API.

In such deployments, attacker-controlled content can be stored in the backend and later rendered in the main clinician-facing OpenEMR interface.

Exploit preconditions

  • Attack surface: OpenEMR web interface, specifically the prescription CSS/HTML multi-print view used by clinicians.
  • Required access: An authenticated patient portal account with permission to update its own demographic information via the PUT api/patient/:num endpoint.
  • Trigger point: A clinician opens or prints a prescription using the multi-print feature that calls multiprintcss_header(), which renders previously stored patient data.
  • Why exploitation is possible: Patient demographic fields are stored verbatim and later injected into HTML without proper output encoding, enabling stored JavaScript execution in the clinician's browser.

Why this happens

This issue stems from treating user-controlled, persistent data as safe for direct HTML output.

The multiprintcss_header() function renders patient demographic fields into a prescription print template without applying context-appropriate output encoding.

Combined with an API path (PUT api/patient/:num) that allows portal patients to write arbitrary HTML into patient_data while bypassing audit review, this matches CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).

The missing or inconsistent authorization and workflow enforcement on sensitive update operations is related to CWE-862: Missing Authorization, since it permits unreviewed content to reach clinician-facing interfaces.

Potential impact

  • Malicious JavaScript may execute in a clinician's authenticated session.
  • Attackers could perform actions as the clinician, such as modifying records or initiating workflows.
  • Session identifiers, CSRF tokens, and other sensitive data accessible to the clinician's browser can be exposed.
  • Integrity of medical records and prescriptions could be compromised or tampered with.
  • Lateral movement to other internal systems accessed through the clinician's browser may be possible.

General mitigation guidance

Effective mitigation focuses on treating all patient-supplied data as untrusted and enforcing strict output encoding at every render point.

Common defensive patterns include:

  • Applying context-appropriate output encoding for all dynamic data when generating HTML, attributes, JavaScript, or CSS.
  • Constraining rich-text or HTML-capable fields to a safe subset using robust sanitization libraries, or preferring plain-text storage wherever feasible.
  • Implementing strong authorization and workflow checks on patient data modification endpoints, ensuring that audit/review steps cannot be bypassed.
  • Segregating patient-controlled content from clinician-critical interfaces or rendering it within strongly sandboxed components.
  • Adopting a least-privilege design for portal accounts, limiting which fields can be edited and where those fields are subsequently displayed.

How teams detect issues like this

Organizations can detect similar issues by combining static analysis, code review, and runtime monitoring:

  • Use static analysis rules to flag direct insertion of request or database values into HTML templates without encoding.
  • During code review, pay attention to print/export features and shared template helpers like *_header() functions that aggregate and render multiple fields.
  • Enforce secure coding guidelines in CI/CD that require encoding helpers for all templated output and disallow raw HTML output for untrusted fields.
  • Employ dynamic application security testing (DAST) or specialized scanners to probe web interfaces for stored XSS in profile, demographic, and notes fields.

Sources

SourceLink
github.comgithub.com/openemr/openemr/security/advisories/GHSA-4gh4-q39r-45wf

Frequently asked

questions

Exploitation typically requires an authenticated patient portal account, but that account can often be created or compromised remotely; once the payload is stored, the impact occurs in the clinician's browser when they open the affected prescription view.

The attacker needs the ability to update patient demographic data via the portal, specifically using the API endpoint that writes into patient_data. No direct access to the clinician's account or browser is required.

The most robust fix is to ensure all patient-controlled data is properly output-encoded for the context in which it is rendered and to close any authorization or workflow gaps that let unreviewed content reach clinician-facing views.

Establish a standard templating and encoding strategy, mandate its use across all rendering layers, enforce strong authorization on data-modifying APIs, and integrate automated security checks (static and dynamic) into the development and release pipeline to catch unsafe patterns early.

Find out what's already
exploitable in your codebase.