D16Defect 5 of 17, in the order they close

Metadata SSH keys instead of OS Login

Public keys live in project metadata, so a project-level key works on every VM.

Severity
medium
Closes in
phase 2, Secure access
Closed by
OS Login
Breaks
1 journey
  • Your VPC
  • Run by Google
  • Firewall and access rules
  • Allowed traffic
  • Where it breaks
project metadata · ssh-keysalice · ssh-ed25519bob · ssh-ed25519contractor · left in MarchD16IAM · OS Loginroles/compute.osLoginalice@harbour.examplerevoke once, gone everywherea contractor's key still opens every VMharbour-vpcevery VMbastionlegacy-api × 3rabbitmq-1trusts every key inproject metadatalogin loga key was used:SHA256:9f3c…whose? unknown

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

As foundKeys in project metadata. One key grants every VM. Cleanup is manual.

Wide by design - scroll it sideways.

Notes

open one at a time

1.

What it can cause

A key added for a contractor still opens every VM after the contract ends, until someone remembers to delete it.
  • A key added for a contractor still opens every VM after the contract ends, until someone remembers to delete it.
  • The logs show that a key was used, not who used it, so an incident cannot be traced to a person.
  • Anyone who can edit project metadata can add a key of their own and log in everywhere.
2.

Why it is wrong

OS Login ties login to IAM, so revocation is central and instant. Metadata keys tie it to nothing - a key outlives the person who owned it.

A key in metadata is just a key. Nothing links it to whether the person still works here, so access survives someone leaving until a human notices and deletes it. OS Login ties login to Google identities and IAM instead: grant roles/compute.osLogin and they can log in, revoke it and access to every VM disappears at once. Logs also show which identity logged in, rather than that a key was used. Deliberately sequenced after D2 - change the access path first and prove it, then change the login mechanism, so a failure has only one possible cause.

The idea

OS Login ties login to IAM, so revocation is central and instant. Metadata keys tie it to nothing - a key outlives the person who owned it.

3.

How you would find it

gcloud compute project-info describe --format="value(commonInstanceMetadata.items.filter(key:enable-oslogin))"
detect
gcloud compute project-info describe \  --format="value(commonInstanceMetadata.items.filter(key:enable-oslogin))" # the keys this would replacegcloud compute project-info describe \  --format="value(commonInstanceMetadata.items.filter(key:sshKeys))"
4.

The change that closes it

OS Login on. Access by roles/compute.osLogin or osAdminLogin, revoked centrally and instantly.
As found
Keys in project metadata. One key grants every VM. Cleanup is manual.
Fixed
OS Login on. Access by roles/compute.osLogin or osAdminLogin, revoked centrally and instantly.
fix
gcloud compute project-info add-metadata \  --metadata enable-oslogin=TRUE gcloud projects add-iam-policy-binding harbour-app-prod \  --member="user:someone@harbour.example" \  --role="roles/compute.osLogin" # find the keys this replaces, so they can be removedgcloud compute project-info describe \  --format="value(commonInstanceMetadata.items.filter(key:sshKeys))"
5.

When to fix it

Phase 2, Secure access - after D2

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

Cannot start until

  • D2SSH open to the internet · phase 2

Unblocks

Nothing waits on it.

6.

Journeys it breaks

An engineer opens an SSH session