face: validate NDNLPv2 fragmentation fields before reassembly - #216
Open
Harsh23Kashyap wants to merge 1 commit into
Open
Harsh23Kashyap wants to merge 1 commit into
Harsh23Kashyap wants to merge 1 commit into
Conversation
A single incoming NDNLPv2 frame carries attacker-controlled FragCount and FragIndex values that were trusted before allocation: - reassemble() sized its buffer with make(enc.Wire, fragCount), so one small fragment with a huge FragCount forces a proportional memory allocation (e.g. FragCount=1<<40 would exhaust memory). - handleIncomingFrame computed baseSequence = Sequence - FragIndex before validation, underflowing to a huge sequence number when FragIndex > Sequence and polluting a reassembly slot. Reject frames with FragCount == 0, FragCount above the maximum possible for a legal packet (MaxNDNPacketSize, since every fragment carries at least one byte), FragIndex >= FragCount, or FragIndex > Sequence before any reassembly state is allocated. The ring buffer introduced in named-data#96 bounds the number of concurrent reassemblies but not their size.
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.
Fixes #215
What
FragCount == 0,FragCount > MaxNDNPacketSize,FragIndex >= FragCount,FragIndex > Sequence) inhandleIncomingFramebeforebaseSequenceis computed, and re-check the bounds inreassemblebefore allocating.FragCountno longer allocates;FragIndex > Sequenceno longer underflows or allocates; a normal 2-fragment packet still reassembles and frees its buffer.Evidence
Before (on main):
After (this branch):
Full
go test ./...green.