|
|
|
|
|
by LethargicStud
2135 days ago
|
|
GCP supports remotely loading public ssh keys onto a box. They do this using the metadata endpoint - this is (in theory) a trusted API endpoint available to instances @ 169.254.169.254. IAM actually uses this - when you call other services, client libs reach out to the metadata endpoint and get IAM creds to send with each request. Anyway, they have a local process that polls the metadata endpoint and adds authorized keys on the host. So you can e.g. upload your public key in the web UI, their metadata endpoint will serve it up on your instance, the guest agent will poll the metadata endpoint and add your key to the authorized_keys file. These folks spoofed a response from the metadata endpoint. They used https://github.com/kpcyrd/rshijack to inject their own hand-crafted public key, which the guest agent happily added to authorized_keys (and created the wouter user). They then ssh'd using their key: > ssh -i id_rsa -o StrictHostKeyChecking=no wouter@localhost > Once we accomplished that, we had full access to the host VM (Being able to execute commands as root through sudo). Looks like they had passwordless sudo as well. |
|