Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] CIDR Netmasks are strings, not netmasks #182

Open
pacohope opened this issue Jul 2, 2021 · 0 comments
Open

[BUG] CIDR Netmasks are strings, not netmasks #182

pacohope opened this issue Jul 2, 2021 · 0 comments
Labels
bug Something isn't working needs-research

Comments

@pacohope
Copy link

pacohope commented Jul 2, 2021

Describe the bug

In the example security ingress/egress rules, the only CIDR range that will flag as "open to the world" is the exact string of 0.0.0.0/0. For example, 1.0.0.0/0 is also open to the world, but if I process my template where that's the ingress CIDR, I see:

ec2-secgroup-inbound-outbound-access.guard/prevent_inbound_access_to_any_ip     PASS

To Reproduce

I am pretty sure if you change the ingress test case to 1.0.0.0/0 it will pass the test when it should fail. EC2/VPC are perfectly happy to accept that as a CIDR, because it is valid syntactically. They will create an ingress CIDR range that, when you do describe-security-groups will show as 0.0.0.0/0.

The same is probably true for IPv6 CIDR ranges (I haven't tested) because it looks like string matching on ::0.

Expected behavior

If we must treat IPv4 CIDRs as strings, can we just match strings that end with /0? That would be be a wee bit more robust.

Ideally we should parse CIDRs as data structures, extract the netmask as an integer, and complain on small numbers like 8 or less.

@pacohope pacohope added the bug Something isn't working label Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-research
Projects
None yet
Development

No branches or pull requests

2 participants