bgpd: fix off-by-one error in FlowSpec operator array bounds check - #21054
Conversation
Greptile SummaryThis PR fixes an off-by-one buffer overflow in Key changes:
Both changes are minimal, correct, and consistent with how the arrays are declared ( Confidence Score: 5/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Enter decode loop β loop = 0"] --> B{"loop >= BGP_PBR_MATCH_VAL_MAX ?"}
B -- Yes --> C["*error = -2\nreturn offset β array full"]
B -- No --> D{"offset >= max_len ?"}
D -- Yes --> E["*error = -1\nbreak β truncated input"]
D -- No --> F["Parse operator byte\ncompute value_size"]
F --> G{"BGP_FLOWSPEC_CONVERT\n_TO_NON_OPAQUE ?"}
G -- Yes --> H["Write to mval, mval++"]
G -- No --> I["String / validate path"]
H --> J["offset += value_size\nloop++"]
I --> J
J --> K{"op[0] == 0 AND\noffset < max_len-1 ?"}
K -- "Yes, more operators" --> B
K -- "No, end-of-list" --> L["*error = loop\nreturn offset"]
Last reviewed commit: 0e6882b |
Change loop > BGP_PBR_MATCH_VAL_MAX to loop >= BGP_PBR_MATCH_VAL_MAX in bgp_flowspec_op_decode() and bgp_flowspec_bitmask_decode() to prevent writing one element past the end of the mval[] array when more than 5 chained operators are present in a FlowSpec component. Reported-by: Jiahao Lei Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
|
@Mergifyio backport stable/10.6 stable/10.5 stable/10.4 stable/10.3 stable/10.2 stable/10.1 stable/10.0 |
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
bgpd: fix off-by-one error in FlowSpec operator array bounds check (backport #21054)
https://build.opensuse.org/request/show/1351832 by user mtomaschewski + dimstar_suse - Update to frr-10.6.1 (https://frrouting.org/release/10.6.1/) providing several bug fixes. Already the previous update to frr-10.6.0 includes security fixes for the following Denial of Service (DoS) vulnerabilities: - ospfd: harden TE/SR TLV iteration against malformed lengths (bsc#1263859,CVE-2026-28532,gh#FRRouting/frr#21002) - bgpd: fix off-by-one error in FlowSpec operator array bounds check (bsc#1263863,CVE-2026-37457,gh#FRRouting/frr#21054) - bgpd: Validate MP_REACH_NLRI attribute against incorrect next-hop (bsc#1263974,CVE-2026-37458,gh#FRRouting/frr#21075) - bgpd: Check if the NHC length is enough to fill TLV value + TLV header (bsc#1264051,CVE-2026-37459,gh#FRRouting/frr#21074)
Change loop > BGP_PBR_MATCH_VAL_MAX to loop >= BGP_PBR_MATCH_VAL_MAX in bgp_flowspec_op_decode() and bgp_flowspec_bitmask_decode() to prevent writing one element past the end of the mval[] array when more than 5 chained operators are present in a FlowSpec component.