Skip to content

v3.6.3

Choose a tag to compare

@benmcollins benmcollins released this 16 Nov 14:36
· 62 commits to master since this release
3a5f02b

LibJWT 3.6.3 is a security release. It fixes three vulnerabilities, plus hardening found while fixing them. All 3.x users should upgrade. 3.6.0 to 3.6.2 are affected by all three; 3.4.x and 3.5.x by GHSA-4jp4-6w6j-ff4q and GHSA-g7xw-4cjw-2247; earlier 3.x releases by GHSA-g7xw-4cjw-2247, which affects only the jwt-verify tool.

This release is ABI-compatible with 3.6.2. An nm diff shows the same 155 exported symbols, so per the libtool rules only the SONAME revision advances (18:2:4 → 18:3:4). The SONAME stays libjwt.so.14 and existing binaries keep working. Some of the behavior changes below may still need application changes.

🛡️ Security fixes

  • GHSA-vmf4-mvgm-7vpv (Critical, 3.6.0–3.6.2): embedded-JWK verification accepted tokens forged against a pinned or allowlisted OKP (Ed25519, Ed448) or AKP (ML-DSA) public key, with the OpenSSL and GnuTLS backends.
    • Affected: jwt_checker_enable_embedded_jwk() and jwt_checker_enable_embedded_jwk_keyring(). A header "jwk" could carry a trusted party's public member with the attacker's own private member; the thumbprint matched the first and the signature was checked with the second.
    • Fix: a private OKP or AKP JWK whose public member is not the public key of its private member is put in error, and a header "jwk" that has any private member or a "keys" member is refused before it is loaded.
  • GHSA-4jp4-6w6j-ff4q (High, 3.4.0–3.6.2): JWKs that failed to load were still used, x5c was not bound to the key, and the public export could leak private members.
    • Affected: a key in error could crash a build with both OpenSSL and MbedTLS after a backend switch (a NULL dereference), and from 3.6.0 keys flagged in error after loading still verified tokens. From 3.6.0 a JWK could also pair one party's key with another party's x5c certificate. From 3.4.0 the public export kept the private members of a key whose kty the build does not recognise, members private to another key type, and the RSA oth member.
    • Fix: a key in error is never used, a JWK whose x5c leaf does not hold its key is put in error, and the public form drops every private member.
  • GHSA-g7xw-4cjw-2247 (High, 3.0.0–3.6.2): the exit status of the jwt-verify tool was the number of failed tokens, so 256 failures exited 0, and a long stdin line was verified as several tokens. A script that trusted the exit status could accept a forged token. The library API is not affected.
    • Fix: jwt-verify exits 0 only when every token verified, and a stdin line is never split.

⚠️ Behavior changes

  • Keys in error (jwks_item_error())
    • jwt_builder_setkey(), jwt_checker_setkey(), jwt_builder_add_signature() and verify or generate callbacks refuse them with Key is in error and cannot be used; with a JWS JSON or keyring token, a callback's key in error simply does not verify. jwe_builder_setkey(), jwe_builder_add_recipient() and jwe_checker_setkey() refuse them with Key is in error and cannot be used for JWE, and jwt_builder_setcnf_jwk() returns an error. Keyrings skip them, so a key set keeps working with its good keys.
    • A refused setkey keeps the key set before it. A checker or builder left with no key rejects every token, or generates none, instead of going unsigned.
    • Keys flagged after loading (a malformed or mismatched x5c, an x5t#S256 mismatch, a non-string alg) no longer sign or verify.
    • jwks_item_key_bits() and jwks_item_is_private() return 0 for a key that failed to load, and the X.509 accessors read as absent for a key in error.
  • x5c: a JWK whose x5c leaf certificate does not hold the JWK's key is now in error. That includes a chain in the wrong order, a certificate kept after its key was rotated, an EC leaf with a compressed point or explicit parameters, and x5c on an oct key. An empty x5c array is unchanged.
  • OKP and AKP keys: with OpenSSL and GnuTLS, a private key whose x or pub cannot be read or does not match its d or priv no longer loads.
  • Embedded JWK: a header "jwk" with a "keys" member or any private member (d, p, q, dp, dq, qi, oth, k, priv) is refused, whatever its value.
  • Public export: every private member name is dropped whatever the kty, and a key of a type the build does not know has no public form. The public form of a key in error also drops x5c, x5t, x5t#S256 and x5u. AKP is recognised in every build, so public ML-DSA keys are exported even without ML-DSA support.
  • jwt-verify
    • The exit status is 0 or 1, not a count. Empty or unreadable stdin exits 1, and so do - token ..., and -h or -l unless it is the only argument.
    • A stdin line of 1 MiB or more, or with a NUL byte, is one failed token. Tokens of up to 1048575 bytes now verify from stdin; before, a newline-terminated token over BUFSIZ - 2 bytes (8190 with glibc, 1022 on macOS) was read in pieces and failed.
    • --print without --verbose is a usage error.
    • Control bytes (0x00–0x1f and 0x7f) in a printed token or error message are shown as \xNN.
    • On Windows, stdin is read in binary mode, so a 0x1A byte no longer ends the input early, and a CRLF line keeps its CR and fails, as it already did on other systems.
  • jwt-verify and jwt-generate
    • A --print command ended by a signal fails the token or the generated output. On Windows the command's exit status is now checked too; it used to be ignored.
    • -k with a key set that holds no keys exits 1 instead of crashing.

🔒 Hardening and fixes

  • JSON null "x5c" and "alg" members read the same under Jansson and json-c.
  • A remote JWKS refresh whose keys are all in error no longer replaces a good cached key set.
  • The x5c leaf is read by a strict, bounds-checked DER parser in common code, so the binding check is the same on every backend.

📚 Documentation

  • jwt-verify(1) has a new EXIT STATUS section, no longer says -q returns the number of failures, and says to pass an untrusted token on stdin as one line, or to reject it if it starts with -. Both man pages say a --print command ended by a signal fails.
  • The setkey functions document that a refused key leaves the previous key in place.
  • jwks_item_x5c() documents that only the public members are compared with the leaf certificate.

Full Changelog: v3.6.2...v3.6.3