Skip to content

sniffer: fix reading past end of very short packet buffers - #12195

Merged
JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:zd-12171
Nov 20, 2026
Merged

JacobBarthelmeh merged 1 commit into
wolfSSL:masterfrom
holtrop-wolfssl:zd-12171

Conversation

@holtrop-wolfssl

@holtrop-wolfssl holtrop-wolfssl commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

sniffer: fix reading past end of very short packet buffers

Fixes #12171

Testing

Had Claude reproduce and verify the fix:

How I checked it: I built with ./configure --enable-sniffer --enable-debug plus ASan, then made a test capture from scripts/sniffer-static-rsa.pcap. The capture adds a 2-byte client segment with a sequence gap, so it gets buffered, and drops the client's 69-byte app-data packet. The server's next ACK then puts the sniffer into recovery, which calls FindNextRecordInAssembly().
- Without the fix: ASan reports heap-buffer-overflow ... 0 bytes after 2-byte region in FindNextRecordInAssembly, with the same stack as the report.
- With the fix: the same capture runs clean under ASan.
- scripts/sniffer-testsuite.test passes on the ASan build with no sanitizer reports.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@holtrop-wolfssl holtrop-wolfssl self-assigned this Nov 19, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 21:13

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 automated suite lacks AddressSanitizer regression tests for one- and two-byte TLS-prefix fragments followed by a valid record to verify bounds safety and continued recovery.

1 open issue
What changed in this PR

This PR fixes an out-of-bounds read in the sniffer’s TLS recovery path when processing very short buffered packets.

Changes:

  • Checks that a reassembly buffer contains at least three bytes before comparing the TLS record type and protocol version.
File Description
src/​sniffer.c Adds a length guard in FindNextRecordInAssembly() before reading the TLS prefix.

Review effort: Balanced

Comment thread src/sniffer.c Resolved
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,496 B (+4.8%, 296,076 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.

@JacobBarthelmeh
JacobBarthelmeh merged commit 11e7979 into wolfSSL:master Nov 20, 2026
437 checks passed
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.

sniffer: FindNextRecordInAssembly() reads 3 bytes from a 1- or 2-byte reassembly buffer

4 participants