33046 Commits

Author SHA1 Message Date
Ben Taylor
757e75732d Add note clarifying that output integrity for the chachpoly update is currently provided, though not gauranteed in the future
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit b70d73e6a7591f99a05e8b1c03f0b3915ae7cdff)
2026-06-11 14:11:30 +01:00
Ben Taylor
4ee90fe0e6 Correct logic for keystream_bytes_used
Co-authored-by: minosgalanakis <30719586+minosgalanakis@users.noreply.github.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
(cherry picked from commit 8de9f6aa776d5e92d77b10dfca6666f83f542ab2)
2026-06-11 14:11:24 +01:00
Ben Taylor
bac83ee5de Add additional verification that output hasn't been modified
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 720ee2392a6ced5ee0220a87c20d6c3d43a10650)
2026-06-11 14:11:16 +01:00
Ben Taylor
29090200c2 Update tests to reflect change to lenght checking
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit f650b3f761ff5d88c94800d168b1889567106eec)
2026-06-11 14:11:10 +01:00
Ben Taylor
89005658bc Remove issue number and add CVE to ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 84bb99ca557ddfe4864d3b9ae84299ba4fb0c358)
2026-06-11 14:11:05 +01:00
Ben Taylor
77a2831999 Remove length checking from chacha20
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 21594d5f6daeb8b6f633d481d3335bd7399f8237)
2026-06-11 14:10:53 +01:00
Ben Taylor
176bea08b7 Correct maximum size for chacha20
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 540c75e5a0fa787b6e4ffdaec33648f83b850b6a)
2026-06-11 14:10:47 +01:00
Ben Taylor
e1641d00e2 Remove assertion that ctx.ciphertext_len is 0
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 3f3d3da789e05f078a4df9995278d3d53e273513)
2026-06-11 14:10:42 +01:00
Ben Taylor
98b1bf9f2e fix asserts in old chachapoly_update_too_long_preserves_state function
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 57ac277339e9e9684caf1e8a3bad20c57678ea83)
2026-06-11 14:10:35 +01:00
Ben Taylor
08accf7b92 Fix code style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit ef055ea1bbfd17de9eeae11c5f90101361fb02df)
2026-06-11 14:10:21 +01:00
Ben Taylor
8b7fca9ede Add improvement to chacha20 tests
Co-authored-by: minosgalanakis <30719586+minosgalanakis@users.noreply.github.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
(cherry picked from commit 9d6a54795c96f7f0d7dfc230071dc16c5f47f94a)
2026-06-11 14:10:14 +01:00
Manuel Pégourié-Gonnard
9b3d8dc174 rsa: fix constant-time test for decompose_ret()
We were passing input, while only combined_ret is marked as secret...

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-11 12:26:16 +02:00
Manuel Pégourié-Gonnard
29108ed8ce pk: test buffer too small for RSA-opaque + RSA-alt
A previous commit added tests "normal" PK RSA contexts, but missed
opaque RSA keys and RSA_ALT keys.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-11 11:52:18 +02:00
Manuel Pégourié-Gonnard
9516cc4e70 psa: test buffer too small for RSA decrypt
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-11 11:30:45 +02:00
Ben Taylor
f1c9f7fb25 Add reported by and CVE placeholder
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit ab2a7d5a3472f39190344f754e6cee5039fcba50)
2026-06-10 14:35:58 +01:00
Ben Taylor
38a111dd98 Correct style of ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit 0501e447cc19ed06b69daea5e17585e1294030cd)
2026-06-10 14:35:58 +01:00
Ben Taylor
dafd83e310 Improve ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit c058818451833a748da112e3b8129fd299480ceb)
2026-06-10 14:35:58 +01:00
Ben Taylor
7f945f96e8 Add ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit e71e49e634ba49b2b630f268bc8f0dd392751ec3)
2026-06-10 14:35:58 +01:00
Ben Taylor
ec1641e6a0 Add in tests for ECDHE-PSK integer overflow
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit c567299ee6bade9547a97d3ad1dcd5f3bd98ea6f)
2026-06-10 14:35:58 +01:00
Ben Taylor
f9835c081f Added fix for Integer overflow using a large ECDHE Identity
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit baf449db7e31f031ed5def0fecf417122f72d3ee)
2026-06-10 14:34:37 +01:00
Ronald Cron
02edd2b8c2
Merge pull request #1609 from minosgalanakis/security/mlfbyt4c_tls13_policy_bypass_3.6
Backport 3.6: TLS1.3 client HRR policy bypass[ARM-MLFBYT4C]
2026-06-10 13:03:45 +02:00
Manuel Pégourié-Gonnard
d73eec656c psa: test buffer sized just for actual plaintext
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-10 09:57:20 +02:00
Minos Galanakis
8c458b8cca test_suite_ssl: Updated reject_hrr_selecting_unoffered_group dependencies
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-06-08 15:54:41 +01:00
Manuel Pégourié-Gonnard
4813b0c093 pk: fix builds without PKCS#1 v1.5
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-08 12:00:02 +02:00
Manuel Pégourié-Gonnard
c76cfd536e pk: also fix RSA-opaque v1.5 decrypt side channels
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-08 11:56:59 +02:00
Manuel Pégourié-Gonnard
88d55b8140 Add ChangeLog for the latest RSA padding issues
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-08 11:39:44 +02:00
Manuel Pégourié-Gonnard
31ac657745 rsa: move CT tests to .constant_time.data
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-08 11:39:44 +02:00
Manuel Pégourié-Gonnard
7e51c31aef rsa/psa: tune doc about RSA v1.5 decrypt usage
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-08 11:39:44 +02:00
Gilles Peskine
fe47e9ed89 Define and use mbedtls_rsa_decrypt_decompose_ret()
Use a more structured way of isolating and translating sensitive error codes
from RSA PKCS#1v1.5 decryption.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-08 11:39:44 +02:00
Gilles Peskine
a818c0a8dd Changelog entry for badmac_seen_or_in_hsfraglen confusion
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 21:59:07 +02:00
Ronald Cron
b513676bed
Merge pull request #10772 from mpg/security-link-3.6
[3.6] Update broken link
2026-06-05 16:47:25 +00:00
Minos Galanakis
c3f90ec54d test_suite_ssl: use 3.6 endpoint helper signatures in HRR test
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-06-05 15:16:19 +01:00
Gilles Peskine
24c2875cb0 Fix confusion between ssl->badmac_seen and ssl->in_hsfraglen
Since Mbed TLS 3.6.3, the field `badmac_seen_or_in_hsfraglen` in the
`mbedtls_ssl_context` structure has a dual purpose: it is the new name of
`badmac_seen` for DTLS, and it has a new meaning `in_hsfraglen` for TLS.
This was done to add support for handshake message fragmentation in TLS
while preserving the library ABI.

There was a bug in some places in the code, which reads the dual-purpose
field in the wrong protocol. Specifically:

* `mbedtls_ssl_prepare_handshake_record()` (beginning): mistakenly reads
  `badmac_seen_or_in_hsfraglen` in DTLS to mean `in_hsfraglen`. (DTLS
  handshake defragmentation does not use `in_hsfraglen`.) As a
  consequence, in DTLS, after receiving a record with a bad MAC, the field
  `ssl->in_hslen` was not correctly updated, which causes problems further
  in handshake message processing.
* `mbedtls_ssl_prepare_handshake_record()` (end): correctly updates
  `badmac_seen_or_in_hsfraglen` in TLS with the `in_hsfraglen` meaning.
* `ssl_consume_current_message()`: incorrectly read
  `badmac_seen_or_in_hsfraglen` in DTLS to mean `in_hsfraglen`, and thus
  stops processing messages after receiving a record with a bad MAC.
* `ssl_get_next_record()`: accesses `badmac_seen_or_in_hsfraglen` to mean
  `badmac_seen` in DTLS. No bug here.
* `mbedtls_ssl_handle_message_type()`: reads `badmac_seen_or_in_hsfraglen`
   to mean `in_hsfraglen` in TLS. No bug here.
* `mbedtls_ssl_session_reset_msg_layer()`: both fields need to be reset
  when not partial, and a partial reset only applies to DTLS where we do
  want to preserve `badmac_seen` in a partial reset. No bug here.
* `mbedtls_ssl_context_save()`, `mbedtls_ssl_context_load()`: saving
  `badmac_seen` in DTLS is desired and done. Saving `in_hsfraglen` in TLS
  is harmless.

To fix this, in `ssl_msg.c`, always access the dual-purpose field
`badmac_seen_or_in_hsfraglen` through getters and setters that are specific
to one purpose and that check that the purpose matches the protocol.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
397db25dc3 Add tests demonstrating badmac_seen_or_in_hsfraglen confusion on the server
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
305bab2bbc Add renegotiate=2 option to ssl_client2
In `ssl_client2`, the existing option `renegotiate=1` causes the client to
initiate renegotiation immediately after the initial handshake. Add a
variant `renegotiate=2` that initiates renegotiation after one data exchange.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
ee9ce31e96 Add tests demonstrating badmac_seen_or_in_hsfraglen confusion on the client
After a message with a bad MAC (invalid application data record), try to
renegotiate:

* Test cases where renegotiation (nominal or delayed) is rejected.
  Nothing bad happens.
* A test where renegotiation is misparsed and rejected.
  The subsequent parsing fails.
* A test where the renegotiation request is delayed.
  This causes a heap buffer overflow in `ssl_buffer_message()`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
9124556b6d Check "refusing renegotiation" log in more renegotiation tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
0fb05d3520 Add badmac_limit option to ssl_client2
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
a9fa52a025 Add one-shot bad AD options to udp_proxy
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
e8d780f5af Add udp_proxy options to delay an encrypted handshake message
This can be used to simulate data messages received in the wrong epoch, or
to cause a handshake message to be buffered.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
929ce501bd Test DTLS renegotiation when badmac_seen_or_in_hsfraglen != 0
Non-regression test for a bug introduced with TLS handshake defragmentation
support in Mbed TLS 3.6.2, whereby the confusion between the `badmac_seen`
meaning and the `in_hsfraglen` meaning of `ssl->badmac_seen_or_in_hsfraglen`
causes renegotiation to be processed incorrectly after receiving a message
with a bad MAC.

This bug will be fixed in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
ba656e8f9b Add some hooks in mbedtls_test_ssl_perform_handshake()
Let test code customize the kitchen sink function
`mbedtls_test_ssl_perform_handshake()` at a few points.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
2aa80688d9 Add a missing dependency
Needed by a test certificate.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Manuel Pégourié-Gonnard
70d619741b Update broken link
I believe the existing link was to the TF wiki which has been retired
for some time now.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-06-05 12:28:55 +02:00
Ronald Cron
d774a25bfe Remove unnecessary dependency
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-05 12:03:16 +02:00
Gilles Peskine
1aaec34173 Add CVE-ID
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:33:28 +02:00
Gilles Peskine
8c398012dd Add attribution for the second bug
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:33:28 +02:00
Gilles Peskine
8e07717105 basicConstraints with leading INTEGER field: document the behavior change
Announce the security fix together with the overflow fix, since the two bugs
are pretty much indistinguishable from a black-box perspective, despite
being due to independent problems in the code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:33:27 +02:00
Gilles Peskine
f67b8e5bde Stop accepting basicConstraints with only pathLenConstraint
In an X.509 certificate, a basicConstraints extension where the cA
field (BOOLEAN) is omitted but the pathLenConstraint field (INTEGER )is
present is syntactically valid, but RFC 5280 states that CAs MUST NOT emit
such a certificate.

Historically, since XySSL 0.9 in 2008, if a basicConstraints extension
started with an INTEGER field, we interpreted that field as a cA value. This
was a deliberate change:

> Fixed x509_get_ext() to accept some rare certificates (like
> www.openssl.org:443) which have an INTEGER instead of a BOOLEAN for
> Extension::BasicConstraints::cA.

However, 18 years later, this does not seem to be relevant, and the details
seem to have been lost. Furthermore, major implementations follow RFC 5280
and interpret `SEQUENCE { INTEGER n }` with cA being set to its default
value (FALSE) and pathLenConstraint set to `n`. This means that such a
certificate with n != 0 would be interpreted as a CA certificate in Mbed TLS
but as a leaf certificate elsewhere, which is dangerous.

Since CAs are not supposed to emit such certificates, stop accepting them
altogether.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:33:27 +02:00
Gilles Peskine
4fb9c9e439 basicConstraints pathLenConstraint tests: use standard cA type
In test cases for pathLenConstraint parsing in a basicConstraints extension
of an X.509 certificate, use the standard type for the leading cA field,
namely BOOLEAN. The test data was encoding that field as INTEGER, which was
accepted as a deviation from the standard since XySSL 0.9.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 11:33:27 +02:00