Repository navigation
VPC ACL: keep the ports and ICMP type of rules given by protocol number or as upper-case ICMP - #14357
Open
bhouse-nexthop wants to merge 2 commits into
Open
bhouse-nexthop wants to merge 2 commits into
bhouse-nexthop wants to merge 2 commits into
Conversation
The VR applies ports only to an ACL rule it is sent as tcp or udp, and an ICMP type and code only to one sent as icmp; anything else becomes a bare protocol-number rule. generateFwRules() sent the protocol as stored, so: - protocol 6 or 17 with ports, which the UI and API accept, was applied to the whole protocol, e.g. all TCP instead of port 22; - protocol 1 set by updateNetworkACLItem (create maps it to icmp, update did not) lost its ICMP type and allowed all ICMP; - an upper-case ICMP failed the case-sensitive "icmp" check and went out with the port range, 0:0, as its type and code, i.e. echo-reply only. Send 1, 6 and 17, and any case, as icmp, tcp and udp, with -1 (any) for a missing ICMP type or code; map protocol 1 to icmp on update as create does. Ports with any other protocol number can't be applied, so reject them when given, and stop the UI offering them. They are only checked when given, so existing rules that carry them stay editable. Fixes: apache#14356 Signed-off-by: Brad House <bhouse@nexthop.ai>
3 of 12 tasks
bhouse-nexthop
requested review from
DaanHoogland,
sureshanaparti,
vladimirpetrov and
weizhouapache
October 8, 2026 10:15
Collaborator
Author
|
@vladimirpetrov @sureshanaparti could you take a look at this one? We'd like this fix to make it into the upcoming 4.22.2 release. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14357 +/- ##
=========================================
Coverage 18.02% 18.03%
- Complexity 16250 16269 +19
=========================================
Files 5936 5936
Lines 535823 535867 +44
Branches 65612 65622 +10
=========================================
+ Hits 96582 96620 +38
- Misses 428242 428250 +8
+ Partials 10999 10997 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Sending 6 or 17 to the VR as tcp or udp also when the rule has no ports made it a tcp or udp rule with the port range 0:0, which the VR's iptables path applies as --dport 0: a rule meant for all of TCP or UDP matched port 0 only. Map them only when the rule has ports; without, the bare number is what matches the whole protocol, as before. Also read the protocol as a number, so that "006" is treated as 6, as the API's own validation does, and check the ports a rule already carries when an update changes its protocol, so that switching a tcp rule to another protocol number cannot leave its ports on it. Signed-off-by: Brad House <bhouse@nexthop.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A VPC network ACL rule given by protocol number 1, 6 or 17, or with the protocol written as upper-case
ICMP, can lose its port range or ICMP type on the virtual router. It is then applied to the whole protocol, and nothing is reported. A rule with ports on any other protocol number is accepted, and its ports are ignored.Fixes #14356
Why it breaks
The VR applies ports only to a rule it receives as
tcporudp, and an ICMP type/code only to one it receives asicmp.SetNetworkACLCommand.generateFwRules()sent the protocol exactly as stored.SetNetworkAclConfigItemturns a protocol number into aProtocolAclRule: a bare number with no port or ICMP fields. So:-p tcp -j ACCEPT, i.e. all TCP.updateNetworkACLItem.createNetworkACLmaps protocol1toicmp, butupdateNetworkACLItemdid not. The ICMP type is then cleared, so the VR allows all ICMP.ICMP(stored as given) failsgenerateFwRules()'s case-sensitive"icmp"check. The rule is sent with the empty port range,0:0, where the ICMP type and code belong, so the VR applies--icmp-type 0/0(echo-reply only), whatever type was asked for. Upper-caseTCP/UDPare not affected, because the VR side lower-cases those.How it is fixed
SetNetworkACLCommand.generateFwRules():icmp.tcpandudponly when the rule has ports. Without ports they stay bare numbers, which is what matches the whole of TCP or UDP. Atcp/udprule with no ports would be sent the range0:0, and the VR's iptables path applies that as--dport 0.006is 6, the same as the API's own validation reads it), and the case of a name doesn't matter.-1(any) instead ofnull. The VR sideparseInts these fields, so anullwould fail the whole ACL apply. That can happen today, judging from the code: a rule switched toicmpby a partial update with no ICMP type stores none.UpdateNetworkACLItemCmd.getProtocol()maps protocol 1 toicmp, the same asCreateNetworkACLCmd.NetworkACLServiceImplrejects ports given with a protocol number other than 6 or 17, since they can't be applied. Ports are checked on create, and on update whenever the request gives ports or a protocol. A protocol change therefore can't leave stored ports on a rule. An existing rule that already carries such ports can still have its other fields edited.AclRulesTab.vue) only shows and sends Start/End port for TCP, UDP, and protocol number 6 or 17.Upgrade note
Existing rules affected by 1–3 will be applied as configured from the next ACL apply:
ICMPrule with type "any" stops being echo-reply only and matches all ICMP.1(only possible through update) was rendered for IPv6 as protocol number 1, which never matches. It now renders as an ICMPv6 rule, the same as anyicmprule.That is what those rules always asked for, but traffic that only got through (or was only blocked) because of the bug will be treated differently. Rules for protocol 6 or 17 without ports are unchanged.
How to reproduce the old behaviour
6, start/end port22, CIDR0.0.0.0/0, Allow. Attach the list to a tier.iptables -S ACL_INBOUND_ethX:-A ACL_INBOUND_ethX -p tcp -j ACCEPT(every TCP port open)-A ACL_INBOUND_ethX -p tcp -m tcp --dport 22 -j ACCEPTcreateNetworkACL protocol=ICMP icmptype=8 icmpcode=0 ...:-p icmp -m icmp --icmp-type 0/0--icmp-type 8/0Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
SetNetworkACLCommandTestchecks the encoded rules:006,01and047are read as numbers;-1;-1when it has none;ICMPkeeps its type;allpass through unchanged.UpdateNetworkACLItemCmdTest: protocol 1 becomesicmp, and anything else is left as is.NetworkACLServiceImplTest:api,coreandservermodules build with checkstyle, and the three test classes pass (2 + 7 + 110 tests).AclRulesTab.vue.tcprule with ports0:0versus a bare protocol 6 by running the rules throughconfigure.py:--dport 0versus all TCP. I have not run this on a VR.How did you try to break this feature and the system with this change?
all, other protocol numbers and lower-case names are encoded as before. A protocol number written with leading zeros is now sent without them.