]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: jwe: substitute random CEK on RSA1_5 decryption failure per RFC 7516...
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Tue, 26 May 2026 15:26:04 +0000 (17:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 May 2026 16:19:00 +0000 (18:19 +0200)
commit1a5a33396d053fe34adfd52dbf1a767b492c630d
treeec84cac4edee0e4733a99df640d9563c6709500b
parent4e7518ed21adc7d42c5459deea3a18e51fb9c997
BUG/MEDIUM: jwe: substitute random CEK on RSA1_5 decryption failure per RFC 7516 #11.5

do_decrypt_cek_rsa() calls EVP_PKEY_decrypt with RSA_PKCS1_PADDING for
RSA1_5 and returns failure (goto end) on decrypt error. This creates a
measurable timing difference between "padding invalid" (fast exit before
content decryption) and "padding valid + AEAD tag fail" (full AES-GCM/CBC
decryption path), exposing the RSA private key to a Bleichenbacher-style
adaptive attack requiring ~10^4-10^6 queries.

Fix: On RSA_PKCS1_PADDING failure, fill decrypted_cek with random bytes
of the buffer size and return success (retval=0). This forces execution
into decrypt_ciphertext() regardless of padding validity, so the attacker
cannot distinguish valid from invalid padding via timing. The AEAD tag
check in decrypt_ciphertext() will still reject the wrong CEK, but the
timing profile is identical for both branches.

RSA-OAEP variants are not affected (mathematically infeasible to craft
valid ciphertext without the private key).

Introduced by RSA1_5 path lacking constant-time fallback.
src/jwe.c