Skip to content

TLS Extensions: add record_size_limit (RFC 8449) - #12258

Open
SparkiDev wants to merge 1 commit into
wolfSSL:masterfrom
SparkiDev:tls-ext-record-size-limit
Open

SparkiDev wants to merge 1 commit into
wolfSSL:masterfrom
SparkiDev:tls-ext-record-size-limit

Conversation

@SparkiDev

Copy link
Copy Markdown
Contributor

Description

Add the record_size_limit extension for TLS 1.3 and TLS 1.2, enabled with --enable-recordsizelimit (CMake WOLFSSL_RECORDSIZELIMIT, macro HAVE_RECORD_SIZE_LIMIT) and by --enable-all and --enable-tlsx.

  • wolfSSL_UseRecordSizeLimit() / wolfSSL_CTX_UseRecordSizeLimit() set the largest record payload this end accepts (64 to 16384, 0 to not advertise). A limit of 16384 is advertised by default.
  • The client offers it in the ClientHello; the server answers in EncryptedExtensions under TLS 1.3 and in the ServerHello under TLS 1.2. The TLS 1.3 wire value includes the content type byte.
  • Records sent are capped to the peer's limit once encryption is on; received records over our advertised limit are refused with record_overflow, checked on the ciphertext length and again on the decrypted plaintext. Early data a server receives is exempt.
  • RFC 8449 Sect. 5: a server ignores max_fragment_length when both are in a ClientHello, and a client aborts if a server sends both. The built-in default stands aside when the application asked for max_fragment_length.
  • EncryptedExtensions, CertificateRequest and NewSessionTicket are fragmented across records when the peer's limit is smaller than the message. SendTls13Certificate() refuses a limit too small for the message's fixed header rather than writing past the fragment.
  • Record compression and a record size limit refuse each other on one connection, and compression is refused once the default limit has been advertised or received.
  • The limit is copied to a write-dup object and peer state is reset by wolfSSL_clear().
  • An application custom extension cannot be registered for type 28 when the extension is built in.

Crypto-only builds turn the option off, in configure and CMake alike.

test_dtls_frag_ch's MTU is raised as the ClientHello grows by 6 bytes.

Testing

./configure --enable-recordsizelimit --enable-earlydata --enable-session-ticket
./configure --enable-recordsizelimit --disable-tls13
./configure --enable-recordsizelimit --enable-maxfragment
./configure --enable-recordsizelimit --enable-postauth
./configure --enable-recordsizelimit --with-libz
./configure --enable-recordsizelimit --enable-dtls --enable-dtls13
./configure --enable-recordsizelimit --enable-dtls --enable-dtls13 --enable-dtls-frag-ch

@SparkiDev SparkiDev self-assigned this Nov 25, 2026
Copilot AI balanced review requested due to automatic review settings November 25, 2026 00:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical TLS 1.3 enforcement gaps allow oversized authenticated handshake records to bypass record-size limits during 0-RTT rejection and EncryptedExtensions processing.

5 open issues
What changed in this PR

Adds RFC 8449 record_size_limit support to wolfSSL’s TLS extension and record-processing layers for TLS 1.2 and TLS 1.3.

Changes:

  • Adds build options, public configuration APIs, and extension negotiation.
  • Enforces record limits and adds handshake fragmentation, compression compatibility checks, and connection-state handling.
  • Adds API documentation, regression tests, and Linux CI configurations.
File Description
wolfssl/​ssl.h Declares record-limit APIs and constants.
wolfssl/​internal.h Adds extension identifiers and connection state.
tests/​api/​test_tls13.h Registers new record-limit tests.
tests/​api/​test_tls13.c Tests negotiation, overflow, fragmentation, and early data.
tests/​api/​test_tls.h Registers the TLS 1.2 negotiation test.
tests/​api/​test_tls.c Tests TLS 1.2 limits and context inheritance.
tests/​api/​test_tls_ext.c Tests rejection of conflicting custom extensions.
tests/​api/​test_dtls13.c Increases test MTU for the larger ClientHello.
tests/​api/​test_compress.h Registers compression compatibility coverage.
tests/​api/​test_compress.c Tests compression and record-limit conflicts.
src/​tls13.c Adds handshake fragmentation and certificate-header bounds checks.
src/​tls.c Implements extension encoding, parsing, and negotiation rules.
src/​ssl.c Handles compression conflicts, duplication, and state reset.
src/​ssl_api_ext.c Implements connection and context setters.
src/​internal.c Initializes limits and enforces record-size bounds.
doc/​dox_comments/​header_files/​ssl.h Documents APIs and feature interactions.
configure.ac Adds the Autotools option and feature defines.
CMakeLists.txt Adds CMake configuration and crypto-only handling.
cmake/​options.h.in Exposes the feature macro in generated options.
.github/​configs/​os-check-linux.json Adds focused Linux CI configurations.

Review effort: Balanced

Comment thread src/internal.c Resolved
Comment thread src/internal.c Resolved
Comment thread configure.ac Resolved
Comment thread src/internal.c Resolved
Comment thread tests/api/test_tls13.c Resolved
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

gcc-arm-cortex-m4-dtls13

  • FLASH: .text +64 B (+0.0%, 199,268 B / 1,048,576 B, total: 19% used)

gcc-arm-cortex-m4-openssl-compat

  • FLASH: .text +64 B (+0.0%, 803,224 B / 1,048,576 B, total: 77% used)

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,816 B (+4.9%, 296,396 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread wolfssl/internal.h Resolved
Comment thread src/internal.c Resolved
Comment thread src/tls.c Resolved
Comment thread src/tls.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The CBC probe miscalculates the ciphertext boundary and fails in the AES-CBC/SHA-1 configuration without encrypt-then-MAC, while CertificateRequest fragmentation can cause quadratic buffer copying.

2 open issues
4 resolved since last review

Review effort: Balanced

Comment thread src/tls13.c Resolved
Comment thread tests/api/test_tls13.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical issues remain: imported objects can bypass receive-size enforcement and accept oversized TLS 1.3 records, while enabling record-size limits with TLS disabled and compression enabled can cause consumer link failures.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread CMakeLists.txt Resolved
Comment thread src/internal.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

With WOLFSSL_OLD_UNSUPPORTED_EXTENSION enabled, TLS 1.3 clients incorrectly accept an unsolicited record_size_limit extension instead of aborting with unsupported_extension, and the test must expect rejection.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/tls.c Resolved
Add the record_size_limit extension for TLS 1.3 and TLS 1.2, enabled with
--enable-recordsizelimit (CMake WOLFSSL_RECORDSIZELIMIT, macro
HAVE_RECORD_SIZE_LIMIT) and by --enable-all and --enable-tlsx.

- wolfSSL_UseRecordSizeLimit() / wolfSSL_CTX_UseRecordSizeLimit() set the
  largest record payload this end accepts (64 to 16384, 0 to not
  advertise). A limit of 16384 is advertised by default.
- The client offers it in the ClientHello; the server answers in
  EncryptedExtensions under TLS 1.3 and in the ServerHello under TLS 1.2.
  The TLS 1.3 wire value includes the content type byte.
- Records sent are capped to the peer's limit once encryption is on;
  received records over our advertised limit are refused with
  record_overflow, checked on the ciphertext length and again on the
  decrypted plaintext. Early data a server receives is exempt.
- RFC 8449 Sect. 5: a server ignores max_fragment_length when both are in a
  ClientHello, and a client aborts if a server sends both. The built-in
  default stands aside when the application asked for max_fragment_length.
- EncryptedExtensions, CertificateRequest and NewSessionTicket are
  fragmented across records when the peer's limit is smaller than the
  message. SendTls13Certificate() refuses a limit too small for the
  message's fixed header rather than writing past the fragment.
- Record compression and a record size limit refuse each other on one
  connection, and compression is refused once the default limit has been
  advertised or received.
- The limit is copied to a write-dup object and peer state is reset by
  wolfSSL_clear(). Session export, whose format does not carry the limits,
  is refused for a connection that negotiated one below the maximum.
- An application custom extension cannot be registered for type 28 when
  the extension is built in.

Crypto-only and no-TLS builds turn the option off, in configure and CMake
alike, overriding an explicit --enable-recordsizelimit or
-DWOLFSSL_RECORDSIZELIMIT=yes (configure warns). ChangeLog.md records the
feature and that --enable-all and --enable-tlsx now advertise it.

test_dtls_frag_ch's MTU is raised as the ClientHello grows by 6 bytes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive TLS/DTLS record enforcement and handshake fragmentation changes require specialist review, with interoperability and retry behavior unvalidated and DTLS 1.3 ACK and TLS 1.2 renegotiation enforcement gaps explicitly deferred.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@SparkiDev SparkiDev assigned wolfSSL-Bot and unassigned SparkiDev Nov 26, 2026
@philljj
philljj requested a review from Frauschi November 26, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants