Cenk Kurtoğlu©26

Credential leaks · 10 minute read

Exposed API key in a public repo: what actually happens in the first 24 hours

You push a commit. It contains an API key — a Supabase anon key, a service_role JWT, an AWS access key, a Stripe secret key. You notice ten minutes later, revert the commit, and force-push. You feel safe because the key is gone from the branch.

It is not gone. It has almost certainly already been copied. This is an hour-by-hour timeline of what actually happens after a key is exposed in a public repository. Nothing here is speculative: every stage is observable with read-only requests and public logs, and the pattern is the same one behind the public leak-demo repository and the browser-native RLS lab we run at cekuu35.github.io/rls-seance.

Hour 0–1: the scanners find it

Public code hosts are crawled continuously by automated scrapers. A key pushed to main at 09:00 is typically indexed by at least one secret scanner within the hour. These scanners are not targeting you specifically; they pattern-match for high-entropy strings that look like keys (sk_live_, sb_, AKIA, service_role) and queue anything that matches for deeper inspection.

At this stage nothing has been abused yet. The exposure is passive — a copy of your key now sits in a scanner's queue and, in some cases, in a public archive of historical commits. Reverting the latest commit does not erase the key: the old commit object stays reachable until garbage collection, and mirrors that cloned earlier keep their copy.

What you can verify immediately:read the repository's commit graph and check for forks and mirrors. If the key commit was ever pushed to a public branch, assume it has been copied.

Hour 1–6: automated validation attempts

Once a scanner flags a candidate key, automated systems try to validate it. For a Supabase anon key that means a read-only apikey: request against rest/v1/ tables. For a service_role key it means admin-level operations. For AWS keys it means sts:GetCallerIdentity or s3:ListBuckets.

These attempts are noisy and scripted. They leave traces in your platform logs — Supabase API logs, CloudTrail, your provider's access logs — but only if logging is enabled and someone is watching it. Most small teams are not.

This is the stage where the key type changes the size of the problem:

Hour 6–12: targeted or opportunistic abuse

If the key validates and grants access to data, two paths diverge.

The opportunistic path (most common)

An automated system enumerates tables, dumps a sample, and moves on. No human looks at your data; the value is in bulk collection. You may never notice unless you monitor query volume or row-access patterns.

The targeted path (rarer, more damaging)

A human reviews the validated key, identifies the application from the repo name, the README or the linked deployment, and decides whether the data is worth extracting systematically. This is where a leaked service_role key becomes a full incident: data exfiltration, schema modification, or ransom notes.

Hour 12–24: the rotation decision point

By hour 24, one of three things is true:

  1. Nothing was abused. The key validated but no data moved. You still do not know whether a copy was saved for later use.
  2. Data was read. Logs show anomalous query patterns, bulk exports, or access from unfamiliar IP ranges.
  3. The key was already rotated. Rotating inside the first hour makes the copied key inert — but anything read before rotation stays exposed.

Rotation is not a cleanup. It is a containment step. Data read between exposure and rotation is already out of your control, and you cannot un-read it.

What to capture before you rotate

Capture evidence while the key is still valid, so the incident report rests on measurements instead of guesses:

# 1. the commit that introduced the key
git log -1 --format='%H %cI %s' <commit>

# 2. which files and which key prefixes it touched
git show --stat <commit>

# 3. one read-only validation of scope, against a non-sensitive table
curl -s -o /dev/null -w '%{http_code}\n' \
  "$SUPABASE_URL/rest/v1/<non_sensitive_table>?select=*" \
  -H "apikey: $EXPOSED_KEY"

# 4. baseline API logs for that key, before the abuse noise arrives

Do not rotate and delete in the same minute. Remove the key from the repository first, then rotate, then verify the old key returns 401 — that verification is your proof the rotation worked. The full order, including purging history, is in the 30-minute service_role rotation runbook.

The false sense of security from a "private" fork

A common mistake is thinking the risk ends when the public repository is deleted or made private. Forks created before deletion stay public. Git mirrors, archive services and CI pipeline logs may retain the key. Treat any key that ever touched a public network as compromised, full stop.

How this connects to an RLS review

An exposed key is only half the problem. The other half is what the key can actually reach. A Supabase anon key against a database with permissive RLS policies is an open door even without any abuse — which is why the fixed-price Supabase RLS review from $95 starts with an anon-key probe and a policy census: it tells you whether a leaked key would be a nuisance or a catastrophe. The Supabase-specific version of this timeline — what the anon key and the service_role JWT each grant an attacker, and how to tell whether they were used — is in what an exposed Supabase key actually grants.

The spot check that answers the second half

Find out what the exposed key could actually reach

$95 spot check · 5 critical tables · 24 hours

Read-only anon-key probe plus a policy census, with the evidence and the written verdict. Five tables, one working day, no database changes.

Book the $95 spot check ↗Review scope and pricing →

Want the verdict on the whole project instead of five tables?

Fixed-price reviews with the evidence, the SQL and the written verdict. Fixes are quoted separately. Instant checkout, no account needed.

Related reading: the 30-minute rotation runbook, what an exposed Supabase key actually grants, what a free anon-key check can — and cannot — prove and the public leak-demo repository at github.com/cekuu35/supabase-rls-leak-demo, which contains the same exposure pattern with reproducible fixtures.

Template bundle

Review all 20 frontend starters in one bundle

20 editable frontend starters with live demos are $79 — one payment, no subscription.

View the Bundle — $79↗