Registry Mirror
Skip to content

Conversation

@lakhansamani

@lakhansamani lakhansamani commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Logs one start-up warning per JWT key that is below current guidance. Nothing is refused, and no flag or default changes.

Key Warning
RSA under 1024 bits Go refuses the key, so tokens cannot be signed or verified (true today; the warning says so instead of "it still works")
RSA 1024–2047 bits below the 2048-bit minimum in NIST SP 800-131A; still works
RSA 2048–3071 bits below the 3072-bit RSA minimum in NSA's CNSA 1.0 suite; still works
ES256 with a P-256 key below the P-384 minimum in CNSA 1.0; still works. Advice: ES384 or ES512
RSA ≥ 3072, ES384/512, HS*, ML-DSA no warning
  • The primary is judged by its signing (private) key, the secondary by its verifying (public) key. There is no fallback, so a key that cannot sign is never described as working.
  • A weak secondary (--jwt-secondary-*, verification-only) gets its own advice: remove it once its tokens have expired (--refresh-token-expires-in, 30 days by default; CIBA also accepts an expired id_token_hint for up to 30 days).
  • Primary warnings carry the documented zero-downtime rotation:
    1. Add the new key as secondary and restart.
    2. Swap it to primary and restart.
    3. Remove the secondary later.
  • A key that does not parse is skipped. token.New only checks keys are non-empty, so such a key still fails when a token is first signed or verified, as today.
  • make dev now uses a freshly generated 3072-bit dev key (PKCS#1, like the one it replaces), so local runs start without the warning.

Tests. The first commit adds TestJWTKeyStrengthWarnings alone. It does not build on main because the function doesn't exist; today these keys start silently. It covers:

  • 1024, 2048 and 3072-bit RSA.
  • Sizing from the signing key when the public key differs.
  • ES256, ES384, HS256, and unparseable keys.
  • A weak secondary behind a strong primary.
  • That no warning promises a future breaking change.

Verified: go build ./..., go vet ./..., make test (3,501 passed, 0 failed, 25 skipped), make lint (0 issues), make smoke (94 passed; the smoke suite still boots with its RSA-2048 and ES256 keys, so existing configs start unchanged).

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. Key-choice guidance is in the docs PR.

Review follow-up (2bac407)

An adversarial review found no blockers. The follow-up commit:

  • Corrects the under-1024 message.
  • Parses ES256 keys, so the warning fires only for a real P-256 key: not for garbage, an RSA key, or a secondary with no keys.
  • Drops the public-key fallback.
  • Recommends ES384/ES512 for P-256 (RS256 at any size is not a CNSA upgrade over P-256).
  • Cites CNSA 1.0.
  • Gives the secondary concrete removal timing.
  • Switches perf/ to the same 3072-bit dev key as make dev.

The test now also covers:

  • A fixed 512-bit key, generated by OpenSSL because Go won't generate one.
  • An unparseable private key next to a weak public key.
  • ES256 with garbage, with an RSA key, and as a secondary with no keys.
  • Text that must not appear: RS256 advice for ES256, and primary advice on a secondary.

Verification on the branch:

  • make test: 3506 passed, 25 skipped.
  • make lint: 0 issues.
  • make smoke: 94 passed.
  • Upgrade simulation (real binaries): exactly one warning for an RSA-2048 primary; the 3-step rotation the warning describes works with zero failed requests; rollback to 2.5.0 works.

Second review (4e51472)

An independent re-review found that each key slot was still sized with both parsers. A public key in --jwt-private-key, or a private key in --jwt-secondary-public-key, was reported as "It still works", but the server cannot use either. The signing key is now sized only as a private key and the secondary only as a public key, so "There is no fallback" above is now true. Four new cases cover this, and all four fail on the previous head. The under-1024 message now says Go refuses such keys by default, since GODEBUG=rsa1024min=0 lifts the limit.

Verification on the branch: go build, go vet, make test (3510 passed, 0 failed) and make lint (0 issues).

Does not build on main: jwtKeyStrengthWarnings does not exist yet. Today a
1024- or 2048-bit RSA key or an ES256 key starts the server silently.

Pins the contract: weak keys keep working and log one warning each with how
to rotate; the secondary (verification-only) key gets its own advice; the
size is read from the signing key; strong, HMAC and unparseable keys log
nothing here.
Logs one warning per JWT key that still works but is below current
guidance, with how to rotate. Nothing is refused and no flag changes.

- RSA under 2048 bits: below NIST SP 800-131A.
- RSA under 3072 bits, or ES256: below NSA's CNSA suite (RSA-3072, P-384).
- The primary's size is read from its signing key; the secondary's from
  its verifying key, with advice to remove it once the longest token
  lifetime has passed (it never signs).

make dev now uses a 3072-bit dev key, so local runs start without the
warning.
- RSA under 1024 bits: say tokens cannot be signed or verified (Go
  refuses the key) instead of 'it still works'.
- Judge the primary by its signing key only and the secondary by its
  verifying key only; no fallback, so a broken key is never reported as
  working.
- ES256: parse the key and warn only for a real P-256 key (not for
  garbage, an RSA key, or a secondary with no keys).
- Cite NSA's CNSA 1.0 suite. Recommend ES384/ES512 for P-256 (RS256 at
  any size is not an upgrade over P-256 for CNSA).
- Secondary advice no longer says to generate a new key, and names when
  to remove it: --refresh-token-expires-in (30 days by default) and the
  30-day CIBA id_token_hint window.
- perf/ uses the same 3072-bit dev key as make dev.
A public key in --jwt-private-key, or a private key in
--jwt-secondary-public-key, cannot be used there, but was sized with the
other parser and reported as "It still works". Size the signing key only
as a private key and the secondary only as a public key. Note that Go
refuses RSA under 1024 bits by default (GODEBUG can lift it).

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