Hardcoded secret

A hardcoded secret is a password, API key or access token written directly into a site's code or files. If that code reaches a browser or a public repository, anyone can copy the secret and use your account.

Why it matters

Leaked secrets are growing fast. GitGuardian found 28.65 million new hardcoded secrets in public GitHub commits in 2025, a 34% rise on 2024.1 Secrets for AI services alone rose 81%, to 1,275,105, in its data.1

A key in front-end code is a published key. Someone who finds it can run up your bill, send email in your name or read your data.

In practice

  • Keep secret keys on the server or in the platform's secrets vault.
  • Search the code for secret, api_key, token and sk_ before launch.
  • Revoke any key that was ever in public code, even briefly.
  • Give each tool its own key, so you can revoke one.
  • Turn on secret scanning in your code repository.

What the sources say

What to do about hardcoded secret, depending on who you are

If you built the site with an AI tool

AI tools often paste keys into front-end code to make a feature work. GitGuardian counted 1,275,105 leaked AI service secrets in 2025, up 81% in a year.

  1. Search the project for key-like strings before launch.
  2. Move any secret to the server or the platform vault.
  3. Revoke and replace every key that was exposed.

Vibe-coded website security

If you manage a team's code

Most leaks happen in ordinary commits. Catching them before they're pushed costs far less than rotating keys afterwards.

  1. Turn on secret scanning and push protection in the repository.
  2. Keep keys in environment variables, never in config files.
  3. Rotate keys on a schedule.

Go deeper

My guide to vibe-coded website security shows where AI tools tend to leave keys and how to check.

Vibe-coded website securityAll 106 terms

Sources

  1. "The State of Secrets Sprawl 2026," GitGuardian, 17 March 2026. Vendor research. blog.gitguardian.com

Related terms

Row-level security

Row-level security is a database feature that decides, row by row, who may read, add, change or delete data. In apps built on Supabase or Postgres, it's what stops one user, or anyone on the internet, from reading everyone else's records.

Learn the term

Least privilege

Least privilege is the security rule of giving every person, tool or AI assistant only the access its job needs, and nothing more. If that access is misused or stolen, the damage stays small.

Learn the term

Model Context Protocol (MCP)

The Model Context Protocol, or MCP, is an open standard for connecting AI assistants to the tools and data where work happens. An MCP server exposes a system, such as a store, a CRM or a document folder, so an assistant like Claude can read it and act in it.

Learn the term

Want this done for you?

Worried a key is sitting in your site's code? Book a call and I'll help you find it.

Twenty minutes and nothing to sign. The three changes are yours to keep either way.

Book a 20-minute call