/

CVE-2026-33346

Severity:

HIGH RISK

(8.7)

Stored XSS in OpenEMR Patient Portal Payment Flow

CVE-2026-33346

Modified

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Client-Side Code Execution in Staff Browsers

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 (XSS) vulnerability in OpenEMR's patient portal payment flow allows arbitrary JavaScript to be persisted by a portal user and later executed in the browser of a staff member reviewing the payment.

When attacker-controlled payment data is stored without proper output encoding and then rendered into HTML, it can execute in privileged staff sessions, enabling session theft, data access, or user interface manipulation.

Affected context

The vulnerability occurs in OpenEMR's patient portal payment workflow, where payment-related fields submitted by a patient portal user are processed by portal/lib/paylib.php and persisted in backend storage.

When staff users later review these payment submissions via portal/portal_payment.php, the stored values are rendered into the response without proper HTML/JavaScript escaping.

This becomes risky in deployments where patient portal users can freely enter payment notes or descriptors that are later displayed to authenticated staff within the same application origin.

Exploit preconditions

  • Attack surface: Web-based patient portal payment submission interface.
  • Required access: A valid or compromised patient portal account capable of submitting payment information.
  • Trigger point: A staff member opens or reviews the affected payment entry in the portal/portal_payment.php interface.
  • Why exploitation is possible: User-supplied payment fields are stored and then rendered into an HTML context without proper output encoding or context-aware escaping, allowing embedded script code to be interpreted by the browser.

Why this happens

This issue stems from insufficient output encoding of user-controlled data when displayed in an HTML page, corresponding to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).

The payment data accepted via portal/lib/paylib.php is treated as benign text but later inserted into the HTML response in portal/portal_payment.php without applying robust, context-appropriate escaping.

As a result, any HTML or JavaScript fragments embedded in those fields are executed by the browser in the security context of the staff user's session.

Potential impact

  • Staff session hijacking via theft of session identifiers or authentication tokens stored in cookies or browser storage.
  • Unauthorized access to sensitive medical records and patient data that the compromised staff account can view.
  • Manipulation of the staff user interface to alter or falsify patient information and payment records.
  • Use of the application as a pivot to perform further actions on behalf of the staff user (e.g., configuration changes, prescription handling, record updates).
  • Distribution of malicious scripts to additional internal users who access affected payment records.

General mitigation guidance

Effective mitigation focuses on strengthening output handling and reducing trust in user-submitted data across the full rendering path.

Recommended patterns include:

  • Applying strict, context-aware output encoding on all user-controlled fields before insertion into HTML, attributes, JavaScript, or URLs.
  • Centralizing templating and response generation so that unsafe direct echoes or concatenations are replaced with framework helpers that auto-escape output.
  • Restricting allowed content for payment-related fields to a safe character set (e.g., alphanumeric plus limited punctuation) and validating length and format on both client and server sides.
  • Implementing a defense-in-depth Content Security Policy (CSP) that disallows inline scripts and restricts script sources, reducing the impact of any residual XSS issues.
  • Following a strict separation of data and code in views, avoiding dynamic construction of HTML or JavaScript with raw user data.

How teams detect issues like this

Detection generally relies on a combination of static review and behavioral testing:

  • Static analysis: Use SAST rules to flag locations where user input flows from HTTP request parameters or database fields into HTML output without passing through known escaping APIs or templating engines.
  • Code review: During manual review, trace the life cycle of user-controlled fields (such as payment notes) from input handling functions (e.g., portal/lib/paylib.php) through to rendering endpoints (portal/portal_payment.php), verifying that all sinks apply appropriate encoding.
  • Dynamic testing: Employ automated and manual web security testing to inject harmless XSS test payloads into payment fields and observe whether they are reflected or executed in staff-facing views.
  • Policy enforcement: Introduce coding standards and CI checks requiring context-aware escaping for all new or modified templates, and optionally integrate automated code scanning tools into the pull request workflow.

Sources

SourceLink
github.comgithub.com/openemr/openemr/commit/6e9e1566d6e271a6d839614674b887e3a73d7da1
github.comgithub.com/openemr/openemr/security/advisories/GHSA-qvf6-6xc6-9qv7

Frequently asked

questions

Yes. Any attacker who can obtain or control a patient portal account and submit payment information can remotely plant a stored XSS payload that later executes in a staff member's browser when they review the payment.

The attacker needs the ability to log into the patient portal and submit payment-related data, or otherwise control such an account (for example, via account compromise or social engineering). Direct access to staff credentials is not required.

The most robust fix is to ensure that every user-controlled value rendered in staff-facing views is passed through context-aware output encoding or escaping routines, ideally via a templating system that auto-escapes by default, and to normalize/validate payment fields to simple text formats.

Adopt a secure development pattern that treats all persisted user input as untrusted, enforces strict server-side validation, uses auto-escaping view layers, and complements these with a restrictive Content Security Policy and automated static analysis rules that flag unsafe output sinks.

Find out what's already
exploitable in your codebase.