Summary
OpenEMR's fax/SMS disposeDocument action does not adequately validate the file_path parameter, creating a file path control and access control weakness. An authenticated low-privilege user may be able to read sensitive files, including database configuration, and write files as the web user, potentially leading to remote code execution.
Affected context
The issue is in the fax/SMS module's disposeDocument action, where a supplied file_path is used without adequate validation or authorization checks. It affects OpenEMR deployments with this vulnerable behavior; exploitation depends on the action being reachable and the web process having access to the targeted files or write locations.
Exploit preconditions
- Attack surface: The fax/SMS module's
disposeDocumentaction - Required access: An authenticated account with low privileges
- Trigger point: Processing a request containing a
file_pathvalue - Why exploitation is possible: Insufficient path validation and access control may let a user reach files or write locations beyond those intended for the action
Why this happens
The application uses a caller-controlled file path without sufficiently constraining it to an authorized location or verifying that the user may perform the requested operation. This maps to CWE-73: External Control of File Name or Path. When path handling and authorization checks are inadequate, file operations may expose sensitive data or permit writes outside the intended scope.
Potential impact
- An attacker could read sensitive files, including database configuration and credentials.
- An attacker may write arbitrary files with the web server user's permissions.
- A crafted file write could enable remote code execution under the web server account.
- Compromised credentials or application access could facilitate further compromise.
General mitigation guidance
Defensive patterns include:
- Derive file locations from trusted server-side identifiers rather than accepting arbitrary paths.
- Canonicalize and validate paths, and enforce that resolved locations remain within explicitly authorized directories.
- Apply authorization checks to each file operation and limit file access to the minimum required.
- Keep sensitive configuration files outside locations accessible to application file operations.
- Run the web process with least privilege and restrict its filesystem write permissions.
- Treat request parameters as untrusted and use allowlists for permitted document identifiers and operations.
How teams detect issues like this
- Review file-handling code for request parameters that flow into path construction, file reads, or writes.
- Use static analysis to identify externally controlled paths and verify canonicalization and directory-boundary checks.
- Check whether authorization is enforced at the point of each file operation, rather than only at module entry.
- Monitor application and web-server logs for unusual document paths, denied file access, and unexpected file creation.
- Apply policy checks that flag file operations using untrusted input without explicit validation and authorization.

