Summary
OpenEMR's Eye Exam PDF creation function contained an Out-of-Band Server-Side Request Forgery issue where user-supplied form answers were parsed as unescaped HTML.
Under these conditions, an attacker with the "Notes - my encounters" role could cause the server to initiate forged HTTP requests to internal or external resources during PDF generation.
Affected context
This vulnerability occurs in OpenEMR instances where:
- Users with the
Notes - my encountersrole can complete Eye Exam forms for patient encounters - The Eye Exam form responses are later rendered into a PDF document
- The PDF generation pipeline interprets the stored answers as HTML content without proper sanitization or output encoding
In such deployments, crafted Eye Exam responses can influence how the PDF engine loads external resources, enabling OOB SSRF from the OpenEMR server environment.
Exploit preconditions
- Attack surface: Eye Exam encounter forms that are later exported/printed as PDF files.
- Required access: Authenticated user with at least the
Notes - my encountersrole and permission to fill Eye Exam forms. - Trigger point: Invoking PDF generation for an encounter containing maliciously crafted Eye Exam answers.
- Why exploitation is possible: The PDF creation logic treats stored form answers as raw HTML and allows resource-loading constructs that the PDF engine or underlying HTTP client resolves from the server's network context, thereby enabling server-initiated requests to attacker-chosen URLs.
Why this happens
The core issue is the direct use of unescaped, user-controlled Eye Exam form data as HTML input to the PDF renderer.
By not applying appropriate output encoding and sanitization, the system allows HTML constructs that reference external resources (for example, images or other fetchable assets) to be embedded in the generated document.
When the PDF engine processes this HTML, it makes outbound requests from the server environment to retrieve those resources, which aligns with CWE-918: Server-Side Request Forgery (SSRF)—the server is tricked into initiating network connections based on attacker-influenced input.
The vulnerability is amplified by the fact that the server's internal network access may differ significantly from that of the user, turning simple HTML rendering into a pivot point for indirect network probing and resource access.
Potential impact
- Could allow attackers to cause the server to make HTTP/HTTPS requests to internal network services that are not directly exposed to users.
- May enable limited internal network reconnaissance (e.g., checking which hosts or ports respond, depending on error behavior and timing).
- Can potentially be used to access or interact with internal web endpoints, metadata services, or management interfaces reachable from the OpenEMR server.
- Might facilitate chaining with other weaknesses (e.g., misconfigured internal services) to escalate impact beyond the application boundary.
General mitigation guidance
Effective mitigation typically focuses on reducing trust in user-controlled content and constraining outbound requests:
- Treat all form responses as untrusted data and apply strict output encoding when embedding them into HTML or PDF templates, avoiding direct HTML interpretation where not necessary.
- Introduce robust HTML sanitization for any content that must remain HTML-capable, removing or neutralizing elements and attributes that can trigger network requests (e.g., remote images, iframes, scripts, CSS imports).
- Prefer safer document-generation patterns that separate layout templates from user data, using templating engines that default to escaped output.
- Restrict the application server's egress network access at the infrastructure level, limiting which external hosts and ports it can reach and blocking access to cloud/VM metadata endpoints and sensitive internal services.
- Apply least-privilege principles to the server environment so that even if outbound requests are triggered, their reach and potential impact are drastically reduced.
How teams detect issues like this
Detection can combine code-centric and infrastructure-level approaches:
- Use static analysis or secure code review to flag patterns where user-provided form fields are injected into HTML or PDF templates without encoding or sanitization.
- Add review checklists for features that generate documents from user data, explicitly questioning whether any resource-loading elements can be influenced by end users.
- Monitor outbound HTTP traffic from application servers for unusual destinations, especially requests that correlate with user-triggered PDF generation events.
- Employ network-level controls and logging (e.g., proxies, firewalls, or service meshes) to observe and restrict unexpected egress from the OpenEMR server.
- Integrate automated security testing tools that simulate SSRF-like inputs in form fields used for document generation workflows.

