Join our Newsletter — 33% off our NHI Course
Home› Guides› The Codecov Breach for Beginners: How a Changed…
Guide Software & AI Supply Chain

The Codecov Breach for Beginners: How a Changed Script Quietly Stole Developer Secrets

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 2 December 2026 10 min read
On this page

The Codecov breach was a 2021 attack where a widely used helper script was secretly changed to copy secrets.

This guide is for anyone who works with developers, manages a software team or is new to IT work. You do not need to write code. If your business builds software, or pays someone who does, the lesson applies to you.

In short

  • Codecov offered a small script that customers downloaded and ran in their automated build systems [1].
  • From 31 January 2021, an attacker changed that script so it could send out secrets from those build systems [1].
  • A customer spotted it on 1 April 2021, because the script's fingerprint no longer matched the published one [1].
  • Lessons: check downloads before running them, give build tools only the secrets they need, and change secrets fast after a warning.

What you will learn

  • Explain what happened in the Codecov breach in plain words.
  • Describe why running a script straight from the internet is risky.
  • Check whether your team verifies the scripts it downloads.
  • Ask which secrets your build systems can see.
Automatic build line (CI/CD pipeline)
the system that tests and packages code every time a developer saves a change to the shared project.
File fingerprint (checksum)
a short code worked out from a file's contents; if the file changes, the code changes too.
Settings with secrets (environment variables)
named values, often keys and tokens, that a program can read while it runs.

What is the Codecov breach?

Think of a recipe card that a busy kitchen collects fresh from a noticeboard every morning. One night, someone quietly rewrites a line. Every cook follows it, because the card has always been right.

Codecov is a service that shows developers how much of their code is tested. To send results to Codecov, many customers used a small script called the Bash Uploader. Their build systems fetched it and ran it on every build [1].

Codecov says an error in how it built one of its software packages let an attacker extract a key. That key allowed the attacker to change the uploader script [1]. The changed script could send information from customers' build systems to a server outside Codecov [1].

Where the comparison stops working: a cook might notice a strange line on a card. A computer runs the script without reading it, so nobody notices unless they check.

Why does it matter?

Build systems often hold powerful keys, such as keys to cloud accounts or code stores. Any script that runs there can usually read them.

If you manage a software team

What could happen: a helper tool in your build system is tampered with, and every key it can see is copied.

Check this: ask which outside scripts your builds download and run each time.

Next: CI/CD Pipeline Security for Beginners

If you are new to IT work

What could happen: you copy a setup line from a website that downloads and runs a script with no check.

Check this: look for a published fingerprint or signature, and compare it before running anything.

Next: Verifying Software Downloads for Beginners

If you pay an outside developer

What could happen: your cloud keys sit in their build system, where any tool they use can read them.

Check this: ask how they limit the keys their builds can see, and how fast they can change them.

Next: CI/CD Pipeline Identities for Beginners

What does it look like?

Here is a made-up build settings page, written in plain words. It shows the pattern that made the Codecov attack so effective.

Example only. All values are made up.

Build job: EXAMPLE-app
Secrets available to every step:
  CLOUD_KEY     = FAKE-0000-EXAMPLE        (1)
  CODE_TOKEN    = EXAMPLE-TOKEN-0000       (2)
Steps:
  1. Run tests
  2. Fetch helper script from example.invalid and run it   (3)
     Fingerprint check: none               (4)
  1. A cloud key. In a real file, this line would hold a key that can reach the company's cloud account.
  2. A token for the code store, which the test-coverage helper does not need.
  3. An outside script fetched fresh on every build. If it changes, the build runs the new version.
  4. No check that the script is the one the supplier published.

Why this is risky: every step can read every secret, and the outside script is trusted without a check.

The safer way: check the script's fingerprint before it runs, or keep a checked copy. Give each step only the secrets it needs.

How does it work?

Here is the chain, as Codecov described it.

  1. A key leaks. An error in how Codecov built a software package let the attacker extract a key to Codecov's file storage [1].
  2. The script is changed. From 31 January 2021, the attacker used that access to alter the uploader script [1].
  3. Customers run it. Build systems that fetched the script ran the changed version. Codecov's related add-ons for other build services used the same script [1].
  4. Secrets go out. The script could send credentials, tokens and keys from those builds to an outside server [1].
  5. A fingerprint check catches it. On 1 April 2021, a customer saw that the script's fingerprint did not match the one published on GitHub, and told Codecov [1].
Diagram titled How a changed script copied build secrets. Five boxes in a row joined by arrows: 1, a storage key leaks from Codecov's packaging process; 2, the uploader script is altered from 31 January 2021; 3, customers' build systems fetch and run the new copy; 4, keys and tokens can be sent to an outside server; 5, on 1 April 2021 a customer's checksum check shows a mismatch. A footer lists the fixes: check fingerprints before running scripts, give each build step only the secrets it needs, change secrets quickly after a warning.
Figure 1. The changed script ran for about two months until one customer's check caught it.

