Summary
OpenEMR's patient portal contains an insecure direct object reference that can let an authenticated patient change settings belonging to another patient. The issue becomes risky when the server accepts a patient identifier from a request without confirming that the requesting patient is authorized to update that patient's settings.
Affected context
The vulnerability is reported in portal/lib/persist.php in OpenEMR versions before 8.3.0. It concerns JSON POST requests that include the setting_patient parameter to identify whose portal settings are being changed; risk exists if the target patient identifier is not checked against the authenticated user's authorization.
Exploit preconditions
- Attack surface: The patient portal settings persistence endpoint.
- Required access: An authenticated portal patient account.
- Trigger point: A JSON POST request handled by
portal/lib/persist.php. - Why exploitation is possible: The request's
setting_patientvalue can be changed to another patient's PID if the server does not verify that the authenticated user may modify settings for that patient.
Why this happens
The underlying issue is an authorization check that does not adequately bind the requested patient record to the authenticated user's permissions. Trusting a client-supplied object identifier without verifying access can allow one user to modify another user's data. This maps to CWE-639: Authorization Bypass Through User-Controlled Key.
Potential impact
- An authenticated patient may be able to alter another patient's portal settings, such as the portal theme.
- Unauthorized changes could affect the other patient's portal experience.
- Repeated or broader access-control gaps could put additional patient-specific settings at risk.
General mitigation guidance
Common defensive patterns include:
- Deriving the target patient identity from the authenticated session where possible, rather than trusting a client-supplied identifier.
- Enforcing a server-side authorization check for every requested patient record and settings change.
- Applying deny-by-default access rules and limiting permissions to the minimum necessary.
- Validating requested changes against an explicit allowlist of settings and permitted actions.
- Keeping authorization checks close to the operation that reads or writes patient data.
How teams detect issues like this
- Review handlers that accept patient identifiers from request parameters and verify that authorization is checked for the specific target record.
- Use static analysis or code review rules to flag writes keyed by client-controlled identifiers without a corresponding access-control check.
- Add tests that confirm a patient cannot read or modify another patient's settings by changing an identifier.
- Apply policy checks to require object-level authorization for patient data operations; automated code review tools may help identify missing checks.

