Project-Wide SSH Keys Allowed
Instances accept SSH keys stored in project-wide metadata, so a single key, or anyone able to edit project metadata, gains access to every Linux instance in the project.
| Severity | Low |
| CVSS 3.1 | 3.3 CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:L/I:L/A:N Open in the calculator |
| CVSS 4.0 | 2.1 CVSS:4.0/AV:N/AC:L/AT:P/PR:H/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-1220: Insufficient Granularity of Access Control |
| MITRE ATT&CK | T1098.004 SSH Authorized Keys, T1021.004 SSH |
| Category | Security Misconfiguration |
Description
Where Compute Engine instances use metadata-managed SSH keys rather than OS Login, keys can be stored in instance metadata, which applies to one instance, or in project metadata under ssh-keys, which applies to every Linux instance in the project. An instance accepts project-wide keys unless its metadata sets block-project-ssh-keys to TRUE. Where project-wide keys are not blocked, gcloud compute ssh adds the user's key to project metadata by default, so keys accumulate there as people connect to different instances.
The finding applies where instances, particularly sensitive ones, accept project-wide keys. Each key in project metadata then grants access to every Linux instance in the project, typically with sudo rights, including those that should be reachable only by a small team, so an attacker who obtains any listed private key, or any principal able to edit project metadata and add a key, can sign in to all of them. A single compromised key or workstation therefore exposes the whole project rather than one instance.
The list is rarely reviewed, so it often contains keys of former staff and contractors, and removing a departed user's access means finding their key among many. Exploitation requires a valid private key or metadata permissions, as well as network access to the instances' SSH port.
The finding is identified by listing project metadata with gcloud compute project-info describe and checking each instance's metadata for block-project-ssh-keys. The issue does not arise where OS Login is enforced, since metadata keys are then ignored.
Remediation
- Prefer OS Login, enforced through the
constraints/compute.requireOsLoginorganisation policy constraint, so that SSH access is granted through IAM and metadata keys are ignored. - Where metadata keys must still be used, set
block-project-ssh-keystoTRUEon each instance, and add only the keys that instance needs to its own metadata. - Remove the
ssh-keysentries from project metadata once no instance relies on them, and check any that remain against current staff and systems. - Restrict who can change project metadata, and monitor the Admin Activity audit logs for metadata changes.
Confirm the fix by checking each instance's metadata, and by attempting to sign in to a protected instance with a key held only in project metadata, expecting the sign-in to fail.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.