Repository navigation
Conversation
When decoding IPv4 and IPv6 packets, trailing bytes in the underlying buffer beyond the packet's declared total length could be included in the subprotocol slice. In cases where the buffer was larger than the IP packet (e.g. Ethernet frame padding or fixed-size receive buffers), fields and ports could be decoded from bytes outside the IP datagram. Additionally: - Reject IPv4 packets with an invalid IHL (< 5 / 20 bytes), which could otherwise leave subofs pointing inside the IPv4 header. - Clamp sub to q.length in both decode4 and decode6. - Validate that the IPv6 fragment extension header fits within q.length rather than len(b). - Ensure TCP data offset is at least tcpHeaderLength and fits within the packet. - Bound Parsed.Transport() to p.length to avoid leaking trailing buffer bytes, mirroring Parsed.Payload(). - In GenerateICMPHostUnreachable, use invoking.subofs directly for the IPv4 header length. Updates #cleanup Change-Id: I598018faebf5f8d6884e19753186176ff363732c Signed-off-by: Kailasnath T <[email protected]>
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.
When decoding IPv4 and IPv6 packets, trailing bytes in the underlying buffer beyond the packet's declared total length could be included in the subprotocol slice. In cases where the buffer was larger than the IP packet (e.g. Ethernet frame padding or fixed-size receive buffers), fields and ports could be decoded from bytes outside the IP datagram.
This change:
subtoq.lengthin bothdecode4anddecode6.q.lengthrather thanlen(b).tcpHeaderLengthand fits within the packet.Parsed.Transport()top.lengthto avoid leaking trailing buffer bytes, mirroringParsed.Payload().invoking.subofsdirectly for the IPv4 header length inGenerateICMPHostUnreachable.Updates #cleanup