RFE: support for the DHCP "option overload" option
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 12.6k
- Forks
- 2.2k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 56
Description
Brief description
The DHCP "option overload" option isn't supported so it's necessary to parse DHCP options stuffed into the "file" and "sname" fields manually.
Scapy version
2b58b51d
Python version
3.12.2
Operating system
Linux 6.7.10-200.fc39.x86_64
Additional environment information
No response
How to reproduce
p = BOOTP(file=b'\xa2\x04\x00\x01\x01\x00\xff')/DHCP(options=[("dhcp-option-overload", 1), 'end'])
tdecode(Ether()/IP()/UDP()/p)
...
Boot file name option overloaded by DHCP
[Expert Info (Note/Protocol): Boot file name option overloaded by DHCP]
[Boot file name option overloaded by DHCP]
[Severity level: Note]
[Group: Protocol]
Magic cookie: DHCP
Option: (52) Option Overload
Length: 1
Option Overload: Boot file name holds options (1)
Boot file name option overload
Option: (162) Unassigned
Length: 4
Value: 00010100
Option: (255) End
Option End: 255
Option: (255) End
Option End: 255
Actual result
>>> BOOTP(raw(p))[DHCP].options
[('dhcp-option-overload', 1), 'end']
>>> BOOTP(raw(p)).file
b'\xa2\x04\x00\x01\x01\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Expected result
I'm not sure what it should look like. One option would be to look for the "option overload" option and if it's present along with the underlying BOOTP layer parse the "file" and "sname" fields and add them to the DHCP options:
>>> BOOTP(raw(p))[DHCP].options
[(162, b'\x00\x01\x01\x00'), ('dhcp-option-overload', 1), 'end']
or it could do something else entirely.
(It's possible to parse the "file" and "sname" fields manually though using something like DHCP(BOOTP(raw(p)).file))
Related resources
According to https://datatracker.ietf.org/doc/html/rfc2132#section-9.3
9.3. Option Overload
This option is used to indicate that the DHCP 'sname' or 'file'
fields are being overloaded by using them to carry DHCP options. A
DHCP server inserts this option if the returned parameters will
exceed the usual space allotted for options.
If this option is present, the client interprets the specified
additional fields after it concludes interpretation of the standard
option fields.
The code for this option is 52, and its length is 1. Legal values
for this option are:
Value Meaning
----- --------
1 the 'file' field is used to hold options
2 the 'sname' field is used to hold options
3 both fields are used to hold options
Admittedly it's an obscure feature but it comes up from time to time when it's necessary to extract all the options generated by, say, fuzzers to try to figure out what exactly they've generated or whether certain options are present. As far as I can remember an option that crashed the dhcp client in https://github.com/systemd/systemd/pull/30952#issuecomment-2027948367 was buried in the "file" field initially and it took me a while to turn it into something I can digest :-)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the BOOTP/DHCP example and read RFC 2132 section 9.3 alongside the DHCP option parsing entry points exercised by BOOTP(raw(p)). Compare handling for option-overload values 1, 2, and 3. Done should define and test how options from the file and sname fields are incorporated into the parsed DHCP options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100