You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "bhouse-nexthop (via GitHub)" <gi...@apache.org> on 2026/10/08 10:15:29 UTC
[PR] Network ACL: validate the protocol name against the list, not as a substring [cloudstack]
bhouse-nexthop opened a new pull request, #14359:
URL: https://github.com/apache/cloudstack/pull/14359
### 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)
- [x] 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
- [x] Test (unit or integration test code)
### Feature/Enhancement Scale or Bug Severity
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [x] Minor
- [ ] Trivial
### How Has This Been Tested?
- New `NetworkACLServiceImplTest.validateProtocolTestProtocolIsPartOfTheSupportedList` checks that `cp`, `t`, `dp,ic`, `,` and `tcp,udp` are each rejected.
- The existing tests for valid names (`tcp`, `udp`, `icmp`, `all`, any case) and for protocol numbers still pass: `NetworkACLServiceImplTest`, 105 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.
- **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 #14357, which also touches `NetworkACLServiceImpl`, in a different method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6423288530
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "Damans227 (via GitHub)" <gi...@apache.org>.
Damans227 commented on code in PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#discussion_r4218945570
##########
server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java:
##########
@@ -619,7 +620,8 @@ protected void validateProtocol(NetworkACLItemVO networkACLItemVO) {
throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
}
} else {
- if (!supportedProtocolsForAclRules.contains(protocol.toLowerCase())) {
+ // one of the names, not just part of the string: "cp" or "dp,ic" must not pass
+ if (!Arrays.asList(supportedProtocolsForAclRules.split(",")).contains(protocol.toLowerCase(Locale.ROOT))) {
Review Comment:
that covers it, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Network ACL: validate the protocol name against the list, not as a substring [cloudstack]
Posted by "bhouse-nexthop (via GitHub)" <gi...@apache.org>.
bhouse-nexthop commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6057671130
@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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6344827851
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19683
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Network ACL: validate the protocol name against the list, not as a substring [cloudstack]
Posted by "Damans227 (via GitHub)" <gi...@apache.org>.
Damans227 commented on code in PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#discussion_r4218650433
##########
server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java:
##########
@@ -619,7 +620,8 @@ protected void validateProtocol(NetworkACLItemVO networkACLItemVO) {
throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
}
} else {
- if (!supportedProtocolsForAclRules.contains(protocol.toLowerCase())) {
+ // one of the names, not just part of the string: "cp" or "dp,ic" must not pass
+ if (!Arrays.asList(supportedProtocolsForAclRules.split(",")).contains(protocol.toLowerCase(Locale.ROOT))) {
Review Comment:
should the firewall and routed network rules get the same fix? they use the same part-of-the-string check, so "cp" still passes there
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6423271418
@blueorangutan test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "bhouse-nexthop (via GitHub)" <gi...@apache.org>.
bhouse-nexthop commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6415669265
@sureshanaparti @DaanHoogland this has three approvals (@DaanHoogland, @weizhouapache, @Damans227), and packaging passed on 10-22, but it hasn't had a Trillian run yet. Could one of you kick one so it can be merged for 4.22.2?
It and #14357 both add tests at the end of `NetUtilsTest`, so I'll rebase whichever is merged second.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6440050869
<b>[SF] Trillian test result (tid-17277)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 54649 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14359-t17277-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Network ACL: validate the protocol name against the list, not as a substring [cloudstack]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6057808515
## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/14359?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 4.04%. Comparing base ([`2974af8`](https://app.codecov.io/gh/apache/cloudstack/commit/2974af84f22a8def8339380628d8653a4f016d3f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`500f583`](https://app.codecov.io/gh/apache/cloudstack/commit/500f583551e32a76ea9aa20b4e60e720c93d33fd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on 4.22.
> :exclamation: There is a different number of reports uploaded between BASE (2974af8) and HEAD (500f583). Click for more details.
>
> <details><summary>HEAD has 1 upload less than BASE</summary>
>
>| Flag | BASE (2974af8) | HEAD (500f583) |
>|------|------|------|
>|unittests|1|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ 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](https://app.codecov.io/gh/apache/cloudstack/pull/14359/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/14359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.04% <ø> (ø)` | |
| [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/14359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/cloudstack/pull/14359?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "bhouse-nexthop (via GitHub)" <gi...@apache.org>.
bhouse-nexthop commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6342328896
@DaanHoogland this has your and @Damans227's approvals but no Trillian run yet. Could you kick one so it can go into 4.22.2 before Monday?
Heads up on merge order: this and #14357 both add tests at the end of `NetUtilsTest`, so whichever merges second will conflict there. I'll rebase that one as soon as the first is in.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6343002773
@blueorangutan package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "bhouse-nexthop (via GitHub)" <gi...@apache.org>.
bhouse-nexthop commented on code in PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#discussion_r4218824852
##########
server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java:
##########
@@ -619,7 +620,8 @@ protected void validateProtocol(NetworkACLItemVO networkACLItemVO) {
throw new InvalidParameterValueException("Invalid protocol number: " + protoNumber);
}
} else {
- if (!supportedProtocolsForAclRules.contains(protocol.toLowerCase())) {
+ // one of the names, not just part of the string: "cp" or "dp,ic" must not pass
+ if (!Arrays.asList(supportedProtocolsForAclRules.split(",")).contains(protocol.toLowerCase(Locale.ROOT))) {
Review Comment:
Yes, good catch. They had the same check, and some provider lists have a space after the comma (`"tcp,udp,icmp, all"`), so splitting alone would have rejected `all`. fa1632dbee adds `NetUtils.isProtocolInList()`, which matches a whole entry in any case and trims the list entries. It is now used by the network ACL check and by the firewall / port forwarding / static NAT (`FirewallManagerImpl`), IPv6 firewall (`Ipv6ServiceImpl`) and routing firewall (`RoutedIpv4ManagerImpl`) checks, with tests for the helper. I updated the description to match.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6343057042
@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Validate ACL, firewall and routing rule protocols against the list, not as a substring [cloudstack]
Posted by "bhouse-nexthop (via GitHub) via commits" <co...@cloudstack.apache.org>.
bhouse-nexthop commented on PR #14359:
URL: https://github.com/apache/cloudstack/pull/14359#issuecomment-6730972923
### Test report: protocol validation on every rule API, on a running zone
**Environment**
- A CloudStack 24.0 (main) build with this PR applied, alongside some of my other open PRs. The code on the paths below is the same as on 4.22.
- Three KVM hosts on Ubuntu 24.04, nested virtualisation; Ceph RBD primary storage; system VM template 4.22.0.
- Networks: a VPC with an ACL'd tier, an isolated network on `DefaultIsolatedNetworkOfferingWithSourceNatService`, a dual-stack isolated network, and a routed isolated network.
Each command was tried with `protocol=cp`, `tcp,udp` and `dp,ic`, then with `TCP`, `Udp`, `ICMP` and `All`.
| Command | `cp` / `tcp,udp` / `dp,ic` | Valid names |
|---|---|---|
| `createNetworkACL` (VPC) | refused: `Invalid protocol [cp]. Expected one of: [tcp,udp,icmp,all]` (likewise for the other two) | `TCP`, `Udp`, `ICMP`, `All` and the lower-case forms accepted |
| `updateNetworkACLItem` | refused with the same message (job result 431). The stored rule is unchanged (`tcp 22-22`) | `TCP`, `Udp`, `ICMP`, `All` accepted on a rule without ports |
| `createFirewallRule` (isolated network public IP) | refused: `Protocol cp is not supported in zone 1` | `TCP`, `Udp`, `ICMP` accepted |
| `createEgressFirewallRule` | refused | `TCP`, `Udp`, `ICMP`, `All` accepted. `All` is matched against `"tcp,udp,icmp, all"`, the egress list with a space, which the helper trims |
| `createPortForwardingRule` | refused | `TCP`, `Udp` accepted |
| `createIpv6FirewallRule` (dual-stack isolated network) | refused: `Protocol cp is not supported in zone` | `TCP`, `Udp`, `ICMP` accepted; egress `All` accepted |
| `createRoutingFirewallRule` (routed isolated network) | refused | `TCP`, `Udp`, `ICMP` accepted; egress `All` accepted |
Valid names that are refused, the same as on stock:
- `All` on an **ingress** firewall, IPv6 firewall or routing firewall rule. The provider's ingress list is `tcp,udp,icmp`, and stock refuses `all` too.
- `ICMP` and `All` on port forwarding. The port forwarding list is `tcp,udp`.
- `updateNetworkACLItem protocol=ICMP` or `protocol=All` on a rule that still has ports, refused for the ports ("Can't specify start/end port when protocol is ICMP"). This is #14357's partial-update behaviour, not this PR's.
**Without the PR** (from the code; there is no toggle): stock checks `supportedProtocols.contains(protocol.toLowerCase())`, so it accepts `cp`, `tcp,udp` and `dp,ic`. The router then fails to load such a rule (`iptables ... -p cp -m cp` is rejected) while the API shows it `Active`.
**Result:** pass. Every invalid protocol is refused, and every valid name is accepted in any case wherever the provider supports it.
**Main has a fifth call site**
- Main has a fifth substring check, which 4.22 lacks: `FirewallManagerImpl.validateFirewallRuleForVpc()`, from #12706 (firewall rules on VPC public IPs). It came after this PR branched.
- In the lab, with a VPC offering that has the Firewall service, this build accepted `cp`, `tcp,udp` and `dp,ic` as firewall rules on the VPC public IP. They were stored `Active`, but the router never loaded them.
- I tested a one-line follow-up for main, which uses this PR's helper (`NetUtils.isProtocolInList`), in the lab build. All three are now refused with `Protocol cp is not supported in VPC 5` (likewise for the other two). `TCP`, `Udp` and `ICMP` are accepted and loaded on the router: `iptables-save -t mangle` shows the three `FIREWALL_<public ip>` rules and nothing else. I'll open it against main once this PR is merged forward.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org