Summary
OpenEMR has a missing authorization check in its CCDA gateway that can let an authenticated, low-privilege staff user access C-CDA documents belonging to other patients. By requesting document view or download actions for other patient IDs, an attacker may expose sensitive health information.
Affected context
The issue is in OpenEMR's ccdaservice/ccda_gateway.php and affects versions before 8.5.0. It becomes a risk when the gateway handles document view or download requests without verifying that the authenticated user is authorized to access the patient identified by the supplied patient ID.
Exploit preconditions
- Attack surface: The CCDA gateway's document view and download actions
- Required access: An authenticated, low-privilege staff account and its own CSRF token
- Trigger point: A request to the gateway that references another patient's ID
- Why exploitation is possible: The gateway does not adequately enforce patient-level authorization for the requested document; sequential patient IDs may make enumeration easier
Why this happens
The underlying issue is a missing object-level authorization check. The application uses a patient identifier supplied in a request to select a C-CDA document without consistently verifying that the authenticated user may access that patient's record. This maps to CWE-639: Authorization Bypass Through User-Controlled Key, where changing an object reference can expose another user's data.
Potential impact
- An attacker may view or download other patients' C-CDA documents.
- Exposed records could include medications, problems, allergies, and immunizations.
- Unauthorized disclosure could compromise patient privacy and create regulatory or operational consequences.
General mitigation guidance
Common defensive patterns include:
- Enforcing server-side authorization for every patient-specific view and download request.
- Deriving accessible patient records from the authenticated user's permissions rather than trusting a request-supplied identifier.
- Applying consistent record-level access checks across all document actions and alternate routes.
- Limiting staff privileges to the records and operations required for their roles.
- Logging and reviewing access to sensitive documents, including repeated requests across patient identifiers.
How teams detect issues like this
High-level detection approaches include:
- Reviewing gateway and document-handling code for user-controlled identifiers used without record-level authorization checks.
- Using static analysis or code review rules to flag sensitive object lookups followed by document access without an authorization decision.
- Testing access-control policies to confirm users cannot view or download records outside their permitted scope.
- Monitoring for repeated document requests across many patient IDs or unusual access patterns.

