Visitar URL original
Network ACL: validate the protocol name against the list, not as a substring by bhouse-nexthop · Pull Request #14359 · apache/cloudstack · GitHub
Skip to content

Network ACL: validate the protocol name against the list, not as a substring - #14359

Open
bhouse-nexthop wants to merge 2 commits into
apache:4.22from
bhouse-nexthop:fix-acl-protocol-validation
Open

bhouse-nexthop wants to merge 2 commits into
apache:4.22from
bhouse-nexthop:fix-acl-protocol-validation

Conversation

@bhouse-nexthop

@bhouse-nexthop bhouse-nexthop commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

createNetworkACL and updateNetworkACLItem accept protocol names that are not valid, such as cp, dp,ic or tcp,udp. The rule is stored and listed but never applied.

Fixes #14358

Why it breaks

NetworkACLServiceImpl.validateProtocol() checked a non-numeric protocol with supportedProtocolsForAclRules.contains(protocol.toLowerCase()). supportedProtocolsForAclRules is the string "tcp,udp,icmp,all", so this is a substring test: anything that appears inside it passes.

On the VR side, SetNetworkAclConfigItem doesn't recognise such a protocol, tries Integer.parseInt on 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

The protocol is compared against the entries of the list (split(",")), case-insensitively as before. The field, the error message and the valid names are unchanged.

How to reproduce the old behaviour

  1. createNetworkACL aclid=<id> protocol=cp startport=22 endport=22 cidrlist=0.0.0.0/0 action=deny traffictype=ingress
    • Before: succeeds, and listNetworkACLs shows the rule with protocol cp. No rule for it appears on the VR, and the agent logs "Problem occurred when reading the entries in the ruleParts array".
    • After: Invalid protocol [cp]. Expected one of: [tcp,udp,icmp,all].

The old and new checks, side by side (jshell):

cp      -> old check passes: true, new: false
t       -> old check passes: true, new: false
dp,ic   -> old check passes: true, new: false
,       -> old check passes: true, new: false
tcp,udp -> old check passes: true, new: false

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  • New NetworkACLServiceImplTest.validateProtocolTestProtocolIsPartOfTheSupportedList checks that cp, t, dp,ic, , and tcp,udp are each rejected.
  • New validateProtocolTestProtocolNameInAnyCase checks 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.
  • server builds with checkstyle.

How did you try to break this feature and the system with this change?

  • Valid input: every protocol name accepted today that is actually valid is still accepted, in any case. Numeric protocols take the other branch and are unaffected.
  • Locale: the comparison now lowercases with Locale.ROOT. Under a Turkish default locale the old check rejected ICMP, because it lowercased to a dotless ıcmp; it is now accepted.
  • Existing rules: a rule already stored with an invalid name would now fail validation on its next update. Such a rule has never been applied, so the error simply surfaces what was already broken.
  • Other open PRs: this is independent of VPC ACL: keep the ports and ICMP type of rules given by protocol number or as upper-case ICMP #14357, which also touches NetworkACLServiceImpl, in a different method.

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

Copy link
Copy Markdown
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

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 4.04%. Comparing base (2974af8) to head (c9c49d8).
⚠️ Report is 1 commits behind head on 4.22.

❗ There is a different number of reports uploaded between BASE (2974af8) and HEAD (c9c49d8). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (2974af8) HEAD (c9c49d8)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               4.22   #14359       +/-   ##
=============================================
- Coverage     18.02%    4.04%   -13.99%     
=============================================
  Files          5936      449     -5487     
  Lines        535823    38240   -497583     
  Branches      65612     7082    -58530     
=============================================
- Hits          96582     1546    -95036     
+ Misses       428242    36482   -391760     
+ Partials      10999      212    -10787     
Flag Coverage Δ
uitests 4.04% <ø> (ø)
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Brad House <bhouse@nexthop.ai>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant