Summary
OpenEMR's CCR revandapprove controller can allow an authenticated core user to inject SQL by supplying crafted patient_data field names. Depending on the database permissions and affected data, this may expose sensitive values, alter patient records, or enable patient-portal account takeover.
Affected context
The issue is in the CCR revandapprove controller's handling of patient_data field names when constructing an UPDATE statement. OpenEMR deployments are at risk when this controller accepts those names from authenticated core users and uses them in SQL without safely constraining or binding them.
Exploit preconditions
- Attack surface: The CCR revandapprove controller and its patient-data update path
- Required access: Authentication as a core user
- Trigger point: A request that causes the controller to build an UPDATE using supplied patient_data field names
- Why exploitation is possible: Untrusted field names can influence SQL structure, allowing injected SQL expressions to be evaluated as part of the update
Why this happens
The controller allows user-influenced field names to affect the structure of an SQL UPDATE statement. SQL parameters can safely bind values, but identifiers such as column names generally require separate validation against a strict allowlist. Failing to constrain these identifiers can permit SQL injection, mapping to CWE-89: Improper Neutralization of Special Elements used in an SQL Command.
Potential impact
- Attackers may read sensitive database values, including staff password hashes and portal reset values.
- Patient demographic records could be altered.
- Patient-portal accounts could be taken over.
- Exposure or modification of related records may occur depending on database permissions and application behavior.
General mitigation guidance
Defensive patterns focus on keeping user input from controlling SQL structure:
- Use parameterized queries for data values.
- Validate any dynamic identifiers against a fixed allowlist of permitted fields.
- Avoid constructing SQL statements directly from request-supplied names.
- Apply least-privilege permissions to database accounts and application roles.
- Limit access to sensitive patient and account data, and audit changes to those records.
How teams detect issues like this
- Use static analysis to identify SQL built through concatenation or interpolation of request-controlled identifiers.
- Review controller code paths that accept field names or other inputs used to construct SQL structure.
- Enforce code-review and CI policies requiring parameterized queries and allowlisted identifiers for dynamic SQL.
- Monitor for unusual database reads, changes to patient demographics, and unexpected portal-account recovery activity.

