You can hijack Google Cloud VMs using DHCP floods, says this guy, once the stars are aligned and...

An Ocean's 11 of exploitation involving guessable random numbers and hostname shenanigans

Google Compute Engine virtual machines can be hijacked and made to hand over root shell access via a cunning DHCP attack, according to security researcher Imre Rad.

Though the weakness remains unpatched, there are some mitigating factors that diminish the potential risk. Overall, it's a pretty neat hack if a tad impractical: it's an Ocean's Eleven of exploitation that you may find interesting from a network security point of view.

In a write-up on GitHub, Rad explains that attackers can take over GCE VMs because they rely on ISC DHCP software that uses a weak random number generator.

A successful attack involves overloading a victim's VM with DHCP traffic so that it ends up using a rogue attacker-controlled metadata server, which can be on the same network or on the other side of the internet. The DHCP flood would typically come from a neighboring attacker-controlled system hosted within Google Cloud.

When the technique is pulled off just right, the VM uses the rogue metadata server for its configuration instead of an official Google one, and ultimately the miscreant can log into the VM via SSH as the root user.

ISC's implementation of the DHCP client, according to Rad, relies on three things to generate a random identifier: the Unix time when the process is started; the PID of the dhclient process; and the sum of the last four bytes of the Ethernet addresses (MAC) of the machine's network interface cards. This random number, XID, is used by the client to track its communications with Google's DHCP servers.

So the idea is to hit the victim VM with a stream of DHCP packets, with a best guess for the XID, until the dhclient accepts them over Google's legit DHCP server packets, at which point you can configure the network stack on the victim VM to use the rogue metadata server by aliasing Google server hostnames.

Two of these XID ingredients, Rad says, are predictable. The last four bytes of the MAC address are the same as the internal IP address of the box. And the PID gets assigned by the Linux kernel in a linear way.

"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," explains Rad.

"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."

Crafting the correct XID in a flood of DHCP packets is made easier by the insufficient randomization scheme. Doing so allows the attacker to reconfigure the target's network stack at will.

Shouldn't be news to Google

According to Rad, Google relies on its metadata servers to handle the distribution of SSH keys. By impersonating a metadata server, SSH access can be granted to the attacker.

Rad's technique is based on an attack disclosed last year by security researcher Chris Moberly, but differs in that the DHCP flooding is done remotely and the XIDs are guessed.

In the three attack scenarios devised by Rad, two require the attacker to be on the same subnet as the target VM to send the flood of DHCP traffic. In one scenario, the victim VM needs to be rebooting, and in the other, it is refreshing its DHCP lease. The third allows for a remote attack over the internet but requires the firewall in front of the target VM to be fully open.

Rad concedes this third case is "probably not a common scenario" but notes that GCP Cloud console provides that option and speculates there are likely to be VMs with that configuration.

Suggested defense techniques include not referring to the metadata server using its virtual hostname (, not managing the virtual hostname via DHCP, securing metadata server communication using TLS, and blocking UDP on Ports 67/68 between VMs.

Google was said to be informed of this issue back in September 2020. After nine months of inaction, Rad published his advisory. The Chocolate Factory did not immediately respond to a request for comment. We imagine Google Cloud may have some defenses in place, such as detection of weird DHCP traffic, for one. ®

Speaking of Google, its security expert Felix Wilhelm found a guest-to-host escape bug in the Linux KVM hypervisor code for AMD Epyc processors that was present in kernel versions 5.10 to 5.11, when it was spotted and patched.

Broader topics

Other stories you might like

  • Cheers ransomware hits VMware ESXi systems
    Now we can say extortionware has jumped the shark

    Another ransomware strain is targeting VMware ESXi servers, which have been the focus of extortionists and other miscreants in recent months.

    ESXi, a bare-metal hypervisor used by a broad range of organizations throughout the world, has become the target of such ransomware families as LockBit, Hive, and RansomEXX. The ubiquitous use of the technology, and the size of some companies that use it has made it an efficient way for crooks to infect large numbers of virtualized systems and connected devices and equipment, according to researchers with Trend Micro.

    "ESXi is widely used in enterprise settings for server virtualization," Trend Micro noted in a write-up this week. "It is therefore a popular target for ransomware attacks … Compromising ESXi servers has been a scheme used by some notorious cybercriminal groups because it is a means to swiftly spread the ransomware to many devices."

    Continue reading
  • Twitter founder Dorsey beats hasty retweet from the board
    As shareholders sue the social network amid Elon Musk's takeover scramble

    Twitter has officially entered the post-Dorsey age: its founder and two-time CEO's board term expired Wednesday, marking the first time the social media company hasn't had him around in some capacity.

    Jack Dorsey announced his resignation as Twitter chief exec in November 2021, and passed the baton to Parag Agrawal while remaining on the board. Now that board term has ended, and Dorsey has stepped down as expected. Agrawal has taken Dorsey's board seat; Salesforce co-CEO Bret Taylor has assumed the role of Twitter's board chair. 

    In his resignation announcement, Dorsey – who co-founded and is CEO of Block (formerly Square) – said having founders leading the companies they created can be severely limiting for an organization and can serve as a single point of failure. "I believe it's critical a company can stand on its own, free of its founder's influence or direction," Dorsey said. He didn't respond to a request for further comment today. 

    Continue reading
  • Snowflake stock drops as some top customers cut usage
    You might say its valuation is melting away

    IPO darling Snowflake's share price took a beating in an already bearish market for tech stocks after filing weaker than expected financial guidance amid a slowdown in orders from some of its largest customers.

    For its first quarter of fiscal 2023, ended April 30, Snowflake's revenue grew 85 percent year-on-year to $422.4 million. The company made an operating loss of $188.8 million, albeit down from $205.6 million a year ago.

    Although surpassing revenue expectations, the cloud-based data warehousing business saw its valuation tumble 16 percent in extended trading on Wednesday. Its stock price dived from $133 apiece to $117 in after-hours trading, and today is cruising back at $127. That stumble arrived amid a general tech stock sell-off some observers said was overdue.

    Continue reading

Biting the hand that feeds IT © 1998–2022