Summary
OpenEMR's one-time authentication flow does not enforce configured token-use limits or revoke tokens after use, and it checks login PINs without rate limiting or strict comparison. A person with a captured service_auth token may be able to replay it, while repeated PIN guesses could open a patient-portal session and expose protected health information (PHI).
Affected context
The flaw is in OpenEMR's src/Common/Auth/OneTimeAuth.php authentication flow. It affects deployments where service_auth tokens and login PINs are used to establish patient-portal sessions and the relevant token-use and PIN-check controls are not enforced.
Exploit preconditions
- Attack surface: Patient-portal one-time authentication.
- Required access: An attacker needs a captured service_auth token to attempt replay, or a way to submit repeated PIN guesses to the authentication flow.
- Trigger point: Token validation and login PIN checking when establishing a portal session.
- Why exploitation is possible: The flow ignores token-use limits, does not revoke consumed tokens, and does not adequately constrain PIN attempts or comparisons.
Why this happens
The authentication flow fails to enforce controls intended to limit token reuse and repeated PIN attempts. Ignoring enforce_onetime_use and max_access_count and leaving consumed tokens valid enables replay; checking PINs without rate limiting or strict comparison weakens resistance to guessing. The missing restriction on repeated authentication attempts maps to CWE-307: Improper Restriction of Excessive Authentication Attempts.
Potential impact
- An attacker could replay a captured token to establish an unauthorized patient-portal session.
- Repeated PIN guesses may allow account or session access.
- Unauthorized sessions may expose PHI.
- Access to portal functions could enable further privacy or integrity harm.
General mitigation guidance
Mitigation patterns include enforcing one-time-use and maximum-access policies on the server, revoking tokens immediately after successful use, and making token consumption atomic to prevent concurrent replay. Apply strict PIN comparison and bounded, monitored authentication attempts, with appropriate delays or lockout controls. Reduce trust in exposed tokens through short lifetimes and narrow scope, and limit the privileges and data available to portal sessions.
How teams detect issues like this
Review authentication code for ignored token-use settings, tokens that remain valid after consumption, non-strict credential comparisons, and PIN checks without effective attempt limits. Use static analysis and code review to identify repeated authentication paths that lack throttling or lockout controls. Monitor for repeated PIN failures, reuse of already-consumed tokens, unusual portal-session creation, and enforce policies for rate limits and token lifecycle behavior.

