ReviewOS

home-lang/home

Reject RSA certificates in JWT HMAC verification

#283
Closed chris opened this 10 days ago ·
10 days ago

Bun corpus slice

  • Position 4035: js/third_party/jsonwebtoken/wrong_alg.test.js

Gap

The suite reads pub.pem as UTF-8. It is an X.509 certificate, so source-path metadata is unavailable and Home currently classifies it as a symmetric secret. That permits an HS256 token to be checked against RSA certificate material instead of rejecting the algorithm confusion attempt.

Acceptance criteria

  • classify PEM certificates as asymmetric RSA key material in the JWT path
  • reject HS verification with certificate/public-key material
  • preserve explicit algorithm allowlist rejection for RS/PS mismatches
  • retain structured key/algorithm verification errors and operation stacks
  • focused and permanent JWT matrices pass
10 days ago

Implemented and pushed in 71d4a78 (fix(jwt): reject certificate algorithm confusion).

What landed:

  • PEM X.509 certificates are classified as asymmetric RSA material even when read as primitive UTF-8 strings
  • default verification algorithms are inferred from key family, matching jsonwebtoken behavior
  • certificate/HS confusion fails early as invalid algorithm with claim=algorithm
  • explicitly allowing HS with an asymmetric key still reaches the more specific symmetric-key diagnostic
  • the exact Bun file is now in the permanent JWT/utility mini-suite

Verification:

  • position 4035: 4 passed, 0 failed/todo/unsupported
  • positions 4034–4035: 23 passed, 1 todo, 0 failed/unsupported
  • permanent third-party error diagnostics: 20 passed
  • full always-on JWT/utility mini-suite: passed

This advances the contiguous full-corpus boundary through position 4035: 377 files, 3,425 passed, 229 todo, 0 failed, 0 unsupported (172 allowlisted empty files).

Sign in to comment on this issue.