Skip to content

print-bgp: account for TLV header bytes in L2VPN tlen tracking#1444

Open
TristanInSec wants to merge 1 commit into
the-tcpdump-group:masterfrom
TristanInSec:fix/bgp-l2vpn-tlen-accounting
Open

print-bgp: account for TLV header bytes in L2VPN tlen tracking#1444
TristanInSec wants to merge 1 commit into
the-tcpdump-group:masterfrom
TristanInSec:fix/bgp-l2vpn-tlen-accounting

Conversation

@TristanInSec

Copy link
Copy Markdown

print_labeled_vpn_l2() reads a 3-byte TLV header (1-byte type +
2-byte length) per iteration and advances pptr by 3, but does not
subtract the header bytes from tlen. Only the data portion is
subtracted via tlen -= ttlv_len (default case) or tlen-- per byte
(case 1).

After N TLVs, tlen is 3*N bytes too high, causing the
while (tlen != 0) loop to continue past the L2VPN attribute
boundary and interpret adjacent BGP path attribute data as TLV
structures.

Fix by subtracting the 3-byte TLV header from tlen immediately
after reading it.

Found by manual audit of commit 9ec6904.

print_labeled_vpn_l2() reads a 3-byte TLV header (1-byte type +
2-byte length) per iteration and advances pptr by 3 bytes, but does
not subtract the header bytes from tlen. Only the data portion
(ttlv_len) is subtracted via tlen -= ttlv_len (default case) or
tlen-- per byte (case 1).

After N TLVs, tlen is 3*N bytes too high, so the while (tlen != 0)
loop continues past the L2VPN attribute boundary, interpreting
adjacent BGP path attribute data as TLV structures.

Fix by subtracting the 3-byte header from tlen immediately after
reading it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant