Secrets management for a small team: where keys live, how they leak, how to check

Secrets management is how a team stores, shares, rotates and revokes its API keys, database passwords and signing secrets. For a small team: keep secrets in the host's environment settings or a vault, never under a NEXT_PUBLIC_ or VITE_ name, turn on GitHub secret scanning and push protection, rotate on a procedure you have tried, and check the deployed JavaScript, because that is where a leaked key is public.

The team behind Keybrum's attacksUpdated 11 min read

In short

  • A secret has three places it should never be: the repository, a prompt, and the browser. The third is the one teams check least.
  • In Next.js, a variable whose name starts with NEXT_PUBLIC_ is inlined into the JavaScript bundle at build time. In Vite, the same holds for VITE_, and Vite's docs say such variables "should not contain sensitive information such as API keys".
  • GitHub secret scanning runs automatically and at no charge on public repositories. Private repositories owned by an organization need GitHub Secret Protection, a paid add-on for Team and Enterprise plans.
  • Secret scanning reads the repository. It does not read what your site serves. A key that reached the bundle through a build variable is found by fetching the live JavaScript.
  • A leaked key stays usable until the provider rejects it. GitGuardian retested secrets it had confirmed valid in 2022 and found more than 64% still valid in January 2026.
On this page

What secrets management is

A secret is any value that gives access when presented: an API key, a database password, a webhook signing secret, a private key, a service account file. Secrets management is everything you do with those values over their life: where they are stored, who and what can read them, how they get to the running app, how often they change and how fast you can revoke one.

The scale of the problem is measured every year. GitGuardian's State of Secrets Sprawl 2026 reports 28.65 million new hardcoded secrets added to public GitHub commits in 2025, a 34% increase over the year before. The same report looked at commits made with an AI assistant: Claude Code-assisted commits showed a 3.2% secret-leak rate against a 1.5% baseline across all public commits. GitGuardian adds that this should not be read as a simple tool failure, since a person still decides what gets pushed. The point for a small team is plain: the faster code is written, the more often a key ends up where it should not be.

Enterprise guides answer with vault clusters and dynamic credentials. A team of one to ten needs less, done consistently. This page covers that smaller set.

Where secrets should live

PlaceUse it forWatch out for
.env.local on your machineDevelopment keys onlyIt must be ignored by git. Vite's docs describe .env.local as "loaded in all cases, ignored by git", and the default create-next-app template adds all .env files to .gitignore
The host's environment settingsProduction and preview keys for one appMark them as secrets. On Vercel, a variable of type Secret is write-only after saving. On Netlify, flag it with "Contains secret values"
The backend platform's secret storeKeys used by edge functions and scheduled jobsThe same key should not also be pasted into the frontend project
A secrets manager or vaultSeveral services, several people, or a need for an access logOne more system to protect: its own access needs multi-factor authentication
A password managerDashboard logins and recovery codesIt does not deliver keys to a running app

And where they should never live: in the code, in a committed .env file, in a chat message, in a screenshot, in a ticket, or in a prompt to a coding agent. Agents read your files and your terminal. Give them the name of the variable, and let the host supply the value. Lovable's documentation says it detects API keys pasted into the project chat and directs you to store them in Secrets, with the calls made on the server.

The OWASP Secrets Management Cheat Sheet adds two rules that cost nothing. Least privilege: "Secrets must have the minimum privileges assigned to them to enable their required use/role." Use a restricted key where the provider offers one. And separation: production and development never share a key, so that a leak from a laptop does not open production. Vercel has a team policy for it, Separate Production Secret Values, which refuses a Secret whose production value equals another environment's.

The prefixes that ship a value to the browser

This is the leak that surprises people who did everything else right. The key is in the host's settings, never in the repository, and it is still public, because of its name.

FrameworkPrefixWhat the documentation says
Next.jsNEXT_PUBLIC_Variables without the prefix "are only available in the Node.js environment". With it, Next.js will "inline" the value "at build time, into the js bundle that is delivered to the client"
ViteVITE_"Variables prefixed with VITE_ will be exposed in client-side source code after Vite bundling." They "should not contain sensitive information such as API keys"

Other frameworks have their own prefix with the same effect. The API key exposed in frontend guide lists them and sorts keys into those built to be public and those that never are.

bash
# Public by design: fine under a public prefix
NEXT_PUBLIC_SUPABASE_URL=https://abcd.supabase.co
VITE_STRIPE_PUBLISHABLE_KEY=pk_live_...

# Secret: the prefix makes it public. Never do this
NEXT_PUBLIC_OPENAI_API_KEY=sk-...
VITE_SUPABASE_SERVICE_ROLE_KEY=eyJ...

# Secret: no prefix, read only by server code
OPENAI_API_KEY=sk-...
SUPABASE_SERVICE_ROLE_KEY=eyJ...
STRIPE_WEBHOOK_SECRET=whsec_...
Wrong and right names in a host's environment settings.

GitHub secret scanning and push protection: what is free today

GitHub has two features that catch secrets in a repository. Secret scanning looks for known key formats in what is already there. GitHub's documentation says it scans the entire git history on all branches, and also issues, pull requests, discussions and wikis. Push protection blocks a push that contains a secret before it lands. We checked on 13 November 2026 what each costs.

RepositorySecret scanningPush protection
Public"Secret scanning runs automatically for free"Available without the paid product. Push protection for users is on by default and stops you from pushing secrets to public repositories
Private or internal, owned by an organizationRequires GitHub Secret Protection, on GitHub Team or GitHub Enterprise CloudRequires GitHub Secret Protection. Disabled by default: turn it on

GitHub lists Secret Protection as an add-on at 19 US dollars per active committer per month. To turn push protection on for a repository: Settings, then Advanced Security in the sidebar, enable Secret Protection if needed, then enable Push protection. For some key formats GitHub also tells the provider directly. Its documentation calls these partner secrets, which "are reported directly to the provider" so that it can act, for example by revoking the key.

Know the limits. Anyone with write access can bypass a push protection block by giving a reason, unless you set up delegated bypass. Scanners match known formats, so a password you invented has no pattern to match. And scanning reads the repository only, which brings us to the check most teams skip. If you do not want to pay for a private repository, open-source scanners run in a pre-commit hook or in CI at no licence cost.

Check the deployed bundle, where a leak is actually public

A secret in a private repository is exposed to your team. A secret in the JavaScript your site serves is exposed to everyone. The second can happen with a perfectly clean repository: the value came from the host's settings, through a public prefix, at build time. No repository scanner sees it. The only reliable check reads what the live site sends.

  1. 1

    List the scripts your site serves

    Open your app in a browser, open the developer tools, and reload with the Network tab filtered on JS. Those files are what every visitor downloads.

  2. 2

    Search them for secret formats

    Search across the loaded files for sk_live_, sk-, whsec_, service_role, AKIA and -----BEGIN. The command below does the same from a terminal for your own site.

  3. 3

    Name what you found

    Paste a suspicious file into the API key leak checker. It names each key, says whether it is public by design or secret, and gives the rotation steps. Legacy Supabase keys are signed tokens, so the role is not readable at a glance: the Supabase key checker tells an anon key from a service role key.

  4. 4

    Check the files next to the bundle

    Request /.env and a source map such as /assets/index.js.map on your own domain. Both should return 404. See the exposed env file guide.

bash
APP=https://your-app.example
curl -s "$APP" | grep -oE '[A-Za-z0-9_./-]+\.js' | sort -u | while read -r f; do
  case "$f" in
    http*) u="$f" ;;
    /*)    u="$APP$f" ;;
    *)     u="$APP/$f" ;;
  esac
  curl -s "$u" \
    | grep -oE 'sk_live_[A-Za-z0-9]{6}|sk-(ant|proj)-[A-Za-z0-9_-]{6}|whsec_[A-Za-z0-9]{6}|AKIA[A-Z0-9]{8}|-----BEGIN [A-Z ]*PRIVATE KEY' \
    | sort -u | sed "s|^|$u  |"
done
Search the JavaScript your own site serves for common secret formats. Replace the address with yours.

Some hosts help at build time. Netlify's Secrets Controller scans the repository code and the build output for the values you flagged as secret, and its documentation says that if it finds one, "it fails the build and adds the location of the secret values to the deploy log". Vercel redacts Secret values of 32 characters or more from build logs. Use both, and still check the live result.

Rotation: a procedure you have tried once

OWASP's cheat sheet gives the reason in one sentence: "You should regularly rotate secrets so that any stolen credentials will only work for a short time." Stolen keys stay valid far longer than people assume. GitGuardian retested the secrets it had confirmed valid in 2022, and in January 2026 more than 64% of them still worked.

  1. Create a new key at the provider, with the smallest permissions that work.
  2. Put it in the host's settings for the right environment and redeploy. Remember that values under a public prefix are fixed at build time, so a redeploy means a new build.
  3. Confirm the app works with the new key.
  4. Revoke the old key at the provider. Deleting it from your settings or your code does not revoke it.
  5. Call the provider with the old key and confirm it is rejected.
  6. Write the date next to the key in your inventory.

Rotate at once when a key appeared anywhere public, when someone with access leaves, and when a tool that held the key is dropped. For the rest, pick a rhythm you will keep: a calendar reminder every quarter beats a yearly plan nobody follows. If the key has already leaked, follow what to do when an API key leaks, which gives the order per provider.

Keep a small inventory: the key's name, what it opens, where it is stored, who owns it and when it was last rotated. A dozen lines in a document is enough. The day something leaks, that list is the difference between ten minutes and an afternoon.

What Keybrum checks about secrets, and what it does not

Keybrum is the automated attack test we build for apps made with AI tools. On secrets, it works on the deployed app, which is the part repository scanners do not see. It reads everything the app serves and looks for provider keys: AI providers, Stripe, the Supabase service role, private keys and many others. Each key found is checked with a harmless read-only call, so the report says whether it is live. It requests .env files, .git folders, source maps and backup files. It looks for keys stored in database tables and Firestore documents that a visitor can read, and in API answers. It also tries weak or default JWT signing secrets on Supabase.

Each finding comes with the request that worked, and your coding agent reads the fix through Keybrum's MCP server. Plans, from €29 a month excluding VAT, attack every deploy, which is when a renamed variable reaches the bundle. A one-time report on one app is €49.

Questions

What is secrets management in simple terms?

It is the set of habits that keep API keys, passwords and signing secrets out of places where others can read them: stored in the host's settings or a vault, given the smallest permissions, different in production and development, rotated on a schedule and revoked fast when one leaks.

Is GitHub secret scanning free?

On public repositories, yes: GitHub's documentation says it runs automatically for free. On private or internal repositories owned by an organization, it requires GitHub Secret Protection, a paid add-on available on GitHub Team and GitHub Enterprise Cloud, listed at 19 US dollars per active committer per month when we checked on 13 November 2026.

What is the difference between secret scanning and push protection?

Secret scanning finds secrets already in the repository, including its history, and raises an alert. Push protection checks a push before it is accepted and blocks it if it contains a known secret format. The first tells you to rotate. The second saves you from having to.

Are environment variables safe for secrets?

On the server, yes, when they are set in the host's settings and marked as secret. They stop being safe when their name starts with a public prefix such as NEXT_PUBLIC_ or VITE_, because the framework then writes the value into the JavaScript sent to every visitor.

Does a small team need a vault?

Often not at first. One app on one host is well served by the host's own secret settings. A dedicated secrets manager starts to pay off when several services share keys, when several people need access with a log of who read what, or when a customer asks how keys are controlled.

How often should API keys be rotated?

At once after any exposure or departure. Otherwise on a fixed rhythm you will actually keep, such as every quarter for the keys that open customer data or money. A rotation procedure that was tried once matters more than the exact interval.

I removed the key from my code. Is the leak fixed?

No. The key is still valid at the provider, still in git history and still in every bundle built with it. Revoke it at the provider first, then clean the code. The leaked API key guide gives the steps in order.

Sources

  1. 1.How to use environment variables in Next.js, Next.js Docs
  2. 2.Env variables and modes, Vite Docs
  3. 3.About secret scanning, GitHub Docs
  4. 4.About push protection, GitHub Docs
  5. 5.About GitHub Advanced Security, GitHub Docs
  6. 6.GitHub security plans and pricing, GitHub
  7. 7.Secrets Management Cheat Sheet, OWASP Cheat Sheet Series
  8. 8.The State of Secrets Sprawl 2026, GitGuardian
  9. 9.Config and Secret environment variables, Vercel Docs
  10. 10.Secrets Controller, Netlify Docs
  11. 11.Security overview, Lovable Documentation

Your app is public. So are its mistakes.

Check what any attacker can already see in it, free, in ten seconds. The full attack, with proof and fixes: €49 once, or €29 a month on a plan.

or continue with Google or GitHub