server: scope IPv6 security group member rules to the exact host - #14037
nagaboinaramgopal wants to merge 2 commits into
Conversation
wido
left a comment
There was a problem hiding this comment.
Code looks good. This is a very common IPv6 oversight of people. Good catch! Lets merge this one quickly
but in the 4.20 branch. by the looks of it this has been in since 4.19.4? |
When a security group rule references another security group, each member VM should be authorized as an exact host. The IPv4 address is correctly pinned to a /32, but the IPv6 address was expanded to /64, opening the whole subnet the member sits in rather than just that member. Pin the IPv6 member to /128 to match the IPv4 behaviour.
I did not check. But lets make sure it at least goes into 4.20 and onwards |
8358dfa to
8c6df72
Compare
|
tnx guys |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.20 #14037 +/- ##
============================================
+ Coverage 16.34% 16.40% +0.05%
- Complexity 13574 13635 +61
============================================
Files 5669 5669
Lines 501368 501541 +173
Branches 60903 60925 +22
============================================
+ Hits 81964 82261 +297
+ Misses 410219 410058 -161
- Partials 9185 9222 +37
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:
|
|
@blueorangutan package |
|
@DaanHoogland 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19090 |
|
Thanks @wido for the review and @DaanHoogland for the package build. This needs a smoke test run and a second review. |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-17058)
|
|
@nagaboinaramgopal After digging into it, I think the same change is needed in SecurityGroupManagerImpl2.java as well. |
|
Good catch, thanks. |
| cidrs.add(cidr); | ||
| if (defaultNic.getIPv6Address() != null) { | ||
| cidrs.add(defaultNic.getIPv6Address() + "/64"); | ||
| cidrs.add(defaultNic.getIPv6Address() + "/128"); |
There was a problem hiding this comment.
what happens to vms that pick their own random ipv6 address, like windows does by default? looks like their traffic wont match this single address anymore
There was a problem hiding this comment.
Thanks for raising this, it's a good thing to pin down. I went and looked at the agent side to be sure, and I think we might actually be covered here, though let me know if I'm missing a case.
From what I can see, a VM can't really put a self-chosen address on the wire in an SG network anyway. The KVM agent installs a source anti-spoof rule in security_group.py (the -m set ! --match-set <vmipset6> src -j DROP near the end of the IPv6 default chain), and that ipset only gets the addresses CloudStack assigned to the NIC. So a Windows temporary/privacy address wouldn't be in the set, and its traffic would get dropped at that VM's own vNIC before the receiving VM's member rule is ever looked at. If that reading is right, then /64 wasn't really letting those packets through either, they just died earlier in the path.
Where /64 did make a difference, I think, is that it also let any other VM sharing that /64 reach the protected VM, member or not, and narrowing to /128 lines it up with what the IPv4 side already does at /32. Does that match how you understand it, or is there a setup where a VM ends up sending from an address CloudStack didn't assign?
There was a problem hiding this comment.
makes sense, the agent drops anything from an address it didnt assign so /64 wasnt helping there. thanks for checking
Description
When a security group rule references another security group, each member VM
should be authorized as an exact host. The IPv4 address is correctly pinned to a
/32, but the IPv6 address was expanded to /64, opening the whole subnet the
member sits in rather than just that member. This silently broadens the rule to
every address in the member's /64.
Pin the IPv6 member to /128 to match the IPv4 behaviour.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Added a unit test asserting an IPv6 security-group member is authorized as a /128
host and not the whole /64. Also built the standard packages and deployed on a KVM
advanced zone.