Summary
The Azure Active Directory authentication plugin's OAuth 2.0 flow reused long-lived PHP session identifiers as the state parameter and failed to rotate sessions after login, exposing users to session fixation and hijacking.
Combined with missing HTTPS enforcement for redirect URIs and unsafe logging of attacker-controlled parameters, these weaknesses increase the risk of credential leakage, replay attacks, and audit log corruption during authentication.
Affected context
This vulnerability occurs in applications integrating Azure Active Directory via the affected OAuth 2.0 plugin when the PHP session identifier doubles as the OAuth state parameter and is reused across authentication cycles.
It is most relevant in deployments where redirect URIs may not be enforced as HTTPS, and where application or infrastructure logs capture full OAuth URLs or error responses containing user-controlled parameters.
Risk is elevated when logs are broadly accessible, reverse proxies or external monitoring systems record request metadata, or users authenticate over unencrypted connections.
Exploit preconditions
- Attack surface: The OAuth 2.0 authorization and callback endpoints exposed by the Azure AD authentication plugin.
- Required access: Ability to observe or influence OAuth requests and responses (e.g., via shared logs, browser history, referrer headers, network sniffing on HTTP, or crafted authentication flows).
- Trigger point: Initiation of the OAuth login process, including redirect to the identity provider and handling of the callback with the
stateparameter, authorization code, and error parameters. - Why exploitation is possible:
- The PHP session identifier is directly reused as the OAuth
state, causing it to appear in URLs, logs, and headers. - Session IDs are not rotated after successful authentication, enabling session fixation when a victim authenticates under an attacker-controlled session.
- The
statevalue is not treated as a dedicated, single-use nonce, weakening CSRF and replay defenses around the callback. - Redirect URIs can be non-HTTPS, allowing authorization codes and tokens to traverse the network in plaintext.
- Error responses containing attacker-controlled parameters are logged without sanitization or length limits, allowing log forging and injection.
Why this happens
The primary root cause aligns with CWE-384: Session Fixation, where the application fails to ensure that a fresh session identifier is created after authentication and instead reuses a potentially attacker-controlled session ID.
Conceptually, the plugin conflates authentication credentials (the PHP session identifier) with protocol integrity metadata (the OAuth state parameter), causing sensitive session tokens to be embedded in redirect URLs and observable across multiple layers of infrastructure.
The state parameter is not implemented as a dedicated, cryptographically strong, single-use nonce, weakening its role as a CSRF token and replay safeguard in OAuth flows.
Additional contributing patterns include insufficient transport-layer protections (accepting non-HTTPS redirect URIs) and unsafe logging of user-supplied error parameters, which together expose tokens, authorization codes, and arbitrary log content to attackers.
Potential impact
- Attackers may hijack active user sessions by obtaining leaked PHP session identifiers.
- Attackers could perform session fixation attacks, forcing victims to authenticate under a known session ID and later reusing it.
- CSRF protections around the OAuth callback can be weakened, enabling unauthorized or replayed authorization responses.
- Authorization codes and access tokens may be intercepted over the network if non-HTTPS redirect URIs are used.
- Application and audit logs could be forged, injected with misleading entries, or corrupted using crafted error parameters.
- Security monitoring and incident response may be undermined due to compromised or ambiguous log integrity.
General mitigation guidance
Effective mitigation focuses on strengthening session management and protocol integrity boundaries within the OAuth 2.0 integration.
Common patterns include:
- Ensuring session identifiers are treated solely as authentication credentials and never embedded in protocol parameters such as
stateor redirect URLs. - Rotating the session identifier upon successful authentication and at other trust boundary transitions to prevent fixation.
- Implementing
stateas a dedicated, cryptographically random, single-use nonce tied to the user's session and invalidated after the callback. - Enforcing HTTPS-only redirect URIs and rejecting any non-TLS endpoints for OAuth callbacks to protect authorization codes and tokens in transit.
- Reducing log exposure by sanitizing, truncating, and structuring logged parameters, avoiding direct inclusion of attacker-controlled content.
- Applying least-privilege access and strict controls around log storage, ensuring sensitive tokens or identifiers are not recorded where possible.
How teams detect issues like this
Detection typically involves a combination of configuration review, code analysis, and log inspection:
- Perform targeted code reviews on authentication modules to verify that session identifiers are rotated after login and never reused as protocol integrity parameters like
state. - Use static analysis or linters to flag patterns where session IDs appear in URLs, GET parameters, or are written to logs, and where
statelacks nonce properties (e.g., deterministic or long-lived values). - Evaluate OAuth configuration for redirect URIs that permit non-HTTPS schemes, and enforce policy checks that require TLS for all callback endpoints.
- Inspect logging code paths that handle OAuth error responses and ensure attacker-controlled inputs are validated, sanitized, and length-limited before recording.
- Consider automated security testing tools that can simulate OAuth flows, detect session fixation behaviors, and highlight CSRF weaknesses around state validation.

