Summary
FeathersJS versions 5.0.0 through 5.0.41 contain an authentication bypass in the OAuth callback handling, where a forged user profile in the query string can be treated as a valid OAuth result.
An unauthenticated attacker can send a crafted GET request directly to /oauth/:provider/callback, causing the service to mint a legitimate JWT for an existing user without ever interacting with the real OAuth provider.
Affected context
This issue affects FeathersJS applications that:
- Use the built-in OAuth integration with routes like
/oauth/:providerand/oauth/:provider/callback - Rely on OAuth providers (e.g., GitHub, Google) for user authentication
- Have the OAuth callback configured in a way that the authentication logic can fall back to
params.querywhen Grant's session/state payload is empty
The vulnerability manifests when the callback endpoint is reachable without prior stateful OAuth negotiation, allowing the query string to influence the authentication payload.
Exploit preconditions
- Attack surface: Public-facing OAuth callback endpoint at
/oauth/:provider/callback - Required access: No prior authentication; any remote attacker who can reach the endpoint
- Trigger point: Direct GET request to the callback URL with a crafted
profile(and related fields) in the query string - Why exploitation is possible: When the OAuth library (Grant) has no established session or state (because no authorization request was initiated), its response is empty. The FeathersJS OAuth service has a fallback chain that ultimately reads from
params.query, treating untrusted query parameters as an authentication profile and using them to drive user lookup and JWT creation.
Why this happens
The vulnerability stems from treating unvalidated, unauthenticated query parameters as trusted identity data in the authentication process.
The OAuth service is designed with a fallback chain that, under error or empty-state conditions, pulls identity information from params.query. This means that when no valid OAuth session or provider response exists, the system still tries to continue the flow by consuming raw request data as an authentication payload. That design violates the core assumption of OAuth: that user identity and profile data must originate from a verified provider response tied to a prior authorization step.
This maps to CWE-287: Improper Authentication, because the system grants authenticated status and issues JWTs without reliably verifying that the caller completed a legitimate OAuth flow or that the profile was issued by the OAuth provider.
Potential impact
- An attacker may obtain a valid JWT for an existing user account without knowing any credentials.
- An attacker could impersonate privileged users if they can guess or influence identifiers used in the entity lookup (e.g., email, provider ID).
- Attackers can access APIs and protected resources as the compromised user, including reading or modifying data within that user's authorization scope.
- If administrative or high-privilege accounts are targeted, the attacker could gain effective full control over the application's data and configuration.
- Stolen or forged JWTs could be reused to maintain long-term unauthorized access until tokens expire or are revoked.
General mitigation guidance
Effective mitigation focuses on ensuring that authentication decisions are based solely on trusted OAuth provider responses and verified state, never on untrusted request parameters:
- Require a valid, non-empty response from the OAuth provider (or from Grant) before constructing any authentication payload; if the provider response is missing, fail closed instead of falling back to request data.
- Remove or strictly constrain fallback chains that read from
params.query,req.query, or similar untrusted sources during authentication processing. - Enforce strong state and session binding: callbacks must verify that they are tied to a prior authorization request (e.g., via state parameter and session identifiers).
- Validate and normalize identity attributes (such as provider ID, email, username) exclusively from provider-signed data, never from raw client input.
- Apply least-privilege account mapping: when in doubt, deny authentication or map to a minimal-privilege account rather than granting access based on ambiguous or incomplete profile information.
- Use configuration patterns that isolate OAuth callback logic from general-purpose request handlers to reduce the chance of mixing untrusted query data with authenticated identity.
How teams detect issues like this
Detection efforts can focus on both code-level analysis and runtime behavior:
- Static analysis and code review:
- Look for authentication flows that read from
params.query,req.query, or similar request data when assembling user profiles or authentication payloads. - Flag any logic paths where JWTs or session tokens are minted if the OAuth provider response is missing, empty, or not explicitly verified.
- Review fallback chains around OAuth and identity handling for patterns like "if provider response is missing, use query/body parameters instead."
- Policy-based checks and tooling:
- Configure linters or custom static analysis rules to detect direct use of request query parameters in authentication or identity mapping code.
- Use automated security review tools to scan for improper authentication patterns related to OAuth callback handlers.
- Runtime monitoring:
- Log all calls to OAuth callback endpoints, including whether a valid prior session/state was present and whether provider responses were consumed.
- Alert on suspicious patterns, such as callbacks with no associated authorization request, or excessive callback hits with unusual query parameters.

