Summary
OpenEMR's patient-matching dialog unsafely processes a serialized key parameter, allowing an authenticated attacker to influence patient-matching criteria. Depending on how the affected workflow is used, this could expose patient records through enumeration or cause lab orders to be associated with the wrong patient.
Affected context
The issue affects OpenEMR deployments before 8.3.0 in the patient-matching workflow at interface/orders/patient_match_dialog.php. It becomes risky when an authenticated user can submit a crafted serialized key parameter and the application uses its contents to determine patient matches.
Exploit preconditions
- Attack surface: The patient-matching dialog at
interface/orders/patient_match_dialog.php - Required access: Authentication to the OpenEMR application
- Trigger point: Processing of the submitted serialized key parameter
- Why exploitation is possible: The application deserializes attacker-controlled data and uses it to influence patient-matching criteria
Why this happens
The underlying issue is unsafe deserialization of a user-controlled parameter. Deserializing input without restricting its structure or validating its meaning can let an attacker manipulate application state or decision-making. This maps to CWE-502: Deserialization of Untrusted Data; the reported consequences here involve patient matching rather than demonstrated code execution.
Potential impact
- Patient records may be enumerated, potentially exposing sensitive information.
- Lab orders could be associated with the wrong patient.
- Patient data integrity and downstream clinical workflows may be affected.
General mitigation guidance
Defensive patterns include avoiding general-purpose deserialization of user-controlled values and using a constrained format with an explicit schema. Treat submitted matching criteria as untrusted, validate them against authorized and expected patient data, and keep matching decisions within server-side controls. Apply least privilege to application components and limit access to patient data to what each workflow requires.
How teams detect issues like this
- Use static analysis to identify deserialization of request parameters and other untrusted inputs.
- Review patient-matching code for paths where serialized values influence record selection or order association.
- Log and monitor anomalous matching requests and unexpected changes in patient-order associations, while avoiding unnecessary sensitive data in logs.
- Enforce policy checks that prohibit unsafe deserialization of user-controlled data and require schema validation for request inputs.

