Skip to content

bgp: dissect every community in a COMMUNITIES attribute - #5253

Open
atg06 wants to merge 1 commit into
secdev:masterfrom
atg06:bgp-dissect-multiple-communities
Open

atg06 wants to merge 1 commit into
secdev:masterfrom
atg06:bgp-dissect-multiple-communities

Conversation

@atg06

@atg06 atg06 commented Oct 25, 2026

Copy link
Copy Markdown

Description

The COMMUNITIES path attribute (RFC 1997) is a list of 4-byte values, but BGPPACommunity only dissects the first one, and the others end up as Raw:

>>> BGPPathAttr(b'\xc0\x08\x08\xfc\x00\x00\x0b\xfc\x00\x00\x15').attribute
<BGPPACommunity  community=4227858443 |<Raw  load=b'\xfc\x00\x00\x15' |>>

This PR sets default_payload_class so the remaining values are dissected as more BGPPACommunity layers. The community field and building are unchanged. A FieldListField like in BGPPAClusterList would also work, but it would rename the public community field.

The first point of the issue (values outside well_known_communities) already works, e.g. BGPPACommunity(community=0xFC00000B).

Fixes #4071

This message was written with the help of AI (Claude Opus 5.5). I checked the change and the tests myself.

The COMMUNITIES path attribute (RFC 1997) holds a list of 4-byte
values, but BGPPACommunity only dissected the first one and left the
others as Raw. Chain the remaining communities as BGPPACommunity
layers.

Fixes secdev#4071

AI-Assisted: yes (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread scapy/contrib/bgp.py

def default_payload_class(self, payload):
# The attribute value is a list of 4-byte communities
return BGPPACommunity

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.

Could you use a bind_layers instead? Thanks

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.

BGP layer, unable to specify non well-known community via BGPPACommunity

2 participants