Sub topic 1
What counts as a secret and who you are defending against
Prerequisites
This chapter assumes you have:
- Basic Git skills and a hosted repository workflow.
- Some experience with a CI/CD system such as GitHub Actions or GitLab CI.
- Working knowledge of shell commands and environment variables.
- A general idea of what an API token or cloud credential is.
What counts as a secret
A secret is a value that grants access or proves identity, so anyone who holds it can act as you. A quick test is to ask whether someone could use the value to do something they are not allowed to do if it appeared in a public log. If the answer is yes, treat it as a secret.
| Kind | Examples | What an attacker can do |
|---|---|---|
| API tokens | Payment API key, GitHub personal access token | Call the service as you |
| Cloud credentials | AWS access key and secret key | Create, read, or delete cloud resources |
| Signing keys | Code-signing certificate, GPG key | Publish software that looks like yours |
| Connection strings | Database URL with a password | Read or change production data |
| Deploy keys and SSH keys | Private key used to push or pull | Modify repositories or servers |
Some values look sensitive but are not credentials. Account IDs, region names, public keys, and public URLs do not grant access on their own. Hiding them adds little security. The opposite mistake is more common: a password stored as a plain "config" variable in a workflow file because it did not look like a key.
Who you are defending against
A threat model lists who might attack you and what they can reach. Pipelines have more attackers than most teams expect.
- Outsiders who can read output. In a public repository, anyone can read logs, artifacts, and commit history.
- Untrusted contributors. A pull request from a fork can change code that your pipeline then runs.
- Compromised dependencies and third-party actions. Code you did not write runs inside your job.
- Over-privileged insiders. A teammate or departed employee may be able to reach secrets they do not need.
- Yourself. An accidental commit or a debug
envcommand is the most frequent leak.
The working model
The key fact is this: any code that runs in a job can read every secret given to that job. The YAML file does not protect a secret. The real boundary is which code runs and which secrets that job receives.
This shapes your defenses:
- Give each job only the secrets it needs.
- Keep secrets away from jobs that run untrusted code.
- Prefer credentials that expire quickly, so a stolen value is useful for minutes rather than months.
- Assume leaks will happen, and plan how to detect and revoke them.
The later chapters cover each of these. Here, the aim is to choose what to protect and from whom.
Common errors
- Treating "private repository" as a security boundary. Many people can still read it, and repositories are sometimes made public or forked.
- Assuming masking in logs makes a secret safe. Masking only hides exact matches in output.
- Sharing one powerful token across all pipelines, so any single leak exposes everything.
- Skipping the threat model and defending only against outsiders.
Exercise
A workflow stores the account ID 123456789012 and a database password in repository variables, both as plain text. Which one should be moved to a secret store, and which kind of actor is most likely to exploit the mistake in a public repository?
Show answer
The database password should be moved to a secret store, because it grants access. The account ID does not grant access by itself. In a public repository, an outsider who can read the workflow file, logs, or history is the most likely actor to exploit it.