-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The constant lives at the call site. The parser does not know it.\n\n`as_path_match()` is the BIRD filter language's implementation of the AS path mask operator. When an operator writes a filter line like `bgp_path ~ [= 65000 =]` and a BGP UPDATE arrives carrying an AS_PATH attribute, the interpreter dispatches to this function:\n\n```c\nint\nas_path_match(const struct adata *path, const struct f_path_mask *mask)\n{\n struct pm_pos pos[2048 + 1];\n int plen = parse_path(path, pos);\n int l, h, i, nh, nl, last, loop;\n u32 val = 0;\n u32 val2 = 0;\n\n /* l and h are bound of interval of positions where\n are marked states */\n\n pos[plen].set = 0;\n pos[plen].mark = 0;\n```\n\nThe matcher is a nondeterministic finite state machine. Each `pm_pos` entry holds one position in the expanded AS path; the algorithm walks the input mask, marking which positions remain valid. The `+1` is a sentinel for the auxiliary position after the last real ASN. The author of this function wrote twenty lines of comment defending the NFSM design and zero lines defending the array length.\n\nThe expansion is delegated:\n\n```c\nstatic int\nparse_path(const struct adata *path, struct pm_pos *pp)\n{\n const byte *pos = path->data;\n const byte *end = pos + path->length;\n struct pm_pos *op = pp;\n uint i;\n\n while (pos < end)\n {\n uint type = pos[0];\n uint len = pos[1];\n pos += 2;\n\n switch (type)\n {\n case AS_PATH_SET:\n case AS_PATH_CONFED_SET:\n pp->set = 1;\n pp->mark = 0;\n pp->val.sp = pos - 1;\n pp++;\n\n pos += BS * len;\n break;\n\n case AS_PATH_SEQUENCE:\n case AS_PATH_CONFED_SEQUENCE:\n for (i = 0; i < len; i++)\n {\n pp->set = 0;\n pp->mark = 0;\n pp->val.asn = get_as(pos);\n pp++;\n\n pos += BS;\n }\n break;\n```\n\n`parse_path()` takes the destination as `struct pm_pos *pp`. No count. No end pointer. No bound of any kind. The number of iterations through the inner loop is `len`, read directly from the wire at `pos[1]`. The number of segments through the outer loop is whatever fits in `path->length`, also from the wire. The destination's capacity is encoded in the caller's stack frame on line 906. The parser does not know about the caller's stack frame. The parser was not asked.\n\nThe bug is the asymmetry. The bound on the destination is a compile-time constant in `as_path_match`. The bound on the source is a runtime length the BGP peer chose. The function that decides how many entries get written is not the function that decided how many entries fit.\n\n## RFC 8654 took the cap off. The array did not move.\n\n`git log -L 906,906:nest/a-path.c` returns one commit. `c8a6b9a3`, 2009-04-17, \"Rewrite of buggy AS path matching,\" authored by Ondrej Zajicek. The line `struct pm_pos pos[2048 + 1];` was introduced that day and has not been touched since.\n\nIn April 2009, the BGP base specification (RFC 4271) capped a single BGP message at 4096 octets, total, including the 19-byte header. Subtract the path attribute headers and the NLRI and the AS_PATH attribute had room for, generously, a thousand four-byte ASNs. The number 2048 was a comfortable margin above what the wire could deliver. The closed-network assumption did not need to be a check because the framing did the check.\n\nRFC 8654 was published in October 2019. It raised the BGP message cap to 65535 octets when both peers advertise the Extended Messages capability during OPEN. At 65535 octets, an AS_PATH attribute fits roughly sixteen thousand four-byte ASNs. Comfortably above 2048.\n\nThe PoC's capability negotiation is three options:\n\n```python\ncap_mp = b'\\x01\\x04\\x00\\x01\\x00\\x01' # IPv4 Unicast\ncap_as4 = b'\\x41\\x04\\x00\\x00\\xfd\\xe8' # 4-byte ASN\ncap_ext = b'\\x06\\x00' # Extended Message support, RFC 8654\n```\n\nOnly the third capability matters for the overflow. Without it, the BGP framing layer would truncate the attacker's message before parsing began. With it, the attacker can ship a path attribute that the framing layer happily accepts and `parse_path()` happily expands.\n\nThe malicious UPDATE carries nine AS_SEQUENCE segments, each carrying 255 ASNs of `0x41414141`:\n\n```python\nas_segment = b'\\x02\\xff' + (struct.pack('!I', 0x41414141) * 255)\nas_path_data = as_segment * 9 # 2295 ASNs total\n```\n\nNine times 255 is 2295. The stack array holds 2049. `parse_path()` runs the SEQUENCE branch nine times, writing 255 entries each time, and walks 246 entries past the end of the buffer. Then `as_path_match()` returns from `parse_path()` and immediately writes the sentinel:\n\n```c\n int plen = parse_path(path, pos);\n ...\n pos[plen].set = 0;\n pos[plen].mark = 0;\n```\n\n`plen` is now 2295. `pos[2295]` is hundreds of bytes past the end of the stack frame. ASan caught the sentinel write at line 915 because the sentinel is the first write the function makes after returning from the parser; the actual overflow began halfway through the second-to-last segment. The advisory's boundary table records the cutover:\n\n```text\nAS_PATH with 2048 ASNs: no crash\nAS_PATH with 2049 ASNs: stack-buffer-overflow\nAS_PATH with 2050 ASNs: out-of-bounds write during parse_path expansion\n```\n\nThe vulnerable function is reached only when the operator's filter evaluates a path mask. `bgp_path ~ [= ... =]` is the canonical example. Operators who run BIRD as a route reflector, a route server, or a backbone forwarder routinely write such filters, because path masks are how you express policy in BGP. The PoC reaches the function the same way: connect as a peer, negotiate, send UPDATE, let the filter pipeline call into `as_path_match()`.\n\nCVSS gave this CVE 6.3 with `AC:H` for the operator-filter precondition and `PR:L` because you have to be a configured BGP peer. The \"high attack complexity\" rating describes the filter-configuration requirement. It does not describe the network position; \"configured BGP peer\" is the trust position route-server operators grant by the hundreds.\n\n## The mitigation CZ.NIC expects is the one BIRD lets you write halfway.\n\nThe vendor's coordination note in the advisory reads: \"The vendor response indicated that there was no fixed timeline for a source-level fix and that they may release a general public advisory reminding operators to reject routes with unusually long attributes.\"\n\nThe NOTE field on the CVE record itself reads: \"reportedly, the Supplier's position is that a fix is not being prioritized because all network operators should already be rejecting routes with unusually long attributes.\"\n\nThe natural way for a BIRD operator to enforce that mitigation is a filter expression against `bgp_path.len`. The filter language's `bgp_path.len` is computed by `as_path_getlen()`, six hundred lines above the bug in the same file:\n\n```c\nint\nas_path_getlen(const struct adata *path)\n{\n const byte *pos = path->data;\n const byte *end = pos + path->length;\n uint res = 0;\n\n while (pos < end)\n {\n uint t = pos[0];\n uint l = pos[1];\n uint n = 0;\n\n switch (t)\n {\n case AS_PATH_SET: n = 1; break;\n case AS_PATH_SEQUENCE: n = l; break;\n case AS_PATH_CONFED_SEQUENCE: n = 0; break;\n case AS_PATH_CONFED_SET: n = 0; break;\n default: bug(\"as_path_getlen: Invalid path segment\");\n }\n\n res += n;\n pos += 2 + BS * l;\n }\n\n return res;\n}\n```\n\nConfederation segments do not contribute to `bgp_path.len`. They do contribute to `parse_path()`. The `AS_PATH_CONFED_SEQUENCE` case in `parse_path()` falls through into the same loop as `AS_PATH_SEQUENCE`, writing one `pm_pos` entry per expanded ASN. Two functions in the same file disagree about what counts as length: the one the operator queries returns zero for confederation entries, the one the matcher uses to size its work writes one entry for each.\n\nThe researcher's confederation-path table records the result:\n\n```text\nasns=2049 segment=confed_sequence bgp_path_len=0 -> stack-buffer-overflow\nasns=2050 segment=confed_sequence bgp_path_len=0 -> out-of-bounds write\n```\n\nA confederation AS_PATH with 2049 entries crashes the daemon while reading as length zero to the filter language. An operator who follows the vendor's advisory and adds `bgp_path.len > 2048` to their import filter catches the AS_SEQUENCE variant of the bug and misses the AS_CONFED_SEQUENCE variant entirely. The mitigation CZ.NIC told MITRE was already in place does not cover the crash they declined to fix.\n\nThe advisory acknowledges this. The advisory is the researcher's, not the vendor's. CZ.NIC's reply to MITRE does not mention confederations.\n\n## The 2048 is a closed-network assumption. CZ.NIC wrote it down.\n\nThis is the [Closed Network Assumed](/patterns/closed-network-assumed) pattern. A parser written for a \"trusted\" bus accepts framing fields as if the protocol's valid-range constraints were guaranteed by the medium. Sequence numbers, length fields, and indices arrive without bounds checks because the developer's threat model excludes adversaries on the wire. When the bus admits a malformed frame, the protocol-derived constant becomes the size of the overflow.\n\nBIRD is not OP-TEE J1939 reading sequence numbers off a CAN frame, and it is not Tasmota reading MJPEG length fields off an HTTP response, but the shape is the same. The 2048 in `as_path_match()` is what a 2009 author wrote when the BGP framing layer guaranteed nothing longer would arrive. The medium changed in 2019. The author was not asked.\n\nThe unusual move here is the vendor's. CZ.NIC took the closed-network assumption out of the implementer's head and wrote it down inside the CVE record. \"All network operators should already be rejecting routes with unusually long attributes\" is the threat model that produced line 906, restated in the body of the public CVE, on the public record, as the reason a memory-safety bug in a BGP daemon does not warrant a patch. The number 2048 is the bound the parser does not enforce. The bound exists. It exists on the wire. It exists in the operator's filter. It exists in CZ.NIC's reply to MITRE. It does not exist in `parse_path()`.\n\nThe unpatched-at-disclosure shape is the rare case where the vendor's closed-network assumption has been published. Every other exhibit on the pattern page is a developer's worldview inferred from the code. This one came with attribution.\n\nPoC: [9Bakabaka/CVE-2026-49943-PoC](https://github.com/9Bakabaka/CVE-2026-49943-PoC)","closing_line":"The bound is in the array. The bound is in CZ.NIC's reply to MITRE. The bound is not in `parse_path()`.","hook_md":"The vulnerable line is `nest/a-path.c:906`. It reads `struct pm_pos pos[2048 + 1];`. There is no `#define`, no symbolic name, no comment defending the constant. The function that owns the array, `as_path_match()`, runs against AS_PATH attributes the BIRD daemon receives from established BGP peers, and its only check on the length of the path before parsing it is the size of the stack frame.\n\nCZ.NIC's reply to MITRE, recorded inside the CVE record itself, reads: \"all network operators should already be rejecting routes with unusually long attributes.\" The number on line 906 is what they expect operators on the wire to be enforcing. The vendor's reply to MITRE is the same expectation, said out loud.","post_id":546,"slug":"bird-cve-2026-49943-buffer-bound-is-an-operator-policy","title":"CVE-2026-49943: BIRD's AS_PATH Buffer Is 2048 Entries. The Vendor Wrote That Number Into the CVE.","type":"initial","unreadable_sentence":"The mitigation CZ.NIC told MITRE was already in place does not cover the crash they declined to fix."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaqBAywAKCRDeZjl4jgkQ JnBHAQDPBu9huFZYTIxjeBHSrwNiWPVbf1dR3ED7S28lkNe3cQEAheNi521+ciHO Tx2fIVAndWRCMz9zk2n8FsT1TrAzsgM= =fVHB -----END PGP SIGNATURE-----