secdev / secdev/scapy

RFE: long DHCPv4 options (RFC 3396)

Open
#4,642 1 comment 0 reactions 0 assignees View on GitHub

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

Long DHCPv4 options longer than 255 bytes aren't supported out of the box. For example

raw(DHCP(options=[('captive-portal', 'a'*256)]))

fails with

error: While dissecting field 'options': ubyte format requires 0 <= number <= 255

but according to https://www.rfc-editor.org/rfc/rfc3396#section-1 it can be split and then it should be joined on the receiving side

when more than
one option with a given type code appears in the DHCP packet, all
such options should be concatenated together.

Wireshark started concatenating options according to that RFC a couple months ago: https://gitlab.com/wireshark/wireshark/-/merge_requests/18079

https://www.ietf.org/archive/id/draft-tojens-dhcp-option-concat-considerations-00.html was also mentioned there.

(It's possible to do all that manually. It's just something I noticed in the context of suboptions in https://github.com/NetworkConfiguration/dhcpcd/pull/404. It came up again when I took a look at https://github.com/secdev/scapy/pull/4638 and tried to stuff quite a few IP addresses into a reply :-))

Scapy version

7106b015379b621966f00667cf0bf3d4daec0262

Python version

Python 3.13.1

Operating system

Fedora 41

Additional environment information

No response

How to reproduce
raw(DHCP(options=[('captive-portal', 'a'*256)]))

and

DHCP(b'\x06\x02\x01\x02\x06\x02\x03\x04')

should be the same as

DHCP(b'\x06\x04\x01\x02\x03\x04')
Actual result

No response

Expected result

No response

Related resources

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by reproducing the two DHCP examples and read RFC 3396 section 1; done should include splitting oversized options during encoding and concatenating repeated option values during decoding, with the two provided byte sequences producing equivalent packets.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.