Repository navigation
Validate ACL, firewall and routing rule protocols against the list, not as a substring - #14359
Open
bhouse-nexthop wants to merge 3 commits into
Open
bhouse-nexthop wants to merge 3 commits into
bhouse-nexthop wants to merge 3 commits into
Conversation
validateProtocol() checked a protocol name with "tcp,udp,icmp,all".contains(protocol), a substring test, so "cp", "t", "dp,ic", "," or "tcp,udp" were accepted. Such a rule is stored and listed but never applied: the VR side can't parse it and drops it with only a warning. Compare against the entries of the list instead. Fixes: apache#14358 Signed-off-by: Brad House <bhouse@nexthop.ai>
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 #14359 +/- ##
============================================
- Coverage 18.02% 18.02% -0.01%
- Complexity 16250 16251 +1
============================================
Files 5936 5936
Lines 535823 535832 +9
Branches 65612 65614 +2
============================================
- Hits 96582 96562 -20
- Misses 428242 428271 +29
Partials 10999 10999
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:
|
Signed-off-by: Brad House <bhouse@nexthop.ai>
Damans227
reviewed
Oct 8, 2026
The firewall (port forwarding, static NAT, firewall), IPv6 firewall and
routing firewall rule checks test the protocol against the provider's
supported protocols with the same substring test, so "cp" or "dp,ic"
passed them as well. Add NetUtils.isProtocolInList(), which matches a
whole entry of the comma-separated list in any case, trimming the entries
since some providers list them with a space after the comma ("tcp,udp,
icmp, all"), and use it for these checks and the network ACL one.
Signed-off-by: Brad House <bhouse@nexthop.ai>
3 of 12 tasks
Damans227
approved these changes
Oct 8, 2026
Damans227
left a comment
Collaborator
There was a problem hiding this comment.
thanks @bhouse-nexthop, fix looks right. LGTM
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
createNetworkACLandupdateNetworkACLItemaccept protocol names that are not valid, such ascp,dp,icortcp,udp. The rule is stored and listed but never applied.Fixes #14358
Why it breaks
NetworkACLServiceImpl.validateProtocol()checked a non-numeric protocol withsupportedProtocolsForAclRules.contains(protocol.toLowerCase()).supportedProtocolsForAclRulesis the string"tcp,udp,icmp,all", so this is a substring test: anything that appears inside it passes.On the VR side,
SetNetworkAclConfigItemdoesn't recognise such a protocol, triesInteger.parseInton it, and drops the rule with only a warning in the agent log. An allow or deny that the API accepted, and that the UI shows, silently does nothing.How it is fixed
A new
NetUtils.isProtocolInList(list, protocol)checks that the protocol is a whole entry of the comma-separated list, in any case.validateProtocol()now uses it. The field, the error message and the valid names are unchanged.FirewallManagerImpl), IPv6 firewall rules (Ipv6ServiceImpl) and routing firewall rules (RoutedIpv4ManagerImpl), socppassed those too. They now use the helper as well."tcp,udp,icmp, all"). The protocol being checked is not trimmed.How to reproduce the old behaviour
createNetworkACL aclid=<id> protocol=cp startport=22 endport=22 cidrlist=0.0.0.0/0 action=deny traffictype=ingresslistNetworkACLsshows the rule with protocolcp. No rule for it appears on the VR, and the agent logs "Problem occurred when reading the entries in the ruleParts array".Invalid protocol [cp]. Expected one of: [tcp,udp,icmp,all].The old and new checks, side by side (jshell):
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
NetworkACLServiceImplTest.validateProtocolTestProtocolIsPartOfTheSupportedListchecks thatcp,t,dp,ic,,andtcp,udpare each rejected.NetUtilsTest.testIsProtocolInList:allin"tcp,udp,icmp, all");cp,dp,ic,tcp,udp,proxyagainsttcp-proxy, an empty string,all).NetUtilsTest,Ipv6ServiceImplTest,RoutedIpv4ManagerImplTestandFirewallManagerTeststill pass (utilsandserverbuild with checkstyle).validateProtocolTestProtocolNameInAnyCasechecks that valid names are still accepted in any case (TCP,Udp,ICMP,All). The existing tests for valid names and protocol numbers still pass:NetworkACLServiceImplTest, 106 tests.serverbuilds with checkstyle.How did you try to break this feature and the system with this change?
Locale.ROOT. Under a Turkish default locale the old check rejectedICMP, because it lowercased to a dotlessıcmp; it is now accepted.NetworkACLServiceImpl, in a different method.