]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: jwe: reject non-empty encrypted keys with "dir" and "ECDH-ES"
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Tue, 20 Oct 2026 08:04:48 +0000 (10:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Oct 2026 15:43:19 +0000 (17:43 +0200)
commit5b0bc00d5cae843b00c262335d88c47b45f9b5d9
tree417e36c86e888753f2ef1c4a879378eb32114b3c
parent6e8acfdb7572ecdd297db2ae4cc5bf99c0134665
BUG/MINOR: jwe: reject non-empty encrypted keys with "dir" and "ECDH-ES"

RFC 7516 section 5.2 step 10 requires that when direct encryption ("dir")
or direct key agreement ("ECDH-ES") are used, the JWE Encrypted Key part
of the token is empty. The jwt_decrypt_jwk() converter with "dir", and
both jwt_decrypt_jwk() and jwt_decrypt_cert() with "ECDH-ES", silently
ignore this part.

This can be reproduced by inserting any base64url string (e.g. "AAAA")
between the first two dots of a "dir" or "ECDH-ES" token: the converters
still return the decrypted contents.

Let's reject the token when the encrypted key is not empty for these
algorithms.

This fix must be backported to 3.4.
reg-tests/jwt/jwt_decrypt_direct_cek.vtc [new file with mode: 0644]
src/jwe.c