Repository navigation
Reject PDUs whose length is shorter than their fixed fields - #75
Merged
stewartadam merged 2 commits intoNov 12, 2026
Merged
Conversation
A root layer, data packet framing layer or DMP layer whose length field was smaller than the fixed fields of that layer caused an out-of-bounds slice and a panic while parsing. Any host on the network could crash a receiver with a single malformed datagram. Each of these layers now returns PduInvalidLength when its length can't hold its own header, as E1.31 requires malformed packets to be discarded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KzaQVQThQpmqhvLapk99Vs
The existing DMP layer tests expect ParseInsufficientData when the PDU length is too low, so keep that error type for the new header check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KzaQVQThQpmqhvLapk99Vs
stewartadam
deleted the
claude/project-thread-njq8b9-1-parse-short-pdu
branch
November 12, 2026 09:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AcnRootLayerProtocol::parsepanicked on packets whose PDU length field was shorter than that layer's fixed header. The panic was an out-of-bounds slice in the root layer (CID), the data packet framing layer, and the DMP layer. Because the receiver parses every datagram it gets, any host on the network could crash a receiver with a single packet. E1.31-2016 requires malformed packets to be discarded.Each layer now checks its length against its own header size before slicing:
PduInvalidLengthPduInvalidLengthParseInsufficientData, matching the existing tests for this layerThe sync and discovery layers already had these checks.
Tests
tests/malformed_length_tests.rshas one regression test per crash, plus a sweep that sets every 12-bit length value on each of the three length fields of a valid packet. All four tests panic onmainand pass on this branch.cargo testandcargo clippyboth pass. Clippy reports no new warnings.