Summary
OpenEMR contains a path traversal vulnerability in its ERA payment and EOB search handling that can let authenticated billing users write attacker-controlled content outside the intended ERA directory. The risk arises when an uploaded X12 835 file contains crafted path information that is used to determine a file destination without adequate containment checks.
Affected context
The vulnerability affects file handling in era_payments.php and sl_eob_search.php. It becomes relevant when an authenticated billing user can upload an X12 835 file and the application processes its GS04 element to construct a destination path. The impact depends on which locations are writable by the web server.
Exploit preconditions
- Attack surface: ERA payment processing and EOB search file handling
- Required access: An authenticated account with billing access sufficient to submit an X12 835 file
- Trigger point: Processing an uploaded file whose GS04 value influences the output path
- Why exploitation is possible: Path information from the file can escape the intended ERA directory if the application does not constrain the resolved destination
Why this happens
The underlying issue is insufficient validation and containment of a file path derived from untrusted input. If traversal sequences in the GS04 element are incorporated into a destination path without reliably restricting the resolved path to the ERA directory, the application may write outside that directory. This is a path traversal weakness covered by CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Potential impact
- Attacker-controlled content could overwrite
.edior.835files in locations writable by the web server. - File integrity or application behavior could be affected, depending on which files are overwritten.
- Sensitive data or services could be disrupted if important files are modified.
- The consequences could extend to other applications or processes that rely on writable files.
General mitigation guidance
Defensive patterns focus on preventing untrusted file metadata from selecting arbitrary destinations.
- Derive storage paths from trusted, server-controlled identifiers rather than uploaded values.
- Canonicalize candidate paths and verify that they remain within the intended storage directory before writing.
- Apply strict validation to file metadata, while treating validation as an additional control rather than the sole path boundary.
- Store uploads in a dedicated location with narrowly scoped write permissions, and run the web server with least privilege.
- Prefer storage designs that do not allow uploaded content to overwrite existing files.
How teams detect issues like this
- Use static analysis to identify file-write operations whose paths are influenced by request data or uploaded-file metadata.
- Review code paths that parse GS04 and other file fields, especially where values are joined with filesystem paths.
- Check that path canonicalization and directory-boundary enforcement occur before every relevant file write.
- Apply policy checks that flag untrusted input flowing into filesystem destinations and verify that web-server write permissions are limited.
- Automated code review tools can help identify risky input-to-file-write flows.

