-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DHCP option 121: Classless Static Routes with regression test #3536
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3536 +/- ##
==========================================
+ Coverage 86.01% 86.18% +0.16%
==========================================
Files 285 285
Lines 64983 65017 +34
==========================================
+ Hits 55896 56033 +137
+ Misses 9087 8984 -103
|
I have a version that removes |
Hi, thanks for PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi ! Thanks for the PR. A small comment
scapy/layers/dhcp.py
Outdated
|
||
route = self.m2i(pkt, s[:route_len]) | ||
ret.append(route) | ||
s = s[route_len:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will get into an infinite loop if route_len
is 0. This is CVE material 😠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't route_len
always be minimum 5 since it is 5 + the calculated octets from prefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's possibility to forge packet with broken route_len (one of purposes of using Scapy-forge even invalid packets), then it will become 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initializing to 5 every iteration should prevent any potential weirdness that could result in a zero length. Now it starts at 5 and will increase up to 9.
Added type hints in same style as seen in |
Added warning for invalid prefix values:
|
Thanks for this PR. To ease the review, could you start by correcting the linting errors https://github.com/secdev/scapy/runs/5558414953?check_suite_focus=true#step:5:1 ? |
7928eba
to
af85243
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased & slightly cleaned up the field.
Description
This PR adds functionality to provide support for DHCP option 121 Classless Static Routes as defined in rfc3442. I ran into situation that required manipulating this DHCP option and found converting raw binary was tiresome for packets with many routes, so this creates a simpler human usable design.
This is done by using a FieldListField, and since rfc3442 defines routes as dynamic length I added a little work to be done to calculate correct number of octets for each route based on prefix. The formatting of the raw bytes is exact to the RFC definition. Also this has been tested in both python2.7 and python3.
Usage
Regression Test Results