/

CVE-2026-33348

Severity:

HIGH RISK

(8.7)

Stored XSS in OpenEMR Eye Exam Encounter Forms

CVE-2026-33348

Analyzed

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Authenticated Stored XSS leading to session hijacking, data exposure, and UI compromise within the affected role scope

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

OpenEMR versions prior to 8.0.0.3 contain a stored cross-site scripting vulnerability in the Eye Exam encounter form display logic.

Authenticated users with the Notes - my encounters role can inject arbitrary JavaScript into form answers, which is later executed in the browser of any user with the same role when viewing encounter pages or visit history.

Affected context

The vulnerability occurs in the context of Eye Exam forms within patient encounters in OpenEMR deployments prior to 8.0.0.3.

It specifically affects workflows where:

  • Users with the Notes - my encounters role can create or update Eye Exam forms.
  • Form answers are later rendered on encounter pages and in the visit history without proper output encoding.
  • Multiple staff members share the same form role and routinely view those encounter details.

The issue is limited to authenticated usage but can affect a broad set of users who rely on the Eye Exam module for clinical documentation.

Exploit preconditions

  • Attack surface: Web interface of OpenEMR (Eye Exam encounter forms).
  • Required access: Authenticated account with at least the Notes - my encounters role, allowing creation or modification of Eye Exam form entries.
  • Trigger point: Viewing patient encounter pages or visit history that render malicious form answers.
  • Why exploitation is possible: User-supplied form answers are stored in the database and later inserted into HTML responses without the necessary context-aware output encoding or sanitization, enabling persistent execution of injected JavaScript in victims' browsers.

Why this happens

This vulnerability stems from improper neutralization of user-controlled content when rendering Eye Exam form answers.

The application stores raw form inputs from users and later embeds them directly into HTML pages without applying context-appropriate output encoding (e.g., HTML- or JavaScript-encoding) or robust server-side sanitization.

This behavior aligns with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), where dynamically generated pages fail to treat stored user input as untrusted, allowing active script content to be interpreted by the browser.

Potential impact

  • Compromise of sessions or login context for users with the affected role, including potential session token theft via malicious scripts.
  • Unauthorized access to sensitive medical information visible to compromised sessions, subject to the role's privileges.
  • Execution of arbitrary JavaScript in the victim's browser, enabling UI redressing, data exfiltration, or manipulation of clinical records within the user's permissions.
  • Creation of self-propagating payloads that automatically inject further malicious content into other encounter records viewed by affected users.
  • Undermining integrity and trustworthiness of patient encounter documentation, particularly in Eye Exam records.

General mitigation guidance

Effective mitigation focuses on treating all stored form content as untrusted and enforcing strict output encoding at every render point:

  • Apply context-aware output encoding on all form answers before inserting them into HTML pages, ensuring that characters with special meaning in HTML and JavaScript are safely encoded.
  • Avoid building HTML fragments by concatenating raw user input; instead, use templating systems and helpers that encode by default.
  • Introduce server-side validation and normalization that rejects or neutralizes input containing potentially executable markup, while accommodating legitimate clinical free-text where necessary.
  • Limit the privileges associated with roles that can submit or edit encounter forms (including Notes - my encounters) according to least privilege principles, reducing blast radius if abuse occurs.
  • Consider enforcing a Content Security Policy (CSP) that disallows inline JavaScript and restricts script sources, to reduce exploitability of any remaining XSS bugs.
  • Maintain a secure development standard where new form modules and display functions are required to pass XSS-focused code review and automated checks before deployment.

How teams detect issues like this

Detection can combine code-centric and behavior-centric approaches:

  • Static analysis: Configure linters or SAST tools to flag direct insertion of user-controlled variables into HTML responses, templates, or echo statements without passing through a known encoding or sanitization function.
  • Code review signals: During review of encounter-related modules and forms, look for patterns where:
  • Database fields are rendered into HTML without escaping.
  • Custom HTML is assembled via string concatenation or echo statements that include request parameters or stored user content.
  • Template and view audits: Perform targeted inspection of all form display functions, verifying that templating helpers or output routines always apply context-aware encoding for text fields.
  • Runtime monitoring: Use application logs, WAF rules, or security monitoring to detect anomalous form submissions that contain script tags, event handlers, or suspicious JavaScript-like substrings.
  • Testing and QA: Incorporate XSS payload checks into automated functional tests for new or modified encounter forms, ensuring that rendered content appears as inert text and not executable script.

Sources

SourceLink
github.comgithub.com/openemr/openemr/commit/f488efbe3eb7f17d0f057f960020cb611149f8a2
github.comgithub.com/openemr/openemr/releases/tag/v8_0_0_3
github.comgithub.com/openemr/openemr/security/advisories/GHSA-6ch2-p26g-x33h

Frequently asked

questions

It is exploitable wherever the OpenEMR web interface is reachable, but the attacker must already possess valid credentials with the Notes - my encounters role (or equivalent). Once authenticated, they can inject stored XSS payloads that affect other users with the same role.

No. The vulnerability can be exploited by any authenticated user with permissions to fill or edit Eye Exam encounter forms via the Notes - my encounters role. However, the impact is bounded by the data and actions available to that role.

The safest approach is to enforce context-aware output encoding on all stored form answers when rendering them in encounter pages or visit history, combined with input validation that rejects clearly unsafe markup. Additionally, centralizing output encoding through shared helpers or templating engines reduces the likelihood of future bypasses.

Establish a secure coding policy that treats all user and database content as untrusted, mandates default-encoding template engines, and integrates automated XSS checks into CI pipelines. Regular security-focused code reviews for new form modules, combined with defense-in-depth controls such as CSP and least-privilege role design, can significantly reduce the chance of reintroducing stored XSS weaknesses.

Find out what's already
exploitable in your codebase.