Summary
OpenEMR before 8.5.0 does not enforce the grant types registered for OAuth2 clients, allowing requests to use unregistered flows. Under affected conditions, this may let a client bypass the user consent screen or allow a disabled client to redeem an authorization code using a JWT client assertion.
Affected context
The issue affects OpenEMR OAuth2 flows where client grant-type restrictions are not enforced. Risk depends on how clients, consent, authorization codes, and JWT client assertions are configured and used. The described behavior applies to OpenEMR versions before 8.5.0.
Exploit preconditions
- Attack surface: OpenEMR's OAuth2 token and authorization flows
- Required access: An attacker must be able to make requests as, or present credentials for, an OAuth2 client; the exact requirement depends on the deployment's client configuration.
- Trigger point: A token request uses an unregistered
grant_type, or an authorization code is redeemed with a JWT client assertion for a disabled client. - Why exploitation is possible: The registered
oauth_clients.grant_typesvalues are not enforced, and the described code-redemption path can accept assertions from disabled clients.
Why this happens
The underlying issue is missing authorization enforcement: the application does not consistently check whether a client is permitted to use the requested grant type or whether it remains enabled when redeeming an authorization code. This maps to CWE-862: Missing Authorization, because protected OAuth2 operations proceed without applying the relevant client permissions and status checks.
Potential impact
- An attacker may obtain tokens through a grant type that was not registered for the client.
- The password grant may allow a token request to bypass the expected user consent screen.
- A disabled client could potentially redeem an authorization code using a JWT client assertion.
- Tokens issued through these paths could enable unauthorized access to resources within their granted scope.
General mitigation guidance
Common defensive patterns include:
- Enforcing an explicit allowlist of grant types for every client at each relevant authorization and token endpoint.
- Checking client status and authorization-code binding during every redemption, including JWT client assertion flows.
- Applying consistent consent and authorization requirements across grant types rather than relying on a particular flow to provide them.
- Minimizing client privileges and token scopes, and avoiding password-based grants where safer flows are suitable.
- Treating client metadata and token requests as untrusted, and validating them against server-side policy.
How teams detect issues like this
Review OAuth2 handlers for grant-type checks that are missing, incomplete, or applied only during client registration. Check that disabled-client status is verified across all token redemption paths, including those using JWT client assertions. Monitor authorization and token logs for requests using unregistered grant types, token issuance without expected consent, and redemption attempts by disabled clients. Static analysis and policy checks can help identify inconsistent authorization checks across endpoint implementations.

