Registry Mirror
Skip to content

Conversation

@lakhansamani

@lakhansamani lakhansamani commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Signatures Authorizer verifies from outside parties are still accepted when the key is RSA under 3072 bits or P-256, but they are now visible. That covers client assertions from trusted issuers and upstream ID tokens from SSO connections. Nothing is refused.

  • Counter: authorizer_weak_signature_verifications_total{surface, alg}, incremented for every such token that is accepted. Rejected ones (expired, replayed, wrong audience) are not counted.
    • surface is client_assertion or sso_id_token.
    • alg comes from the verifier's allow-list, so both labels are bounded.
  • Log: one warning per issuer or connection and key size (e.g. RSA-2048) per process. It names the issuer, kid (truncated to 64 bytes), alg and key size, and asks the issuer to rotate.
    • The warn-once sets are keyed by trust row or connection plus key class, never by kid, so they are bounded by the number of configured issuers whatever an upstream puts in its headers.
  • Classifier: crypto.WeakJWSKey(key), a pure function. It looks at the key the signature was actually verified with, captured by wrapping the keyfunc, not at the JWKS or the header.
  • Signature unchanged: verifyIDTokenAgainstJWKS keeps its signature and its 10 test callers. The new verifyIDTokenKey also returns the verifying key.

Tests. The first commit adds the tests alone. They don't build on main because the classifier, counter and warn-once state don't exist; today these signatures are accepted silently.

  • TestWeakIssuerKeysAcceptedCountedAndLoggedOnce:
    • ES256 and RSA-2048 assertions still authenticate.
    • Each is counted and logged once per key.
    • RSA-3072 is neither counted nor logged.
  • TestSSOIDTokenReportsVerifyingKey and TestSSOWeakKeyCountedAndLoggedOnce: the same contract on the SSO side.
  • TestWeakJWSKey: classifier cases.

Existing SSO and client-assertion tests, which sign with RSA-2048, pass unchanged.

Verified: go build ./..., go vet ./..., make test (3,494 passed, 0 failed, 25 skipped), make lint (0 issues).

TestVerifySSOIDTokenCountsAcceptedWeakKeys exercises the noteWeakSSOKey call in verifySSOIDToken end to end, against an httptest JWKS.

Which issue(s) does this PR fix?

None filed; part of the signing-key strength review.

If this PR affects any API reference documentation, please share the updated endpoint references

No API change. The new metric is documented in the docs PR (Metrics & Monitoring).

Review follow-up (8a42d30)

An adversarial review found no blockers. Accept and reject decisions match main exactly. It found three things worth fixing, all fixed here:

  • Unbounded warn-once set. An org admin controls its OIDC connection's identity provider, and keying the set by kid let it add an entry and a log line on every login: +37 MiB over 200 logins with 64 KiB kids. The set is now keyed by connection and key class, and kid is truncated in logs.
  • Rejected client assertions were counted and logged as "still accepted", because the check ran right after the signature. It now runs just before acceptance, as on the SSO side.
  • WeakJWSKey panicked on nil or malformed keys; it now returns "".

New tests:

  • TestVerifySSOIDTokenCountsAcceptedWeakKeys: end to end through verifySSOIDToken, with the JWKS served over HTTP via the e2e seam. Two accepted, one rejected (bad nonce): the count is +2 and there is one log line.
  • Expired and replayed assertions are not counted.
  • 64 KiB kids: one set entry, and the log stays under 2 KB.
  • Nil and malformed keys.
  • TruncateForLog.

Scope, now stated in the docs:

  • Only OIDC SSO connections and trusted issuers are checked.
  • SAML SP connections and social logins are not.

Verification on the branch:

  • make test: 3496 passed, 25 skipped.
  • make lint: 0 issues.
  • The new tests pass under -race -count=2.

Second review

An independent re-review found nothing that changes whether a token is accepted. No code change; two notes:

  • What "accepted" means on each surface.
    • Client assertions are counted after the replay, client and active checks.
    • SSO ID tokens are counted once their signature and claims verify. JIT provisioning can still refuse the user afterwards (for example, not an active org member); that login is counted, because the weak key was relied on.
    • The docs now say "tokens that fail verification are not counted" rather than "rejected tokens".
  • Noise is a design choice. The threshold is CNSA 1.0 (RSA under 3072 bits, P-256). Many identity providers sign with RSA-2048, so on many deployments the counter will rise with SSO traffic. The warning is logged once per connection and key size per process.

…ed once

Does not build on main: WeakJWSKey, the weak-signature counter and the
warn-once state do not exist yet. Today an ES256 or RSA-2048 signature from
a trusted issuer or SSO connection is accepted silently.

Pins the contract: such signatures keep verifying; each is counted under
authorizer_weak_signature_verifications_total{surface,alg}; each issuer or
connection key is logged once; 3072-bit RSA and P-384 are neither.
Client assertions (trusted issuers) and upstream ID tokens (SSO
connections) signed with RSA under 3072 bits or P-256 are still accepted;
nothing is refused. Now each such verification:

- counts authorizer_weak_signature_verifications_total{surface,alg}
  (surface=client_assertion|sso_id_token; alg is allow-listed, so both
  labels are bounded), and
- logs one warning per issuer or connection key per process, naming the
  issuer, kid, alg and key size, asking the issuer to rotate.

The check uses the key the signature was actually verified with. Only
verified keys enter the warn-once sets, so they are bounded by the issuers'
real keys. verifyIDTokenAgainstJWKS keeps its signature; verifyIDTokenKey
also returns the verifying key.
…review)

- Client assertions: the weak-key counter and warning ran right after the
  signature check, so expired, mis-addressed and replayed assertions were
  counted (and warned about as 'still accepted'). They are now recorded
  just before the assertion is accepted, matching the SSO side.
- Warn-once sets are keyed by trust row / connection plus key class
  (e.g. RSA-2048), not by the token's kid. An org admin controls its OIDC
  connection's identity provider; keying by kid let it add a set entry and
  a log line (with a kid of up to ~1 MiB) on every login. kid is now
  truncated to 64 bytes in logs.
- WeakJWSKey returns '' for nil or malformed keys instead of panicking.
- New end-to-end test through verifySSOIDToken (JWKS over HTTP via the
  e2e seam): accepted weak ID tokens counted, a rejected one not.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant