CVE-2025-29789
Executive Summary
CVE-2025-29789 is a directory traversal vulnerability in OpenEMR, a free and open-source electronic health records and medical practice management application. The vulnerability exists in the "Load Code" feature of versions prior to 7.3.0. An attacker can exploit this flaw to read arbitrary files on the server, potentially accessing sensitive patient data, configuration files, or other critical system resources. The vulnerability is patched in version 7.3.0.
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
Supply Chain & Package Security
This vulnerability is not related to a package manager (NPM, PyPI, Go, Ruby) but is a direct vulnerability in the OpenEMR application source code. The risk is primarily to organizations that self-host OpenEMR.
CVSS Breakdown & Threat Level
The CVSS score is listed as 0.0, which is likely a placeholder or uncalculated. Based on the nature of the vulnerability (directory traversal), a reasonable CVSS v3.1 vector would be:
- Attack Vector (AV): Network (N) - The vulnerability is exploitable remotely.
- Attack Complexity (AC): Low (L) - No special conditions are required.
- Privileges Required (PR): Low (L) - An attacker likely needs some level of access to the application, possibly a valid user account.
- User Interaction (UI): None (N) - No user interaction is required.
- Scope (S): Unchanged (U) - The vulnerability does not affect resources beyond the vulnerable component.
- Confidentiality (C): High (H) - Sensitive files can be read.
- Integrity (I): None (N) - File modification is not possible.
- Availability (A): None (N) - No impact on availability.
Estimated CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Estimated Base Score: 6.5 (Medium)
Threat Level: Medium. The vulnerability allows for information disclosure, which is critical in a healthcare context due to HIPAA and other data privacy regulations.
Deep Dive & Mechanics
The vulnerability is located in the "Load Code" feature of OpenEMR. This feature is designed to load code snippets or templates from the server's file system. The flaw is a classic directory traversal (path traversal) vulnerability, where user-supplied input (likely a file path or filename) is not properly sanitized.
Mechanism:
- The "Load Code" feature accepts a file path as input.
- The application fails to validate or sanitize the input to prevent the use of
../(parent directory) sequences. - An attacker can craft a request with a path like
../../../../etc/passwdto read arbitrary files outside the intended directory. - The application then reads and returns the contents of the specified file.
This allows an attacker to read sensitive files such as:
/etc/passwd(user account information)/etc/shadow(password hashes, if readable)- OpenEMR configuration files (e.g.,
sites/default/sqlconf.phpcontaining database credentials) - Patient data files stored on the server
- Application source code
Vulnerable vs. Patched Code
Vulnerable Code (Pre-7.3.0): The vulnerable code likely directly uses user input to construct a file path without sanitization. A simplified example in PHP:
<?php
$file = $_GET['file'];
$content = file_get_contents($file);
echo $content;
?>
Patched Code (7.3.0+): The patched code sanitizes the input to prevent directory traversal. A simplified example:
<?php
$file = $_GET['file'];
$baseDir = '/var/www/openemr/code_templates/';
$file = basename($file); // Remove directory components
$file = str_replace('..', '', $file); // Remove parent directory references
$file = $baseDir . $file;
if (file_exists($file) && strpos(realpath($file), $baseDir) === 0) {
$content = file_get_contents($file);
echo $content;
} else {
echo "File not found.";
}
?>
The patched code uses basename() to strip directory components, removes .. sequences, and verifies that the resolved path is within the allowed base directory.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy a vulnerable version of OpenEMR (e.g., 7.2.0) in a controlled environment (e.g., Docker).
- Obtain a valid user account (e.g., by registering or using default credentials).
Exploitation Steps:
- Log in to OpenEMR.
- Navigate to the "Load Code" feature (likely under Administration or a similar menu).
- Intercept the request using a proxy like Burp Suite.
- Modify the request parameter that specifies the file path. For example, if the parameter is
file, change it to../../../../etc/passwd. - Send the request.
- Observe the response, which should contain the contents of
/etc/passwd.
Example HTTP Request (using curl):
curl -X GET "http://target-openemr/load_code.php?file=../../../../etc/passwd" -b "PHPSESSID=your_session_cookie"
Blue Team (Defensive)
Detection:
- Monitor web server logs for requests containing
../or..%2fin parameters related to file loading. - Look for requests to
load_code.phpor similar endpoints with suspicious file paths. - Use a Web Application Firewall (WAF) to block directory traversal patterns.
Prevention:
- Apply the patch by upgrading to OpenEMR 7.3.0 or later.
- Implement input validation and sanitization on all user-supplied file paths.
- Use a whitelist of allowed files or directories.
- Run the application with the least privileges necessary (e.g., do not run as root).
- Use a chroot jail or containerization to limit the impact of a successful exploit.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP requests containing
../or..%2fin parameters (e.g.,file=../../../../etc/passwd). - Requests to
load_code.phpor similar endpoints with unusual file paths. - Outbound connections from the server to unknown IPs (if data exfiltration occurs).
- HTTP requests containing
File System IOCs:
- Unexpected access to sensitive files like
/etc/passwd,/etc/shadow, or database configuration files. - Modified application logs showing file read attempts outside the web root.
- Unexpected access to sensitive files like
Log IOCs:
- Web server access logs showing
200 OKresponses for requests with directory traversal patterns. - Application error logs indicating failed file reads or permission errors.
- Web server access logs showing
Detection Engineering
YARA Rule
rule CVE_2025_29789_Directory_Traversal {
meta:
description = "Detects directory traversal attempts targeting OpenEMR Load Code feature"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-29789"
strings:
$traversal1 = "..\\" ascii wide nocase
$traversal2 = "..%2f" ascii wide nocase
$traversal3 = "..%5c" ascii wide nocase
$param1 = "file=" ascii wide nocase
$param2 = "path=" ascii wide nocase
$param3 = "load_code" ascii wide nocase
condition:
any of ($param*) and any of ($traversal*)
}
Sigma Rule
title: CVE-2025-29789 OpenEMR Directory Traversal
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects directory traversal attempts against OpenEMR Load Code feature
author: Valters IT
date: 2025/04/10
references:
- https://nvd.nist.gov/vuln/detail/CVE-2025-29789
logsource:
category: webserver
product: apache
service: access_log
detection:
selection:
cs-uri-query|contains:
- '..\\'
- '..%2f'
- '..%5c'
cs-uri-stem|contains:
- 'load_code'
condition: selection
falsepositives:
- Legitimate use of file paths with dots (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-29789 OpenEMR Directory Traversal Attempt"; flow:to_server,established; content:"GET"; http_method; content:"load_code"; http_uri; content:".."; http_uri; distance:0; pcre:"/\.\.\//i"; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade OpenEMR: The primary remediation is to upgrade to version 7.3.0 or later, which contains the patch for this vulnerability.
- Apply Virtual Patching: If immediate upgrade is not possible, use a Web Application Firewall (WAF) to block requests containing directory traversal patterns (e.g.,
../,..%2f) in parameters associated with the Load Code feature. - Restrict File Permissions: Ensure that the web server runs with minimal privileges and that sensitive files (e.g.,
/etc/shadow, database configs) are not readable by the web server user.
Long-Term Mitigations:
- Input Validation: Implement strict input validation for all file path parameters. Use a whitelist of allowed files or directories.
- Security Audits: Regularly conduct security audits and penetration testing of the OpenEMR instance.
- Monitoring: Implement robust logging and monitoring to detect and alert on suspicious file access patterns.
- Least Privilege: Run the application with the least privileges necessary and use containerization or chroot jails to limit the impact of a successful exploit.
Valters IT
DevSecOps & Cyber Threat Intelligence Expert