Summary
OpenEMR has OAuth scope canonicalization and containment flaws that can let unauthenticated attackers obtain unapproved system-level access to FHIR Patient resources. If the OAuth registration and authorization flow is exposed, an attacker may bypass approval and request permissions to read, modify, or create Patient records.
Affected context
The issue affects OpenEMR deployments before 8.4.0 where OAuth scope handling does not consistently canonicalize and constrain system-level FHIR scopes. A client may register a colon-form scope such as system:Patient.read and then request an unregistered slash-form scope such as system/Patient.write, potentially bypassing approval checks.
Exploit preconditions
- Attack surface: OpenEMR's OAuth client registration and FHIR authorization flows
- Required access: The described attack is unauthenticated; it does not require an existing user account
- Trigger point: Scope registration and subsequent scope evaluation during an OAuth request
- Why exploitation is possible: Inconsistent scope canonicalization and containment checks may allow an unapproved system-level scope to pass authorization
Why this happens
The underlying flaw is improper authorization (CWE-863). Scope values are not consistently normalized and checked against the scopes approved for a client, allowing differently formatted values to evade containment or approval logic. Authorization decisions should be based on a canonical representation and an exact, policy-bound set of permitted scopes.
Potential impact
- Attackers may read Patient records without approval
- Attackers could modify existing Patient records
- Attackers may create Patient records
- Unauthorized access could affect the confidentiality and integrity of healthcare data
General mitigation guidance
Defensive patterns include canonicalizing scope values before both registration and authorization, then comparing requests against an explicit allowlist of scopes approved for each client. Reject ambiguous or unsupported scope formats, and default to denying access when validation or containment checks fail. Limit client registration and FHIR permissions to the minimum necessary, and apply access controls and monitoring around OAuth registration and token issuance.
How teams detect issues like this
Review OAuth scope parsing and authorization code for inconsistent normalization, substring-based containment checks, or approval decisions made against non-canonical values. Test that unapproved scope variants are rejected and that requested scopes cannot exceed a client's approved permissions. Enforce policies requiring explicit scope allowlists and fail-closed authorization; automated static analysis and security testing can help identify risky patterns.