Codecov published its notice on 15 April 2021. It told affected users to immediately change all the credentials, tokens and keys in their build settings [1]. Codecov also said users who had not checked the fingerprint during that time should treat their build secrets as possibly exposed [1].

The keys in this story are non-human identities. One leaked key let the attacker change the script. The script then put many more keys at risk. Some customers later reported that keys were exposed. For example, HashiCorp said a key it used to sign its software downloads was exposed, and it replaced that key [2].

A worked example

This story is made up to show the idea.

Hugo Okafor runs a small web agency with four developers. Their build system runs tests on every change. After reading about Codecov, Hugo sits down with his lead developer to look at it.

They find three outside scripts that the build fetches fresh every time. None is checked. One is a test helper that nobody has looked at in two years.

They also find that every step in the build can see every secret. That includes the key to the agency's cloud account and a token that can change client code.

Hugo's developer makes two changes. First, each outside script is now checked against the fingerprint its supplier publishes. If the fingerprint does not match, the build stops and alerts the team. Second, the test steps no longer see the cloud key. Only the final step, which uploads the finished site, can use it.

Hugo adds one more thing: a short list of every secret the build uses, with who can change each one. If a supplier ever reports a problem, the team knows exactly what to change and in what order.

A month later, a fingerprint check fails. It turns out the supplier had simply released a new version. The team reviews it, updates the expected fingerprint and carries on. Hugo sees the alert as proof that the check works.

Myths and mistakes

What people thinkWhat is true
A script from a well-known company is safe to run unchecked.The Codecov script came from the real supplier but had been changed by an attacker [1].
Checking fingerprints is a waste of time.A fingerprint check is how a customer caught the Codecov change [1].
Every build step needs every secret.Most steps need few or none. Limit each step to what it uses.
Once the supplier fixes the script, we are fine.Secrets already copied still work. Codecov told users to change them [1].
Build systems are internal, so they are low risk.Build systems often hold some of the most powerful keys a company has.

What can I do this week?

  • Ask your developers which outside scripts your builds download and run.
  • Check that each one is verified against a published fingerprint or signature.
  • List the secrets your build system holds and which steps can read them.
  • Remove one secret from a step that does not need it.
  • Write down who would change each build secret if a supplier warned you.

Checklist

  • We know which outside scripts our builds run.
  • Outside scripts are checked before they run, or kept as checked copies.
  • Each build step sees only the secrets it needs.
  • We keep a list of build secrets and their owners.
  • We can change all build secrets quickly.
  • We follow security notices from the tools our builds use.
  • Outside developers we pay follow the same rules.

Common questions

How long was the script changed for?

Codecov says the changes started on 31 January 2021. A customer reported a fingerprint mismatch on 1 April 2021, and Codecov fixed the script that day [1]. So the changed script was available for about two months.

What is a checksum, and how did it help?

A checksum is a short code worked out from a file. If even one character changes, the code changes. Codecov published the expected code. One customer compared it with the code of the file they downloaded, saw a mismatch and raised the alarm [1].

What did Codecov tell customers to do?

Codecov told affected users to immediately change all the credentials, tokens and keys in their build settings. It also suggested checking which secrets the build could see and reviewing how those secrets had been used [1].

Were other companies affected?

Some Codecov customers published their own notices. HashiCorp, for example, said its key for signing software downloads was exposed. It replaced the key and said it found no sign that its software had been changed [2].

Why is this a non-human identity story?

Every secret in the story belongs to software, not a person. A storage key let the attacker change the script. The script then reached cloud keys and tokens in customers' builds. Protecting and limiting these machine secrets is the main lesson.

Where next?

Ready for the detail? Read the breach analysis: Codecov Breach 2021. It sets out the full timeline, the downstream companies affected and the pipeline lessons in more depth [1].

Also useful:

Related NHI Mgmt Group resources: Non-Human Identities for Beginners, Leaked Secret Response for Beginners and Secrets Management for Beginners.

Key terms

CI/CD pipeline
The automated system that builds, tests and releases code.
Checksum
A short code worked out from a file, used to check the file has not changed.
Environment variables
Named settings a program reads while it runs, often holding keys and tokens.
Software supply chain attack
An attack that tampers with trusted software or tools so that harm reaches their users.
Credential rotation
Replacing a key or password with a new one so the old copy stops giving access.
Non-human identity (NHI)
A digital identity used by software, such as a service account, API key or token, rather than a person.

Sources and further reading

  1. Codecov, "Bash Uploader Security Update", 15 April 2021, with later updates. https://about.codecov.io/security-update/ (accessed 2 Dec 2026).
  2. HashiCorp, "HCSEC-2021-12: Codecov Security Event and HashiCorp GPG Key Exposure", 22 April 2021. https://discuss.hashicorp.com/t/hcsec-2021-12-codecov-security-event-and-hashicorp-gpg-key-exposure/23512 (accessed 2 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.