Summary
OpenEMR has a persistent SQL injection vulnerability in the processing of X12 835 ERA billing files. An attacker with billing write access may submit a crafted file whose claim control number is later included in a database query without escaping, potentially exposing patient health information when the file is reprocessed.
Affected context
The issue occurs in the OpenEMR SLEOB invoice-number handling path for uploaded X12 835 ERA files. The described risk arises when a user with billing write access can submit an ERA file and the stored file is later processed through the billing workflow.
Exploit preconditions
- Attack surface: ERA file upload and processing in the billing workflow
- Required access: Billing write access sufficient to upload an X12 835 ERA file
- Trigger point: Processing or reprocessing the stored file through the ERA workflow
- Why exploitation is possible: The CLP01 claim control number is concatenated into a SQL query without appropriate escaping or parameterization
Why this happens
The application constructs a database query by concatenating a value from an uploaded ERA file into SQL. Because the CLP01 claim control number is not safely separated from query syntax, crafted input may alter the query's behavior. This is CWE-89: SQL Injection, an improper neutralization of special elements used in an SQL command.
Potential impact
- An attacker may be able to infer or extract patient health information from the database.
- Database queries may return or modify data beyond the intended billing operation.
- Repeated processing of a stored file could cause the injected behavior to recur.
- Billing data integrity and confidentiality could be affected.
General mitigation guidance
Common defensive patterns include:
- Use parameterized queries or prepared statements for all values derived from files or other untrusted sources.
- Treat uploaded ERA content as untrusted, even after it has been stored or passed through initial validation.
- Apply strict format and schema validation, while not relying on validation as a substitute for query parameterization.
- Limit database account privileges to the minimum operations required by the billing workflow.
- Make file-processing behavior explicit and controlled, and avoid unintended repeated processing of stored inputs.
How teams detect issues like this
- Use static analysis to identify SQL queries built through string concatenation, especially where values originate from uploaded files.
- Review the SLEOB invoice-number handling and related ERA parsing and processing paths for unsafe query construction.
- Enforce code-review or CI policies requiring parameterized database access.
- Monitor database and application logs for anomalous query behavior during ERA processing, and review unusual access to patient records.

