Summary
OpenEMR's classic document controller may allow a low-privilege authenticated user to change the category of documents belonging to other patients. If the controller does not verify document ownership and access rights during both recategorization and retrieval, an attacker may expose protected health information (PHI) and tamper with patient charts.
Affected context
The issue occurs in the classic document controller's document-move and retrieval flows. It is relevant when authorization checks do not consistently confirm that the authenticated user may access the specific document and patient record. The described behavior involves moving documents into a patients|demo category and retrieving them with an empty patient_id.
Exploit preconditions
- Attack surface: The classic document controller's document categorization and retrieval functions
- Required access: An authenticated account with low privileges
- Trigger point: A document move request followed by a retrieval request
- Why exploitation is possible: The controller may permit actions on another patient's document without verifying the user's authorization for that document and its associated patient
Why this happens
The underlying issue is a missing or incomplete authorization check, mapped to CWE-862: Missing Authorization. The vulnerable pattern is accepting an operation on a document based on request parameters or category state without enforcing object-level permissions for the document's owner and associated patient. Authentication alone does not establish authorization to move or retrieve another patient's records.
Potential impact
- An attacker may access PHI belonging to other patients.
- Patient documents could be moved or recategorized without authorization.
- Clinical charts could be altered or made less reliable.
- Unauthorized disclosure or tampering could affect privacy and care workflows.
General mitigation guidance
Defensive patterns focus on enforcing authorization for every operation involving a patient document.
- Check the authenticated user's permissions against the specific document and patient on both move and retrieval operations.
- Derive patient and document scope from trusted server-side records rather than relying on client-supplied identifiers or category values.
- Treat empty, missing, or ambiguous patient identifiers as invalid unless an explicitly authorized workflow allows them.
- Apply least privilege to document-management roles and keep authorization rules consistent across controller actions.
- Use secure-by-default access controls that deny requests when ownership or permission cannot be established.
How teams detect issues like this
- Review controller code for document actions that do not perform object-level authorization checks.
- Use static analysis and code review to identify request parameters that select documents or patients without a corresponding permission check.
- Test authorization policies across document moves and retrievals, including missing or empty identifiers and cross-patient access attempts.
- Monitor audit logs for unusual document recategorization or retrieval patterns, and enforce policies requiring auditable access to patient records.

