Skip to content

netutils/dhcpd: prevent out-of-bounds DHCP option read - #3897

Merged
acassis merged 1 commit into
apache:masterfrom
anchao:26102201
Oct 23, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
anchao:26102201

Conversation

@anchao

@anchao anchao commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix an out-of-bounds read in the DHCP server option parser.

dhcpd_parseoptions() parsed each non-PAD/non-END DHCP option by reading the
option length byte before verifying that at least two bytes remained in the
current options field. A malformed packet ending with a single non-PAD option
byte could therefore read one byte past the end of the current DHCP options
field.

Fix

This patch hardens DHCP option parsing by:

  • checking that non-PAD/non-END options have a complete two-byte option header
    before reading the length byte;
  • rejecting options whose declared length extends beyond the current field;
  • allowing options that exactly consume the remaining field bytes;
  • avoiding stale option-length advancement when switching to overloaded
    file / sname option fields.

Impact

This prevents malformed DHCP client requests from causing out-of-bounds reads
during DHCP server option parsing.

Testing

sim/usbdev

dhcpd_parseoptions() read the option length byte for every non-PAD/non-END
option without first checking that two bytes remained in the current options
field.  A malformed packet ending with a single non-PAD option byte could
therefore read one byte past the end of the options array.

Check that the option header is present before reading the length byte, and
reject options whose declared length extends beyond the current field.  Also
allow options that exactly consume the remaining field bytes, and avoid using
a stale option length when switching to overloaded file/sname option fields.

This prevents malformed DHCP client requests from causing out-of-bounds reads
during DHCP server option parsing.
@acassis
acassis merged commit edf07e4 into apache:master Oct 23, 2026
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants