498 points · by ithkuil · 5y ago · 174 comments
Companies who use that response are even worse because they know very well there is no wining move from the researcher. The company have all the responsibility no matter what.
It highlights how divisions operate in silos at Google, and just because Project Zero causes a lot of positive security marketing for Google, it doesn't seem that the quality bar is consistently high across the company.
Also, please don't forget this is still not fixed.
When it comes to others (like Microsoft) Google is always quick to publish their findings, regardless of other circumstances.
The metadata server is documented to be at 169.254.169.25, always[1]. But Google software (agents and libraries on VMs) resolves it by looking up metadata.google.internal. If metadata.google.internal isn't in /etc/hosts, as can be the case in containers, this can result in actual DNS lookups over the network to get an address that should be known.
AWS uses the same address for their metadata server, but accesses via the IP address and not some hostname[2].
I've seen Google managed DNS servers (in GKE clusters) fall over under the load of Google libraries querying for the metadata address[3]. I'm guessing Google wants to maintain some flexibility, which is why they are using a hostname, but there are tradeoffs.
[1] https://cloud.google.com/compute/docs/internal-dns
[2] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance...
[3] This is easily solvable with Kubernetes HostAliases that write /etc/hosts in the containers.
> Using a fixed IP makes it very difficult to spoof the metadata
https://github.com/googleapis/google-cloud-go/commit/ae56891...
It was not straightforward. I learned a lot about iptables and docker networking.
There might be a persistence issue, it seems like part of this attack was that the IP was persisted to /etc/hosts even after the real DHCP server took over again. But even just writing to /etc/hosts could open the door redirecting traffic to an attacker controlled server.
Real example: I have a client with precisely this situation, and elsewhere in the GCP project is PII consumer data requiring public disclosure if exposed.
This at least mitigates the the impact of this exploit to a degree. If a web server has access only to Cloud SQL, an attacker cannot use access to that VM to go digging around in Cloud Storage buckets unless GCS access is granted explicitly to the VM.
From there, IAM security applies. So even if the VM has Cloud API access to, say Big Query, the limitations of that Service Account then applies to any data that is accessed.
Servers holding PII should be firewalled off. Necessary traffic should be explicitly granted. That would remedy the issue a bit.
This is usually the case. As most of my clients use isolated GCP projects for housing PII data. This forces IAM permissions to be granted service accounts, which, hopefully, means that administrators are cognizant of the levels of access that they are granting to service accounts.
Not a guarantee, mind you, but hopefully some redflags would be raised if a someone requested PII-level access for a Service Account associated with a public facing web server.
Probably easier to create separate subnets for VMs that don't trust each other ?
> Targeting a VM over the internet. This requires the firewall in front of the victim VM to be fully open.
I mean, even if the firewall is non-existing, can you really carry a dhcp payload over the public internet?
EDIT: still haven't read the whole thing, but looks like they did test it
https://github.com/irsl/gcp-dhcp-takeover-code-exec#attack-3
It all starts with:
"Note that the last 4 bytes (0a:80:00:02) of the MAC address (42:01:0a:80:00:02) are actually the same as the internal IP address of the box (10.128.0.2). This means, 1 of the 3 components is effectively public."
BTW I just checked my corporate intranet setup and MAC has nothing to do with the ip address.
The config as designed probably looked like a good idea at the time. When you are worrying about millions of things in an address space like IPv4 and MAC, then having them tie up in some way may be useful for lookups in a very large database or two.
However, giving information away about something that was never designed from the outset to do so is not a good idea.
If you follow the chain of reasoning in the github post you can see that you can break the chain at multiple points by not "being clever". If you start by not making your IP addresses follow the MAC address you kill this problem off before it starts.
If you have anything to do with fire fighting (and we all do in a way) you soon learn that there are three things required for a fire:
* Something to burn
* Air (strictly speaking: Oxygen)
* Something to start the fire (source of ignition)
Fire prevention is based around avoiding having all three things together at any point in time. So, putting out a fire often involves removing oxygen or removing the burning thing. Prevention can be as simple as making a rule at home that no one puts dish cloths on the hob to dry. That last phrase may need some translating!So, you put your webby app or VM out on the internets for all to see and play with. Unlike your home front door, every Tom, Dick and Harry in the world can go and take a playful kick at it. So you need to take some care with it. There is no simple set of three factors that you can protect against as there is for fire prevention. Instead you need to follow some good practice and hope for the best.
One good (not best - there is no such thing) practice is to avoid giving away information unnecessarily. Linking IP to MAC is such a thing. Do it at home if you must but don't do it in public.
I'm not sure I even understand the impulse behind writing a comment like this. Assume Google simply refuses to apply the P0 disclosure rule to themselves (this isn't the case, but just stipulate). Do you want them to stop funding Project Zero? Do you wish you knew less about high profile vulnerabilities?
So the Zero timeline applies to everyone the same. It doesn't mean fixes actually happen on the same timeline.
Yes, sometimes other Google teams miss the deadline set by Project Zero too. That's not the point.
[0] https://github.com/irsl/gcp-dhcp-takeover-code-exec#timeline
Project Zero probably doesn't care or doesn't even accept the bounties
So I just don't see the inconsistency here. Project Zero gives a disclosure deadline. The reporter here chose not to give one. When they said they wanted to disclose, there was no stalling for extra time. Just what is the expectation here?
if [ -n "$new_host_name" ] && [ -n "$new_ip_address" ]; then
with this:
if [ -n "$new_host_name" -a ! "$new_host_name" =~ metadata.google.internal ] && [ -n "$new_ip_address" ]; then
(Yes, =~ is a bashism, but google_set_hostname is a bash script.)
This prevents /etc/hosts from getting poisoned with a bogus entry for the metadata server. Of course, dhcpd should also be fixed to use a better random number generator, and the firewall should be default stop dhcp packets from any IP address other than Google's DHCP server. Belt and suspenders, after all. But fixing the dhclient exit hooks is a simple text edit.
It would be much better if, instead of the network, these metadata servers were only visible as a PCIe or MMIO device. Of course, that would require a driver to be written, so at least initially, unmodified distributions would not be able to be used (but after a few years, every Linux and BSD distribution, and perhaps even Windows, would have that driver by default). That way, it would (on Linux) appear as files on /sys, readable only by root, without requiring any local firewall.
I wasn't aware of this single point of failure
It would seem simple enough for googles metadata server to have a valid HTTPS certificate and be hosted on a non-internal domain. Or use an internal domain, but make pre-built images use a custom CA.
Or Google could make a 'trusted network device', rather like a VPN, which routes traffic for 169.254.169.254 (the metadata server IP address) and add metadata.google.internal to the hosts file as 169.254.169.254.
Not mTLS, but AWS metadata v2 has moved to an authenticated session-based system. Of course, an attacker who can make arbitrary requests can create tokens for limited sessions, but it's certainly an improvement.
There's clearly a communication gap between the researcher and Google. But perhaps the techies at Google saw it and fixed it and it just hasn't been communicated, or some other change in GCE has closed it or mitigated it?
https://github.com/irsl/gcp-dhcp-takeover-code-exec#attack-s...
The attack is unlikely to succeed unless the attacker knows the exact time a particular VM was last rebooted, or can cause a reboot.
Overall, this attack alone probably won't be the reason you will have to start filling in a GDPR notification to your users...
I don't know what exactly he expected us to "see later," except that he knows exactly when the target machine rebooted down to a 15 second window because he already had full control over it before starting the attack...
Or they could flood the machine with requests, hoping to cause some monitoring system or human to reboot it.
But overall, it seems unlikely...
See all mentions of "Attack #2"
> a day of unixtime + potential pids makes ~86420 potential XIDs, this is a feasible attack vector.
The number of potential XIDs isn't timestamp PLUS pid, it's timestamp TIMES pid, right?
Totaling not "~86420" but 2,160,000, right?
But where does he get "a day" from? How does he know the target wasn't booted yesterday, or a month ago?
You still have somebody in your network though, so there's that.
> The firewall/router of GCP blocks broadcast packets sent by VMs, so only the metadata server (169.254.169.254) receives them. However, some phases of the DHCP protocol don't rely on broadcasts, and the packets to be sent can be easily calculated and sent in advance.
> To mount this attack, the attacker needs to craft multiple DHCP packets using a set of precalculated/suspected XIDs and flood the victim's dhclient directly (no broadcasts here). If the XID is correct, the victim machine applies the network configuration. This is a race condition, but since the flood is fast and exhaustive, the metadata server has no real chance to win.
> Google heavily relies on the Metadata server, including the distribution of ssh public keys. The connection is secured at the network/routing layer and the server is not authenticated (no TLS, clear http only). The google_guest_agent process, that is responsible for processing the responses of the Metadata server, establishes the connection via the virtual hostname metadata.google.internal which is an alias in the /etc/hosts file.
He appears to spoof the DHCP packets to get the victim to respond to his rogue metadata server, insert the IP address of his metadata server into the /etc/hosts entry for metadata.google.internal, then is able to have his ssh pubkey installed on the victim so he can ssh to the host.
The way it works for physical hosts is that all machines in the same rack see the dhcp traffic and the TOR has a special ip helper configured where it's sending the DHCP traffic. So it's broadcast in the rack and after that point to point, but still there is zero to no security when it comes to DHCP traffic.
For VMs, I guess the hypervisor acts as the TOR with the same limitations.
Does that exist? In my book, if you're security conscious, you can only do self-hosting whether on premises or in your own bay in a datacenter.
Giving away your entire computing and networking to a third party such as Google is orthogonal to security.
There are plenty of ways to do zero trust networking, a slick commercial implementation is https://tailscale.com/, which you can totally use in the cloud for secure node to node comms if you're worried about those things.
Google's current confidential compute offering does not prove at runtime that it's actually confidential. You just get a bit in your cloud console saying 'yep it's confidential' (and some runtime CPU bit too, but that's easily spoofable by a compromised hypervisor), but no cryptographically verifiable proof from AMD that things actually are confidential.
But you know this for metropolis, right? :)
All these measures are not feasible unless you are working in national security or a Megacorp, and insisting on one of them, while ignoring others, is daft
A threat model has no basis in reality if you do not accurately model threats, and your infra vendor is a glaringly obvious threat. Now, maybe that's a risk worth the tradeoffs, but how do you know that?