Summary
OpenEMR contains a stored cross-site scripting vulnerability in CAMOS content handling. An authenticated user with CAMOS access may save malicious HTML that runs in a victim's browser when the entry is printed, potentially allowing actions or data access as that user.
Affected context
The issue affects OpenEMR versions before 8.3.0. It occurs when CAMOS content saved through ajax_save.php is later rendered by the non-print_html branch of rx_print.php without appropriate output encoding.
Exploit preconditions
- Attack surface: CAMOS content creation and the printing flow in OpenEMR.
- Required access: An authenticated account with CAMOS access to save content.
- Trigger point: A victim views or prints the saved entry through the affected rendering path.
- Why exploitation is possible: Saved HTML is output without encoding, allowing browser-interpreted script content to execute in the victim's context.
Why this happens
The application treats saved content as trusted HTML when rendering it for printing, rather than encoding it for the output context or restricting it to safe markup. This is a stored cross-site scripting flaw mapped to CWE-79: Improper Neutralization of Input During Web Page Generation.
Potential impact
- A script could perform actions available to the victim within OpenEMR.
- It could read information accessible to the victim through the application.
- It may compromise the victim's session or expose sensitive data, depending on application controls and the victim's permissions.
General mitigation guidance
Defensive approaches generally focus on treating saved content as untrusted and safely handling it at every output point.
- Encode content according to its HTML output context by default.
- If formatted HTML is required, use a strict allowlist-based sanitizer and avoid unsafe rendering paths.
- Reduce trust in user-submitted content, including content created by authenticated users.
- Apply least privilege to user accounts and limit access to CAMOS features to those who need them.
- Use consistent safe-rendering patterns across print and non-print views.
How teams detect issues like this
- Review rendering code for saved or user-controlled content inserted into HTML without context-appropriate encoding.
- Use static analysis to flag unsafe HTML output and bypasses of shared encoding or sanitization utilities.
- Test CAMOS save-and-print workflows with security checks that verify untrusted markup is rendered inert.
- Enforce code review and CI policies requiring safe output handling for user-controlled content.

