Summary
A path traversal vulnerability in OpenEMR's disposeDocument() method allows authenticated users to read arbitrary files from the server filesystem.
Any logged-in user, regardless of role or privilege level, can exploit this flaw to access sensitive server-side files whenever the vulnerable EtherFax action is reachable.
Affected context
This vulnerability occurs in OpenEMR deployments that have the EtherFax functionality available and expose the disposeDocument() method via the web interface.
The issue is triggered when user-controlled input is used to determine which document or file is handled on the server, without properly constraining the resulting file path.
It becomes risky in environments where:
- Application users include non-admin or low-privileged accounts
- The web server user has read access to sensitive application, system, or configuration files
- File paths passed into EtherFaxActions are not normalized or strictly validated against an expected directory
Exploit preconditions
- Attack surface: HTTP(S) interface to the OpenEMR application, specifically the EtherFax actions endpoint that exposes
disposeDocument(). - Required access: Any valid OpenEMR user account; no administrative privileges are required.
- Trigger point: An HTTP request that causes
disposeDocument()to operate on a file path influenced by user-controlled input. - Why exploitation is possible: The method uses attacker-influenced path components without enforcing strict directory constraints or canonicalization, enabling traversal outside the intended document directory and into arbitrary locations on the filesystem.
Why this happens
The underlying issue is improper neutralization and validation of user-controlled path input before it is used in filesystem operations, corresponding to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Within EtherFaxActions.php, the disposeDocument() method appears to construct file paths based on request parameters or other untrusted input, but fails to:
- Restrict the resulting path to an expected base directory
- Normalize and canonicalize the path to remove
../and similar traversal sequences - Enforce allowlists of valid document identifiers instead of accepting raw paths
As a result, the file operation logic trusts data derived from the client, enabling low-privileged users to target files outside the intended document storage area.
Potential impact
- Disclosure of sensitive application configuration files (e.g., database credentials or API keys)
- Exposure of protected health information (PHI) and other medical records stored in accessible directories
- Leakage of system files that can aid further attacks (e.g., user lists, log files, or environment configuration)
- Facilitation of privilege escalation by revealing internal secrets used elsewhere in the infrastructure
- Assistance in reconnaissance for subsequent exploitation, persistence, or lateral movement
General mitigation guidance
Effective mitigation centers on strictly controlling file paths and removing direct path control from users:
- Use opaque, server-side identifiers (IDs or hashes) for documents and resolve them to file paths on the server, instead of accepting user-provided paths.
- Enforce a fixed base directory for all file operations and reject any path that, after canonicalization, falls outside this directory.
- Normalize and canonicalize requested paths before use, and explicitly block traversal tokens such as
../or absolute paths. - Implement allowlists for file types and locations; only permit operations on known, expected document locations.
- Run the web server and application with the least-privileged account possible, limiting access to only the directories required for OpenEMR.
- Treat all user-supplied parameters affecting filesystem operations as untrusted and subject them to centralized validation routines.
How teams detect issues like this
Detection can combine code-centric and operational approaches:
- Static analysis: Configure rules to flag any use of user-controlled input in file operations (e.g.,
fopen,file_get_contents, or similar APIs) without path normalization and directory constraints. - Code review cues: Look for concatenation of request parameters into file paths, direct use of
$_GET/$_POSTvalues as filenames, or logic that trusts client-selected paths for internal documents. - Centralized validation checks: Mandate use of shared utilities for resolving document IDs to paths, and review exceptions where raw paths are still used.
- Runtime monitoring: Analyze web server and application logs for suspicious patterns such as
../sequences in request parameters or repeated access attempts to configuration and system files. - Automated security testing tools and DAST scanners can often detect directory traversal patterns by fuzzing parameters that influence file access.

