* Tue Jun 30 2026 Phil Sutter <psutter@redhat.com> [1.0.9-8.el9]
- parser_json: fix map/set type confusion crash in map statement parser (Phil Sutter) [RHEL-190549]
- parser_json: bail out on malformed statement in set (Phil Sutter) [RHEL-190549]
- parser_json: allow statement stateful statement only in set elements (Phil Sutter) [RHEL-190549]
- parser_json: fix crash in json_parse_set_stmt_list (Phil Sutter) [RHEL-190549]
- cache: honor -c/--check for reset commands (Phil Sutter) [RHEL-190549]
- mnl: Fix ordering of hooks in 'list hooks' output (Phil Sutter) [RHEL-190549]
- segtree: Fix for variable-sized object may not be initialized (Phil Sutter) [RHEL-190549]
- cache: Filter for table when listing flowtables (Phil Sutter) [RHEL-190549]
- cache: Filter for table when listing sets or maps (Phil Sutter) [RHEL-190549]
- cache: Relax chain_cache_dump filter application (Phil Sutter) [RHEL-190549]
- cache: Respect family in all list commands (Phil Sutter) [RHEL-190549]
- json: complete multi-statement set element support (Phil Sutter) [RHEL-190549]
- mergesort: Align concatenation sort order with Big Endian (Phil Sutter) [RHEL-190549]
- optimize: expand expression list when merging into concatenation (Phil Sutter) [RHEL-190549]
- mergesort: Fix sorting of string values (Phil Sutter) [RHEL-190549]
- segtree: Fix range aggregation on Big Endian (Phil Sutter) [RHEL-190549]
- monitor: fix memleak in setelem cb (Phil Sutter) [RHEL-190549]
- tests: json_echo: Drop rule handle before multi-add (Phil Sutter) [RHEL-190549]
- rule: skip CMD_OBJ_SETELEMS with no elements after set flush (Phil Sutter) [RHEL-190549]
- doc: libnftables-json: Describe RULESET object (Phil Sutter) [RHEL-190549]
- doc: don't suggest to disable GSO (Phil Sutter) [RHEL-190549]
- tests: py: inet/osf.t: Fix element ordering in JSON equivalents (Phil Sutter) [RHEL-190549]
- tests: py: any/ct.t.json.output: Drop leftover entry (Phil Sutter) [RHEL-190549]
- optimize: Fix verdict expression comparison (Phil Sutter) [RHEL-190549]
- datatype: Fix boolean type on Big Endian (Phil Sutter) [RHEL-190549]
- datatype: clamp boolean value to 0 and 1 (Phil Sutter) [RHEL-190549]
- src: parser_json: fix format string bugs (Phil Sutter) [RHEL-190549]
- doc: fix tcpdump example (Phil Sutter) [RHEL-190549]
- fib: Fix for existence check on Big Endian (Phil Sutter) [RHEL-190549]
- monitor: Inform JSON printer when reporting an object delete event (Phil Sutter) [RHEL-190549]
- tests: monitor: Fix regex collecting expected echo output (Phil Sutter) [RHEL-190549]
- monitor: Quote device names in chain declarations, too (Phil Sutter) [RHEL-190549]
- mnl: continue on ENOBUFS errors when processing batch (Phil Sutter) [RHEL-190549]
- mnl: silence compiler warning (Phil Sutter) [RHEL-190549]
- fib: restore JSON output for relational expressions (Phil Sutter) [RHEL-190549]
- json: Do not reduce single-item arrays on output (Phil Sutter) [RHEL-190549]
- src: ensure chain policy evaluation when specified (Phil Sutter) [RHEL-190549]
- segtree: incorrect type when aggregating concatenated set ranges (Phil Sutter) [RHEL-190549]
- tests: py: Fix tests added for 'icmpv6 taddr' support (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entry from ip/snat.t.payload (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entries from ip6/{ct,meta}.t.json (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entry from ip/snat.t.json (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/vxlan.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entry from inet/tcp.t.json (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/gretap.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/gre.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop duplicate test from inet/geneve.t (Phil Sutter) [RHEL-190549]
- tests: py: Drop stale entries since redundant test case removal (Phil Sutter) [RHEL-190549]
- src: netlink: netlink_delinearize_table() may return NULL (Phil Sutter) [RHEL-190549]
- doc: nft.8: Minor NAT STATEMENTS section review (Phil Sutter) [RHEL-190549]
- mnl: Call mnl_attr_nest_end() just once (Phil Sutter) [RHEL-190549]
- evaluate: validate set expression type before accessing flags (Phil Sutter) [RHEL-190549]
- rule: print chain and flowtable devices in quotes (Phil Sutter) [RHEL-190549]
- tests: shell: skip if kernel does not support flowtable counter (Phil Sutter) [RHEL-190549]
- tests: shell: adjust add-after-delete flowtable for older kernels (Phil Sutter) [RHEL-190549]
- tests/shell: cover long interface name in "0042chain_variable_0" test (Phil Sutter) [RHEL-190549]
- tests: py: re-enables nft-test.py to load the local nftables.py (Phil Sutter) [RHEL-190549]
- fib: allow to use it in set statements (Phil Sutter) [RHEL-190549]
- fib: allow to check if route exists in maps (Phil Sutter) [RHEL-190549]
- tests: py: fix json single-flag output for fib & synproxy (Phil Sutter) [RHEL-190549]
- parser_json: Introduce parse_flags_array() (Phil Sutter) [RHEL-190549]
- json: work around fuzzer-induced assert crashes (Phil Sutter) [RHEL-190549]
- json: Introduce json_add_array_new() (Phil Sutter) [RHEL-190549]
- json: Print single synproxy flags as non-array (Phil Sutter) [RHEL-190549]
- json: Print single fib flag as non-array (Phil Sutter) [RHEL-190549]
- json: fix use after free in table_flags_json() (Phil Sutter) [RHEL-190549]
- doc: extend description of fib expression (Phil Sutter) [RHEL-190549]
- json: reject too long interface names (Phil Sutter) [RHEL-190549]
- parser_bison: allow delete command with map via handle (Phil Sutter) [RHEL-190549]
- parser_bison: only reset by name is supported by now (Phil Sutter) [RHEL-190549]
- cache: assert name is non-nul when looking up (Phil Sutter) [RHEL-190549]
- rule: skip fuzzy lookup if object name is not available (Phil Sutter) [RHEL-190549]
- src: BASECHAIN flag no longer implies presence of priority expression (Phil Sutter) [RHEL-190549]
- netlink: Avoid crash upon missing NFTNL_OBJ_CT_TIMEOUT_ARRAY attribute (Phil Sutter) [RHEL-190549]
- tests: py: Properly fix JSON equivalents for netdev/reject.t (Phil Sutter) [RHEL-190549]
- tests: monitor: Fix for single flag array avoidance (Phil Sutter) [RHEL-190549]
- json: Support typeof in set and map types (Phil Sutter) [RHEL-190549]
- netlink: Do not allocate a bogus flowtable priority expr (Phil Sutter) [RHEL-190549]
- netlink: Fix for potential crash parsing a flowtable (Phil Sutter) [RHEL-190549]
- json: prevent null deref if chain->policy is not set (Phil Sutter) [RHEL-190549]
- netlink: Catch unknown types when deserializing objects (Phil Sutter) [RHEL-190549]
- netlink: Avoid potential NULL-ptr deref parsing set elem expressions (Phil Sutter) [RHEL-190549]
- json: Print single set flag as non-array (Phil Sutter) [RHEL-190549]
- doc: Fix typo in nat statement 'prefix' description (Phil Sutter) [RHEL-190549]
Resolves: RHEL-190549
173 lines
4.8 KiB
Diff
173 lines
4.8 KiB
Diff
From 0a64846a869aab6c9bc5cb1adb268a16f53bb9f8 Mon Sep 17 00:00:00 2001
|
|
From: Phil Sutter <psutter@redhat.com>
|
|
Date: Tue, 30 Jun 2026 14:25:19 +0200
|
|
Subject: [PATCH] json: reject too long interface names
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-190549
|
|
Upstream Status: nftables commit bed99830c4c63eae205c28a7ff914737bedb199d
|
|
|
|
commit bed99830c4c63eae205c28a7ff914737bedb199d
|
|
Author: Florian Westphal <fw@strlen.de>
|
|
Date: Tue Jun 24 23:46:59 2025 +0200
|
|
|
|
json: reject too long interface names
|
|
|
|
Blamed commit added a length check on ifnames to the bison parser.
|
|
Unfortunately that wasn't enough, json parser has the same issue.
|
|
|
|
Bogon results in:
|
|
BUG: Interface length 44 exceeds limit
|
|
nft: src/mnl.c:742: nft_dev_add: Assertion `0' failed.
|
|
|
|
After patch, included bogon results in:
|
|
Error: Invalid device at index 0. name d2345678999999999999999999999999999999012345 too long
|
|
|
|
I intentionally did not extend evaluate.c to catch this, past sentiment
|
|
was that frontends should not send garbage.
|
|
|
|
I'll send a followup patch to also catch this from eval stage in case there
|
|
are further reports for frontends passing in such long names.
|
|
|
|
Fixes: fa52bc225806 ("parser: reject zero-length interface names")
|
|
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
|
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
---
|
|
src/parser_json.c | 17 +++-
|
|
.../nft-j-f/dev_name_parser_overflow_crash | 90 +++++++++++++++++++
|
|
2 files changed, 105 insertions(+), 2 deletions(-)
|
|
create mode 100644 tests/shell/testcases/bogons/nft-j-f/dev_name_parser_overflow_crash
|
|
|
|
diff --git a/src/parser_json.c b/src/parser_json.c
|
|
index 936c5aa..eefb8af 100644
|
|
--- a/src/parser_json.c
|
|
+++ b/src/parser_json.c
|
|
@@ -3062,7 +3062,13 @@ static struct expr *json_parse_devs(struct json_ctx *ctx, json_t *root)
|
|
size_t index;
|
|
|
|
if (!json_unpack(root, "s", &dev)) {
|
|
- tmp = constant_expr_alloc(int_loc, &string_type,
|
|
+ if (strlen(dev) >= IFNAMSIZ) {
|
|
+ json_error(ctx, "Device name %s too long", dev);
|
|
+ expr_free(expr);
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ tmp = constant_expr_alloc(int_loc, &ifname_type,
|
|
BYTEORDER_HOST_ENDIAN,
|
|
strlen(dev) * BITS_PER_BYTE, dev);
|
|
compound_expr_add(expr, tmp);
|
|
@@ -3080,7 +3086,14 @@ static struct expr *json_parse_devs(struct json_ctx *ctx, json_t *root)
|
|
expr_free(expr);
|
|
return NULL;
|
|
}
|
|
- tmp = constant_expr_alloc(int_loc, &string_type,
|
|
+
|
|
+ if (strlen(dev) >= IFNAMSIZ) {
|
|
+ json_error(ctx, "Device name %s too long at index %zu", dev, index);
|
|
+ expr_free(expr);
|
|
+ return NULL;
|
|
+ }
|
|
+
|
|
+ tmp = constant_expr_alloc(int_loc, &ifname_type,
|
|
BYTEORDER_HOST_ENDIAN,
|
|
strlen(dev) * BITS_PER_BYTE, dev);
|
|
compound_expr_add(expr, tmp);
|
|
diff --git a/tests/shell/testcases/bogons/nft-j-f/dev_name_parser_overflow_crash b/tests/shell/testcases/bogons/nft-j-f/dev_name_parser_overflow_crash
|
|
new file mode 100644
|
|
index 0000000..8303c5c
|
|
--- /dev/null
|
|
+++ b/tests/shell/testcases/bogons/nft-j-f/dev_name_parser_overflow_crash
|
|
@@ -0,0 +1,90 @@
|
|
+{
|
|
+ "nftables": [
|
|
+ {
|
|
+ "metainfo": {
|
|
+ "version": "VERSION",
|
|
+ "release_name": "RELEASE_NAME",
|
|
+ "json_schema_version": 1
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "table": {
|
|
+ "family": "netdev",
|
|
+ "name": "filter1",
|
|
+ "handle": 0
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "chain": {
|
|
+ "family": "netdev",
|
|
+ "table": "filter1",
|
|
+ "name": "Main_Ingress1",
|
|
+ "handle": 0,
|
|
+ "dev": "lo",
|
|
+ "type": "filter",
|
|
+ "hook": "ingress",
|
|
+ "prio": -500,
|
|
+ "policy": "accept"
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "table": {
|
|
+ "family": "netdev",
|
|
+ "name": "filter2",
|
|
+ "handle": 0
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "chain": {
|
|
+ "family": "netdev",
|
|
+ "table": "filter2",
|
|
+ "name": "Main_Ingress2",
|
|
+ "handle": 0,
|
|
+ "dev": [
|
|
+ "d2345678999999999999999999999999999999012345",
|
|
+ "lo"
|
|
+ ],
|
|
+ "type": "filter",
|
|
+ "hook": "ingress",
|
|
+ "prio": -500,
|
|
+ "policy": "accept"
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "table": {
|
|
+ "family": "netdev",
|
|
+ "name": "filter3",
|
|
+ "handle": 0
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "chain": {
|
|
+ "family": "netdev",
|
|
+ "table": "filter3",
|
|
+ "name": "Main_Ingress3",
|
|
+ "handle": 0,
|
|
+ "dev": [
|
|
+ "d23456789012345",
|
|
+ "lo"
|
|
+ ],
|
|
+ "type": "filter",
|
|
+ "hook": "ingress",
|
|
+ "prio": -500,
|
|
+ "policy": "accept"
|
|
+ }
|
|
+ },
|
|
+ {
|
|
+ "chain": {
|
|
+ "family": "netdev",
|
|
+ "table": "filter3",
|
|
+ "name": "Main_Egress3",
|
|
+ "handle": 0,
|
|
+ "dev": "lo",
|
|
+ "type": "filter",
|
|
+ "hook": "egress",
|
|
+ "prio": -500,
|
|
+ "policy": "accept"
|
|
+ }
|
|
+ }
|
|
+ ]
|
|
+}
|