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.
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.
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.
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)
- A cloud key. In a real file, this line would hold a key that can reach the company's cloud account.
- A token for the code store, which the test-coverage helper does not need.
- An outside script fetched fresh on every build. If it changes, the build runs the new version.
- 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.
- A key leaks. An error in how Codecov built a software package let the attacker extract a key to Codecov's file storage [1].
- The script is changed. From 31 January 2021, the attacker used that access to alter the uploader script [1].
- 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].
- Secrets go out. The script could send credentials, tokens and keys from those builds to an outside server [1].
- 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].

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 think | What 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:
- Software Supply Chain Security Guide
- Verifying Software Downloads for Beginners
- Secrets Rotation for Beginners
- Supply Chain Attacks for Beginners
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
- Codecov, "Bash Uploader Security Update", 15 April 2021, with later updates. https://about.codecov.io/security-update/ (accessed 2 Dec 2026).
- 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).