D2Defect 3 of 17, in the order they close

SSH open to the internet

Port 22 allowed from 0.0.0.0/0 on every VM.

Severity
high
Closes in
phase 2, Secure access
Closed by
IAP TCP forwarding
Breaks
1 journey
  • Your VPC
  • Run by Google
  • Firewall and access rules
  • Allowed traffic
  • Where it breaks
outside GCPAnyoneport scanners, botsEngineerSSH from homewith a keyIAPchecks identity35.235.240.0/20firewall · ingresstcp:22from 0.0.0.0/0every VMD2harbour-vpcevery VMbastionlegacy-api × 3rabbitmq-1port 22 openguessing keys, around the clock

Only what D2 touches. Red is the defect and what it lets through; switch to fixed to see the same parts with only D2 closed. Struck IDs are closed.

As foundallow INGRESS · tcp:22 · source 0.0.0.0/0 · target all instances

Wide by design - scroll it sideways.

Notes

open one at a time

1.

What it can cause

Every VM with a public address takes key and password guessing from the whole internet, around the clock.
  • Every VM with a public address takes key and password guessing from the whole internet, around the clock.
  • One leaked or reused key is a shell in production, from anywhere.
  • The logs fill with failed attempts, so the one that succeeds is hard to see.
2.

Why it is wrong

Identity-based access beats network-based access. The fix is not a narrower IP list, it is removing the public port.

The fix is not a narrower IP list, it is removing the need for a public SSH port at all. IAP tunnels SSH through Google after an identity check, and all its traffic arrives from one fixed range - so the firewall narrows the network path to IAP only, and IAP narrows access to authorised identities only. Two narrow layers replacing one wide-open one. Three independent things must all be true for it to work: the iap.googleapis.com API enabled, roles/iap.tunnelResourceAccessor on the identity, and this firewall rule. roles/editor does not include the tunnel role.

The idea

Identity-based access beats network-based access. The fix is not a narrower IP list, it is removing the public port.

3.

How you would find it

gcloud compute firewall-rules list --filter="allowed.ports:22 AND sourceRanges:0.0.0.0/0"
detect
gcloud compute firewall-rules list \  --filter="allowed.ports:22 AND sourceRanges:0.0.0.0/0"
4.

The change that closes it

allow INGRESS · tcp:22 · source 35.235.240.0/20 · priority 900
As found
allow INGRESS · tcp:22 · source 0.0.0.0/0 · target all instances
Fixed
allow INGRESS · tcp:22 · source 35.235.240.0/20 · priority 900
fix
# ORDER MATTERS. You are changing how you reach the box while using that# same access to make the change. Add and verify before deleting anything. # 1. Additive. Opens nothing new - that range is only reachable after#    IAP has already checked your identity.gcloud compute firewall-rules create allow-ssh-from-iap \  --network=harbour-vpc --direction=INGRESS --action=allow \  --rules=tcp:22 --source-ranges=35.235.240.0/20 --priority=900 # 2. VERIFY on every VM. Not optional - this is what stands between#    "SSH is now secure" and "nobody can SSH to production".gcloud compute ssh bastion --zone=asia-southeast1-b \  --tunnel-through-iap --command="echo ok" # when it fails, this checks all three requirements at once:gcloud compute ssh bastion --zone=asia-southeast1-b \  --tunnel-through-iap --troubleshoot # 3. ONLY after every VM verifies.gcloud compute firewall-rules delete default-allow-ssh
5.

When to fix it

Phase 2, Secure access

Phase 2, Secure access, together with D3a and D16. Depends on nothing, and everything after it is safer once administrative access no longer runs over a public SSH port.

Cannot start until

Nothing. It can start as soon as its phase does.

Unblocks

  • D3aBastion carries an external IP · phase 2
  • D16Metadata SSH keys instead of OS Login · phase 2
  • D1One allow rule opens everything · phase 6
6.

Journeys it breaks

An engineer opens an SSH session