/

CVE-2026-33301

Severity:

HIGH RISK

(8.1)

Improper Output Encoding in OpenEMR Eye Exam PDF Generation

CVE-2026-33301

Analyzed

Vulnerability type

Category:

Improper Output Encoding

CWE:

CWE-116

Impact:

Arbitrary File Read via PDF Generation

Severity:

HIGH RISK

(8.1)

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's Eye Exam PDF generation feature fails to correctly encode user-supplied form data before treating it as HTML.

Under certain conditions, a user with the Notes - my encounters role can craft Eye Exam answers that cause the server to embed arbitrary image files from the filesystem into the generated PDF, leading to an arbitrary file read exposure via the PDF output.

Affected context

The vulnerability exists in OpenEMR deployments where Eye Exam encounter forms are enabled and can be completed by users with the Notes - my encounters role.

When generating a PDF for a completed Eye Exam, the application takes the stored answers and incorporates them into an HTML template that is then rendered as a PDF.

Because these answers are not safely encoded or sanitized before being interpreted as HTML, crafted input can influence resource references in the PDF, enabling inclusion of arbitrary image files that reside on the server and are accessible to the application process.

Exploit preconditions

  • Attack surface: Eye Exam form completion and subsequent PDF generation functionality within OpenEMR.
  • Required access: Authenticated access with at least the Notes - my encounters role (or equivalent) that can fill Eye Exam forms and trigger PDF export.
  • Trigger point: Submission of specially crafted Eye Exam answers followed by invoking the PDF print/export feature for that encounter.
  • Why exploitation is possible: The PDF generation pipeline treats stored form answers as trusted HTML content without proper output encoding, allowing attacker-controlled markup to reference local server files (e.g., images) that are then embedded into the generated PDF returned to the attacker.

Why this happens

The issue stems from improper output encoding of user-supplied data in an HTML-to-PDF workflow.

Instead of encoding Eye Exam form answers as plain text before inserting them into an HTML template, the application processes them as raw HTML.

This aligns with CWE-116: Improper Encoding or Escaping of Output, where untrusted data is rendered within an output context that gives it more authority than intended.

In this case, the unescaped content can inject or alter HTML elements (such as image tags) whose source attributes point to files on the server, causing these resources to be fetched and embedded into the resulting PDF.

Potential impact

  • Exposure of arbitrary server-resident image files that are readable by the application process.
  • Disclosure of sensitive medical images or internal assets unintentionally stored on the server.
  • Leakage of internal file paths and structural information about the server environment.
  • Assistance in further attacks by revealing information useful for privilege escalation or lateral movement.

General mitigation guidance

Effective mitigation focuses on enforcing strict output encoding and controlling how user data is incorporated into document templates:

  • Encode all user-supplied form values as text when inserting them into HTML or other rich formats, ensuring that they cannot be interpreted as markup or resource references.
  • Constrain the allowed HTML, if HTML is required, using a robust allowlist-based sanitizer that strips or neutralizes elements and attributes capable of referencing local resources (for example, img src, iframe, or similar tags).
  • Design PDF generation templates so that only application-controlled paths and assets can be referenced; disallow dynamic, user-controlled file paths in any resource attributes.
  • Apply the principle of least privilege to the process that generates PDFs, limiting its filesystem read access to only the directories strictly required for operation.
  • Treat all form fields as untrusted input regardless of user role, applying the same encoding and sanitization rules to privileged and non-privileged users.

How teams detect issues like this

Detection can rely on a combination of static analysis, code review practices, and runtime monitoring:

  • Use static analysis rules to identify template rendering code where user-controlled variables are inserted into HTML or PDF templates without passing through encoding or sanitization functions.
  • During manual code review, pay attention to any HTML-to-PDF pipelines, especially those that interpolate form data or notes directly into HTML strings or templates.
  • Enforce secure coding policies that require explicit output encoding functions for all untrusted data in templates and views, with checks integrated into code review and CI pipelines.
  • Consider automated scanning tools that understand server-side templating patterns and can flag unescaped variables in PDF or document generation logic.
  • Monitor logs or application telemetry for unusual patterns of Eye Exam form content or repeated PDF generation requests that may indicate probing for file disclosure.

Sources

SourceLink
github.comgithub.com/openemr/openemr/commit/dccc962f06bdf6105ca85c277915167caf3e7c28
github.comgithub.com/openemr/openemr/security/advisories/GHSA-v9v3-q973-xp2h

Frequently asked

questions

Yes, but only by authenticated users who can access the Eye Exam form and trigger PDF generation. The attack can be conducted over standard web access to the OpenEMR instance; no local shell access is required.

The attacker needs an account with at least the Notes - my encounters role (or another role with equivalent permissions) that allows filling Eye Exam forms and generating PDFs for those encounters.

The safest fix is to ensure that all user-supplied data is properly encoded for the output context before rendering—here, HTML destined for PDF generation. This typically means treating user input as plain text, or, if limited HTML is necessary, sanitizing it with a strict allowlist and preventing user control over resource paths.

Adopt a consistent output-encoding strategy across the application, backed by shared utility functions or libraries; avoid ever inserting raw user input into HTML, templates, or documents. Combine this with security-focused code review, static analysis rules that flag unescaped output, and architectural patterns that separate trusted template logic from untrusted data.

Find out what's already
exploitable in your codebase.