Repository navigation
Raise dpkt error instead of IndexError on truncated SSL2 and BGP EVPN records - #683
Closed
eeshsaxena wants to merge 1 commit into
Closed
eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
SSL2.unpack read self.data[0] for the padding length in the 3-byte header form, and RouteEVPN.unpack read buf[0] for the MAC/IP address length. A truncated record left those buffers empty, so parsing raised a raw IndexError instead of dpkt.NeedData like the other truncated-packet paths. Guard each read and raise NeedData. Add regression tests.
Author
|
Closing this to clear out my older open PRs. Nothing wrong with the change on my side, I am just tidying up a backlog. If it is still useful to you, say so and I will reopen it and rebase it on current main. |
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.
Two more truncated-packet paths (same class as #682) that leak a raw
IndexErrorinstead of adpkterror.SSL2
SSL2.unpackreads the padding-length byte in the 3-byte header form withcompat_ord(self.data[0]). A record that stops after the 2-byte length field leavesself.dataempty:BGP EVPN
RouteEVPN.unpackreads the MAC and IP address length bytes withcompat_ord(buf[0])without checking the buffer:Fix
Guard each read and raise
dpkt.NeedData, consistent with the other truncated-packet handling in these modules.Tests
Added
test_ssl2_truncated_padding_length(ssl.py) andtest_route_evpn_truncated(bgp.py), covering the SSL2 padding byte and both the MAC (type 2) and IP (type != 1) length reads. They fail withIndexErrorbefore this change and pass after.ssl.pyandbgp.pytests pass (62).