Summary
OpenEMR encounter-form endpoints may allow authenticated clinical users to access or modify records belonging to other patients when patient and encounter ownership checks are missing. If form identifiers can be guessed or enumerated, an attacker may read or overwrite clinical records by changing an identifier in a request.
Affected context
The issue affects OpenEMR encounter-form view and save endpoints in versions before 8.3.0. The described endpoints include soap/view.php and save.php; risk arises where a request's form identifier is accepted without verifying that the authenticated user is authorized to access the associated patient and encounter.
Exploit preconditions
- Attack surface: Encounter-form view and save endpoints
- Required access: An authenticated clinical user account
- Trigger point: A request that supplies an encounter-form identifier
- Why exploitation is possible: Identifiers may be sequential, and affected endpoints lack checks tying the requested form to a patient and encounter the user is permitted to access
Why this happens
The underlying issue is an authorization failure involving a user-controlled object identifier. When an endpoint retrieves or updates a form by its identifier without checking the user's access to the associated patient and encounter, changing that identifier may expose or alter another patient's record. This maps to CWE-639: Authorization Bypass Through User-Controlled Key.
Potential impact
- An authenticated user could read clinical records belonging to other patients
- An authenticated user could overwrite or otherwise modify another patient's clinical records
- Unauthorized changes could affect the accuracy and integrity of clinical information
General mitigation guidance
Common defensive patterns include:
- Enforce server-side authorization checks for every record-level read and write, verifying access to the associated patient and encounter
- Derive permitted records from the authenticated user's authorized scope rather than trusting client-supplied identifiers
- Apply the same authorization policy consistently across view, save, and related endpoints
- Use least-privilege roles and limit access to patient records to what users need for their work
- Treat identifiers as references, not proof of authorization; unpredictable identifiers alone are not a substitute for access checks
How teams detect issues like this
- Use static analysis and code review to find endpoints that fetch or update records using request-supplied identifiers without object-level authorization checks
- Review encounter-form routes for consistent patient and encounter ownership validation on both reads and writes
- Test authorization policies to confirm that users cannot access records outside their permitted scope by changing identifiers
- Monitor for unusual patterns of sequential identifier access or cross-patient record updates
- Use automated security review tools as a complement to manual authorization testing

