Notes
open one at a time
1.What it can cause
Every port on every VM with an external address answers the internet - database ports, admin consoles, debug ports nobody remembers opening.
- Every port on every VM with an external address answers the internet - database ports, admin consoles, debug ports nobody remembers opening.
- Every narrow rule written since is decoration. Tightening one changes nothing, so reviews pass while nothing is protected.
- Anyone who lands on one VM can reach every other VM on any port.
2.Why it is wrong
Priority and the implied deny - a rule at 1000 is consulted long before the implied deny at 65535, so one broad allow makes every narrow rule decoration.
It sits above the implied deny at 65535, so it is consulted first and always matches. Every other ingress rule in the project is decoration.
The idea
Priority and the implied deny - a rule at 1000 is consulted long before the implied deny at 65535, so one broad allow makes every narrow rule decoration.
Learn it
- The scoping trap · GCP 5.1
- Implied rules and priority · GCP 5.1
3.How you would find it
gcloud compute firewall-rules list --format="table(name,priority,direction,sourceRanges.list(),targetTags.list(),allowed[].map().firewall_rule().list())" --filter="direction=INGRESS AND sourceRanges:0.0.0.0/0"
gcloud compute firewall-rules list --format="table( name,priority,direction,sourceRanges.list(),targetTags.list(), allowed[].map().firewall_rule().list())" \ --filter="direction=INGRESS AND sourceRanges:0.0.0.0/0"4.The change that closes it
Rule deleted. Each service keeps its own narrow rule, and the implied deny is reached again.
- As found
- allow INGRESS · 0.0.0.0/0 · all protocols · no target · priority 1000
- Fixed
- Rule deleted. Each service keeps its own narrow rule, and the implied deny is reached again.
gcloud compute firewall-rules delete allow-all # verify nothing depended on it, per VM, before deleting:gcloud compute instances network-interfaces get-effective-firewalls legacy-api-abc1 \ --network-interface=nic0 --zone=asia-southeast1-b