]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: jwe: validate the secret length against the algorithm of the token
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 6 Aug 2026 07:33:59 +0000 (09:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Aug 2026 08:43:55 +0000 (10:43 +0200)
commitba26a4e85311761928b58b2c58a2c15da1e02cd6
treee7494b55db6f4ba3c482e80adf84b3b4726213eb
parent378386e14225f6aea45b9254ba00973cdaf20ff8
BUG/MEDIUM: jwe: validate the secret length against the algorithm of the token

The "alg" field of the JOSE header of a JWE token selects the key-wrapping
algorithm, hence the AES key size, while the key itself is the secret
configured by the operator for the "jwt_decrypt_secret" converter. That
secret is stored in an exact-size heap allocation, and neither
decrypt_cek_aeskw() nor aes_process() (used by the AES-GCM key wrap
variant) checked that it was large enough for the selected cipher before
handing its address to OpenSSL.

So a client sending a token that declares A256KW or A256GCMKW while the
configured secret is only 16 bytes long makes OpenSSL read 16 bytes past
the end of that allocation and use them as key material. This is a
remotely triggered heap over-read which may crash the worker, and whose
bytes influence the decryption result.

Let's check the secret length against the cipher's key length in both
paths before initializing the cipher.

Both were introduced in 3.4, by commits f0e64de75 ("MINOR: ssl: Factorize
AES GCM data processing") and 416b87d5d ("MINOR: jwe: Add new
jwt_decrypt_secret converter"). This must be backported to 3.4.

Reported-by: Claude (ANT-2026-TS9WFQ5T)
Reported-by: Claude (ANT-2026-9T34RNDD)
src/jwe.c
src/ssl_sample.c