Skip to content

Fix/jwt algorithm confirmation - #72

Open
1456055067 wants to merge 2 commits into
TAK-Product-Center:mainfrom
1456055067:fix/jwt-algorithm-confirmation
Open

Fix/jwt algorithm confirmation#72
1456055067 wants to merge 2 commits into
TAK-Product-Center:mainfrom
1456055067:fix/jwt-algorithm-confirmation

Conversation

@1456055067

Copy link
Copy Markdown

Summary

Hardens JWT handling in takserver-core to close two issues found during a security review:

  1. Algorithm confusion on token verification. Verifiers were built with the legacy
    jjwt setSigningKey(Key) API, which selects the verification algorithm from the
    token's own alg header. A token signed RS256 could be re-presented as HS256, causing
    the RSA public key to be used as the HMAC secret. All verifiers now use a
    SigningKeyResolver that pins the expected algorithm (RS256 for OAuth/OIDC,
    HS384 for mission tokens) and rejects any mismatch before signature validation.

  2. Asymmetric key used as a symmetric secret. Mission tokens were HMAC-signed using
    the raw RSA private-key DER bytes as the secret. They now use a dedicated key derived
    via HMAC-SHA384 (PRF/KDF) with domain separation. Derivation remains deterministic, so
    the existing multi-server / missionTls shared-key verification model is preserved.

Changes

  • JwtUtils: add pinnedResolver(...) (algorithm-pinned SigningKeyResolver) and
    deriveHmacKey(...) (HMAC-SHA384 KDF); route all external/OAuth and mission-token
    verifiers through them.
  • MissionTokenUtils: sign with the derived key.
  • Mission-token algorithm moves HS256 → HS384 (FIPS 198-1 approved; CNSA / Suite-B minimum).

Compatibility / deployment notes

  • In-flight mission tokens are invalidated on upgrade (short-lived subscription/
    invitation/access tokens; re-issued automatically). During a rolling upgrade,
    mixed-version servers will not verify each other's mission tokens until all are upgraded.
  • External OAuth/OIDC tokens (RS256, signed by the IdP) are unaffected.

Testing

  • :takserver-core:takserver-war:compileJava
  • :takserver-core:compileTestJava
  • Integration tests (MissionAuthorizationTests) not run in this environment (require DB/Ignite).

Follow-ups (not in this PR)

  • FederationJwtUtils (federation hub) shares the asymmetric-key-as-HMAC-secret pattern;
    lower exploitability (HMAC-only, secret key) but worth the same treatment.
  • Consider upgrading jjwt 0.9.1 → 0.12.x (EOL library; enables native algorithm pinning).

…n-token HMAC key

Close two JWT issues in takserver-core:

- Algorithm confusion: verifiers built via the legacy jjwt setSigningKey(Key)
  API selected the algorithm from the attacker-controlled `alg` header, allowing
  an RS256 token to be re-signed as HS256 using a published RSA public key as the
  HMAC secret. All verifiers now use a SigningKeyResolver that pins the expected
  algorithm (RS256 for OAuth/OIDC, HS384 for mission tokens) and rejects mismatches.
- Mission tokens were HMAC-signed using the raw RSA private-key DER bytes as the
  symmetric secret. They now use a dedicated key derived via HMAC-SHA384 (PRF/KDF)
  with domain separation; derivation stays deterministic so multi-server/missionTls
  verification continues to work.

Mission-token signing/verification moves HS256 -> HS384 (FIPS 198-1 approved,
CNSA/Suite-B minimum). In-flight mission tokens are invalidated on upgrade.
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