Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 2 min read

How to check any website for exposed API keys in its JavaScript (5 minutes, no tools)

You can check what a website hands to every visitor in a few minutes. No account and no special tools. This is the same look a stranger gets, so it only makes sense on sites you own or have permission to test.

You can check what a website hands to every visitor in a few minutes. No account and no special tools. This is the same look a stranger gets, so it only makes sense on sites you own or have permission to test.

1. Open the bundle

Open the site, press F12, go to the Network tab, reload, and filter by JS. Click the largest .js files (names like index-abc123.js or main.js).

2. Search for key shapes

Use the search box in the Sources tab (Ctrl+Shift+F) or paste the file into an editor. Look for these prefixes:

Pattern What it is In the browser?
sk- or sk-proj- OpenAI secret key Never
sk_live_ Stripe secret key Never
pk_live_ Stripe publishable key Fine
eyJ... with "role":"service_role" Supabase service role JWT Never
eyJ... with "role":"anon" Supabase anon key Fine if access rules are on
AKIA AWS access key ID Never

A JWT is three base64 parts separated by dots. Paste the middle part into a base64 decoder, or use a local decoder, and read the role claim. Do not paste a real secret into a website you do not trust.

3. Check the two files people forget

Request /.env and /.git/HEAD on the site. A real file shows contents. A normal HTML page means the host is returning its fallback, which is not a leak. Also check whether the bundle ends with a //# sourceMappingURL= line and whether that .map file loads. A public source map shows your original source code.

4. If you found a real secret

  1. Revoke or rotate it with the provider first.
  2. Move it to a server-side environment variable.
  3. Redeploy, then search the new bundle again.
  4. Check the provider's usage log for activity you do not recognize.

Removing it from the site does not undo exposure. Anything that was served can have been copied.

Faster options

ProofForge has free read-only checkers that do these steps for a site you own: https://proofforge.live/tools/exposed-api-key-checker and https://proofforge.live/tools/env-file-checker . Key prefix reference and the fix for each: https://proofforge.live/leaked-keys

A clean result is evidence, not a guarantee. It does not see server code or logged-in behavior.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.