Skip to content

Validate minimum TCP header length#53

Merged
gasbytes merged 1 commit intowolfSSL:masterfrom
danielinux:validate_min_tcp
Mar 2, 2026
Merged

Validate minimum TCP header length#53
gasbytes merged 1 commit intowolfSSL:masterfrom
danielinux:validate_min_tcp

Conversation

@danielinux
Copy link
Member

discard malformed TCP packets that are too short.

Found by fenrir/224

Copilot AI review requested due to automatic review settings March 2, 2026 14:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens TCP packet parsing by rejecting segments whose TCP data-offset (header length) indicates a header smaller than the minimum 20 bytes, preventing malformed packets from being processed.

Changes:

  • Add a minimum TCP header-length (data offset) check in tcp_input() to drop malformed segments early.
  • Add a unit test covering the “header length below minimum” drop behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/wolfip.c Adds a minimum TCP header-length validation before computing payload length / processing options.
src/test/unit/unit.c Introduces a regression test ensuring malformed short-header TCP segments are dropped without state changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@gasbytes gasbytes left a comment

Choose a reason for hiding this comment

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

lgtm, checked via gh pr checkout.

@gasbytes gasbytes merged commit 338ec0f into wolfSSL:master Mar 2, 2026
19 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.

3 participants