Summary
OpenEMR portal onsite-document APIs may allow an authenticated core user to access documents belonging to other patients when patient-level authorization is not enforced. By omitting the patient ID and providing record IDs, a user may list, read, or overwrite portal documents, signatures, and template data.
Affected context
The issue affects OpenEMR deployments before 8.4.0 where portal onsite-document API operations do not consistently verify that the authenticated user is authorized for the patient associated with each record. Risk arises when these APIs accept record IDs without requiring and validating the corresponding patient context.
Exploit preconditions
- Attack surface: OpenEMR portal onsite-document APIs
- Required access: An authenticated core user account
- Trigger point: A request to list, read, or overwrite portal document, signature, or template data
- Why exploitation is possible: The API may permit omission of the patient ID and fail to enforce authorization against the patient associated with the supplied record ID
Why this happens
The underlying issue is a missing authorization check, mapped to CWE-862. The API does not reliably verify that the authenticated principal is permitted to access or modify the patient-specific object identified by a request. Relying on a record ID, or on a patient ID supplied by the caller, without enforcing ownership and access policy can expose cross-patient data.
Potential impact
- An authenticated user may be able to read other patients' portal documents.
- Patient signatures or template data could be disclosed or altered.
- Document contents could be overwritten, potentially affecting record integrity and care workflows.
- Unauthorized access may create privacy, compliance, and audit concerns.
General mitigation guidance
Defensive approaches typically ensure authorization is enforced for every patient-specific operation, regardless of which identifiers a request includes.
- Derive the permitted patient scope from the authenticated identity and server-side access policy.
- Check object-level authorization for each record before listing, reading, or modifying it.
- Reject requests with missing, inconsistent, or unauthorized patient context rather than relying on client-supplied identifiers.
- Apply least-privilege access to core user roles and minimize the data each role can reach.
- Log and review denied access attempts and sensitive document changes.
How teams detect issues like this
- Review API handlers for object lookups or mutations that use record IDs without patient-scoped authorization checks.
- Use static analysis or code review rules to flag endpoints where authorization is absent or occurs only at the route level.
- Test access-control policies with users who have different patient scopes, including requests with omitted or mismatched patient identifiers.
- Enforce API security policies requiring object-level authorization for sensitive patient data, and monitor logs for unusual cross-patient access patterns.

