Summary
OpenEMR's SOAP note update API does not verify that the supplied note ID belongs to the patient and encounter in the request. An authenticated user with encounter and note permissions may therefore overwrite another patient's clinical note and reassign its patient ID.
Affected context
The issue affects OpenEMR deployments before 8.3.0 where the SOAP note update API accepts a patient ID, encounter ID, and SOAP note ID. Risk arises when the API checks the caller's general permissions but does not confirm that the note is associated with the specified patient and encounter.
Exploit preconditions
- Attack surface: The SOAP note update API at
/api/patient/:pid/encounter/:eid/soap_note/:sid - Required access: An authenticated account with encounters/notes permission
- Trigger point: A PUT request that updates a SOAP note
- Why exploitation is possible: The API does not verify that the supplied note ID belongs to the patient and encounter identified in the request
Why this happens
The API uses a client-supplied object identifier without enforcing the relationship between that object and the requested patient and encounter. This is a broken object-level authorization flaw mapped to CWE-639: Authorization Bypass Through User-Controlled Key. Authorization checks need to validate access to the specific note, not only the user's general permission to update notes.
Potential impact
- Clinical notes could be overwritten without authorization
- A note could be reassigned to a different patient record
- Patient records could become inaccurate or inconsistent
- Clinical workflows and trust in record integrity could be disrupted
General mitigation guidance
Defensive patterns focus on authorizing access to each specific note and enforcing its relationship to the patient and encounter on the server.
- Derive object access from the authenticated user's authorized scope rather than trusting identifiers supplied by the client
- Check that the note, patient, and encounter form a valid association before allowing updates
- Deny updates when an object is missing, mismatched, or outside the caller's permitted scope
- Apply least privilege to accounts and roles that can modify clinical notes
- Keep authorization checks close to the operation that reads or changes the record
How teams detect issues like this
- Review API handlers for authorization checks that rely on user permissions but omit per-object ownership or relationship checks
- Use static analysis or code review rules to flag client-controlled identifiers used in database updates without scoped authorization
- Test API policies with mismatched patient, encounter, and note identifiers, verifying that updates are rejected
- Monitor audit logs for note updates where the note's patient or encounter association changes unexpectedly
- Enforce server-side authorization requirements through API policy checks and CI tests

