Summary
OpenEMR's upload handler does not adequately check whether an authenticated user is authorized to access or change the document identified by a supplied doc_id. A low-privilege user may be able to enumerate document IDs to read patient information or overwrite medical records belonging to other patients.
Affected context
The issue occurs in library/ajax/upload.php when the fetch and save actions handle document IDs without sufficient authorization checks. Deployments may be at risk when authenticated users can reach these actions and the handler does not verify that each document belongs to a patient or record the user is permitted to access. The description identifies OpenEMR versions before 8.3.0 as affected.
Exploit preconditions
- Attack surface: The OpenEMR upload handler's fetch and save actions
- Required access: An authenticated account; the account may have low privileges
- Trigger point: A request that supplies a document ID to fetch or save
- Why exploitation is possible: The handler does not adequately authorize access to the requested document, allowing users to try arbitrary or enumerated IDs
Why this happens
The underlying issue is a failure to enforce authorization on a document-level operation. The handler accepts a supplied doc_id without reliably verifying that the authenticated user may read or modify the associated document. This is an instance of CWE-862: Missing Authorization: access is permitted without the required authorization check.
Potential impact
- Patient health information may be disclosed to unauthorized users.
- Medical records or document data may be overwritten or tampered with.
- Unauthorized changes could affect clinical workflows or record integrity.
- Exposure or alteration could extend across multiple patients if document IDs are accessible.
General mitigation guidance
Common defensive patterns include:
- Enforcing authorization checks on every document read and write, including AJAX actions.
- Deriving the permitted patient and document scope from the authenticated user's server-side identity and role, rather than trusting a client-supplied ID.
- Applying consistent ownership and access-policy checks before fetching or saving document data.
- Following least-privilege principles for user roles and limiting access to sensitive records by default.
- Logging and reviewing denied access attempts and unusual document access patterns.
How teams detect issues like this
Review document-handling endpoints for authorization checks that occur before data is fetched or changed. Static analysis and code review can flag handlers that use client-supplied identifiers in database or file operations without a corresponding access-policy check. Test access policies with accounts of different roles and patient scopes, and enforce server-side authorization requirements through API policies and security tests.

