Skip to content

tlv_dcbx: bounds-check nested TLVs in legacy DCBX decoders - #136

Open
DicksonWu654 wants to merge 1 commit into
intel:masterfrom
DicksonWu654:dcbx-nested-tlv-bounds
Open

DicksonWu654 wants to merge 1 commit into
intel:masterfrom
DicksonWu654:dcbx-nested-tlv-bounds

Conversation

@DicksonWu654

Copy link
Copy Markdown

Follow-up to my email to Aaron and Loren. The legacy DCBX decoders (unpack_dcbx1_tlvs / unpack_dcbx2_tlvs) don't check nested TLV lengths against the outer TLV, so a malformed LLDPDU from a link peer reads past the TLV buffer (ASan heap-buffer-overflow READ of 1, 2 and up to 408 bytes). This adds the missing bounds checks and drops the frame instead.

Testing: a small harness drives one LLDPDU per case through rxProcessFrame with the real rx.c, agent.c, lldp_dcbx.c, tlv_dcbx.c and lldp_tlv.c. Unpatched, ASan reports the over-read; patched, each frame sets badFrame and is discarded. make check passes on the patched tree. I didn't see over-read bytes leave the daemon, so this is a robustness fix.

Disclosure: I found this with LLM-assisted analysis and the patch was LLM-generated. I reran the tests above on current master before opening this.

🤖 Generated with Claude Code

unpack_dcbx1_tlvs and unpack_dcbx2_tlvs walk the nested TLVs inside a
received legacy DCBX TLV without checking the nested header and length
against what is left of the outer TLV, so a short or inconsistent
LLDPDU from a link peer makes them read past the TLV buffer.

Reject the frame when the outer TLV is shorter than OUI plus subtype,
when fewer than 2 bytes remain for a nested header, when a nested
length runs past the outer TLV, and when an application or logical
link TLV is too short to hold its subtype byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant