Skip to content

sys/net/dhcpv6: reject truncated option headers - #23018

Merged
miri64 merged 1 commit into
RIOT-OS:masterfrom
AnnsAnns:dhcpv6-reject-truncated-option-headers
Oct 29, 2026
Merged

miri64 merged 1 commit into
RIOT-OS:masterfrom
AnnsAnns:dhcpv6-reject-truncated-option-headers

Conversation

@AnnsAnns

@AnnsAnns AnnsAnns commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Contribution description

The DHCPv6 option walker reads a four byte option header without checking that four bytes remain. A message with one to three trailing bytes after its last complete option makes the parser read past the end of the message.

The real recv_buf is 256 bytes and is followed by best_adv, so the read lands in valid static memory on normal builds. It reads one or two bytes only, and the values are used for parsing, never sent back to the attacker. There is no write, no code execution, and no reliable crash.

Testing procedure

Issues/PRs references

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:

  • DeepSeek v4.1 Flash 1017 for assessing the report

Assisted-by: DeepSeek v4.1 Flash 1017
@AnnsAnns
AnnsAnns requested a review from miri64 as a code owner October 28, 2026 15:18
@github-actions github-actions Bot added Area: network Area: Networking Area: sys Area: System labels Oct 28, 2026
@AnnsAnns AnnsAnns added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR AI: Co-Authored PR/Issue relies on AI. Documentation / Code was partly generated by AI. labels Oct 28, 2026
@crasbe crasbe added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Oct 28, 2026
@riot-ci

riot-ci commented Oct 28, 2026

Copy link
Copy Markdown

Murdock results

✔️ PASSED

d493a4c sys/net/dhcpv6: reject truncated option headers

Success Failures Total Runtime
14013 0 14013 09m:09s

Artifacts

@miri64 miri64 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor clean-up request.

for (dhcpv6_opt_t *opt = (dhcpv6_opt_t *)(&rep[sizeof(dhcpv6_msg_t)]);
len > 0; len -= _opt_len(opt), opt = _opt_next(opt)) {
if (len < sizeof(dhcpv6_opt_t)) {
DEBUG("DHCPv6 client: REPLY options truncated\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug statement in the if branch below says "ADVERTISE". Could you maybe piggy-back a fix for that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oop, i can do a followup maybe?

@miri64 miri64 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short round of confusion I had, that others might have later: While the length field of the option header does not include the header itself, the result of _opt_len(opt) (which is used here) does.

@miri64 miri64 added the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Oct 29, 2026
@miri64
miri64 enabled auto-merge October 29, 2026 10:01
@miri64
miri64 added this pull request to the merge queue Oct 29, 2026
@miri64 miri64 added this to the Release 2026.10 milestone Oct 29, 2026
Merged via the queue into RIOT-OS:master with commit 8fa4bbd Oct 29, 2026
35 checks passed
@mguetschow

Copy link
Copy Markdown
Contributor

Backport provided in #23034

@miri64 miri64 removed the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Co-Authored PR/Issue relies on AI. Documentation / Code was partly generated by AI. Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants