Vulnerability class

How to find live secrets in a repo, and prove a rotation worked

Updated

A secret in git history is a live credential until it is rotated, not deleted. Find it with a history scan, then test from outside your network whether the old value still authenticates — that is the only proof the exposure is closed.

Where this class of bug actually lives in a repository and its build pipeline

  • History, not the working tree. A key removed in a later commit is still in every clone and every fork.
  • Build output. Bundles that inline NEXT_PUBLIC_ or VITE_ variables, source maps, and container layers that copy .env.
  • CI configuration. Secrets echoed in a workflow log, or a token with broader scope than the job needs.
  • Client bundles. The place credentials actually leak to attackers: anyone can read them without touching your repo.

What to try first

  1. Scan full history with trufflehog or gitleaks, and separately grep the built assets for key prefixes.
  2. For each hit, test the credential from a machine outside your network to see whether it is still live.
  3. Check the scope of each live key: a read-only token is a different incident from an owner token.
  4. Verify the old key stops working after rotation — from outside, not by looking at a dashboard.

A reproduction you can keep

The only meaningful verification is an external one, before and after rotation:

Is the exposed key still live?
# history scan
gitleaks detect --no-git=false --redact=false -v

# client bundle, the leak path that actually matters
curl -sS https://yourapp.com/assets/index-*.js | grep -oE '(sk_live|AKIA|ghp_|xox[bp])_[A-Za-z0-9]+' | sort -u

# is the found key still valid? run the vendor's read-only endpoint
curl -sS -o /dev/null -w '%{http_code}\n' https://api.vendor.com/v1/account \
  -H 'Authorization: Bearer <exposed-key>'

# vulnerable: 200 — the key is live
# fixed after rotation: 401

What "fixed" has to look like

Rotation, not deletion: revoke the credential at the vendor, issue a new one, and confirm the old value returns 401 from outside your network. Then remove it from history and add a pre-commit scanner so the next one never lands.

Where people get this wrong

  • Rewriting history does not revoke anything. The credential is live until the vendor invalidates it.
  • Rotating the key but leaving it in a build cache or a container image leaves the exposure in place.
  • A scan of the working tree misses everything that was committed and later deleted, which is most of it.

What Offense does here

Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

Does deleting a secret from git remove the exposure?

No. It stays in history and in every existing clone, and it remains a valid credential until revoked at the vendor.

How do I confirm a rotated key is really dead?

Call the vendor's API with the old value from outside your network and confirm a 401.

Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.