Security rules

NGB057: Missing OIDC nonce

Reports OpenID Connect sign-ins that do not bind the ID token to the browser session with a nonce: angular-oauth2-oidc login calls with disableNonceCheck: true, and hand-written authorization requests that ask for an id_token from the authorization endpoint (implicit / hybrid flow) without a nonce parameter — in URL strings and in response_type request objects..

Property Value
Rule ID NGB057
Category Navigation & authentication
Default severity medium
CWE CWE-294, CWE-345
Built-in presets recommended: error, strict: error

Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.

What it checks

Reports OpenID Connect sign-ins that do not bind the ID token to the browser session with a nonce: angular-oauth2-oidc login calls with disableNonceCheck: true, and hand-written authorization requests that ask for an id_token from the authorization endpoint (implicit / hybrid flow) without a nonce parameter — in URL strings and in response_type request objects.

Why it matters

When the ID token is returned from the authorization endpoint, the nonce is the only thing that ties it to the sign-in this browser started. Without it, an ID token stolen from logs, history or another client — or injected by an attacker into the redirect — is accepted, and the attacker can sign the victim into the attacker's account or replay a victim's token. OpenID Connect Core makes nonce mandatory for these flows.

Detection behavior and supported patterns

  • angular-oauth2-oidc: tryLogin({ disableNonceCheck: true }), tryLoginImplicitFlow(…), loadDiscoveryDocumentAndTryLogin(…), loadDiscoveryDocumentAndLogin(…) — high confidence when the receiver is OAuthService
  • URLs (string, template literal, concatenation) containing response_type=…id_token… without nonce=
  • Object literals with response_type: 'id_token…' that also carry client_id / redirect_uri and no nonce property (e.g. new URLSearchParams({ … }))
  • The authorization code flow (response_type=code) is not reported: PKCE protects the code and the token is fetched from the token endpoint

Example

TypeScript
location.assign(`${issuer}/authorize?client_id=${id}&response_type=id_token&redirect_uri=${cb}&state=${state}`);

Safer alternative

TypeScript
location.assign(`${issuer}/authorize?client_id=${id}&response_type=code&redirect_uri=${cb}&state=${state}&code_challenge=${challenge}&code_challenge_method=S256`);

Remediation

Use the authorization code flow with PKCE (responseType: 'code'). If ID tokens must come from the authorization endpoint, send a fresh random nonce (crypto.randomUUID()), keep it in session storage, and reject ID tokens whose nonce claim differs. Never set disableNonceCheck.

False-positive considerations

  • Requests whose nonce parameter is appended later by another helper are reported; build the request in one place.

Known limitations

  • Validation of the returned nonce claim in hand-written callbacks is not checked; only whether one is sent.
  • Library configurations (angular-oauth2-oidc AuthConfig, angular-auth-oidc-client) generate nonces themselves and are not reported unless the check is explicitly disabled.

References

Run it

Shell
ngbastion explain NGB057