Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 459

Hardcoded Secrets in Code

What is Hardcoded Secrets in Code?

Hardcoded Secrets in CodeEmbedding credentials, API keys, tokens, or cryptographic material directly in source code, configuration files, or container images, where they are easily discovered and abused.


Hardcoded secrets are one of the most common and damaging mistakes in modern development. They end up in Git history, container layers, mobile apps, CI logs, and public repositories, where bots scan them within minutes. Real-world exposures include AWS keys committed to GitHub, Slack tokens in client-side bundles, and database passwords baked into Docker images. Mitigations combine prevention (developer education, pre-commit hooks, IDE plugins, .gitignore patterns), detection (secret scanning in repos and CI such as GitHub secret scanning, Gitleaks, TruffleHog), and centralised secret management (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, Kubernetes External Secrets). When detected, secrets must be rotated immediately, not just deleted from history.

Examples

  1. 01

    AWS access key committed to a public GitHub repository and abused within minutes.

  2. 02

    OAuth client secret embedded in a mobile app binary.

Frequently asked questions

What is Hardcoded Secrets in Code?

Embedding credentials, API keys, tokens, or cryptographic material directly in source code, configuration files, or container images, where they are easily discovered and abused. It belongs to the Application Security category of cybersecurity.

What does Hardcoded Secrets in Code mean?

Embedding credentials, API keys, tokens, or cryptographic material directly in source code, configuration files, or container images, where they are easily discovered and abused.

How does Hardcoded Secrets in Code work?

Hardcoded secrets are one of the most common and damaging mistakes in modern development. They end up in Git history, container layers, mobile apps, CI logs, and public repositories, where bots scan them within minutes. Real-world exposures include AWS keys committed to GitHub, Slack tokens in client-side bundles, and database passwords baked into Docker images. Mitigations combine prevention (developer education, pre-commit hooks, IDE plugins, .gitignore patterns), detection (secret scanning in repos and CI such as GitHub secret scanning, Gitleaks, TruffleHog), and centralised secret management (HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, Kubernetes External Secrets). When detected, secrets must be rotated immediately, not just deleted from history.

How do you defend against Hardcoded Secrets in Code?

Defences for Hardcoded Secrets in Code typically combine technical controls and operational practices, as detailed in the full definition above.

What are other names for Hardcoded Secrets in Code?

Common alternative names include: Hardcoded credentials, Secret leakage in code.

Related terms

See also