Skip to content
Exposed keys

How to find API keys in your JavaScript bundle

Inspect the JavaScript files your live page actually loads and classify credential-shaped values without printing them publicly. A pattern match is a reason to review the value, not proof that every visible key is private or active.

Check your app free, first fix free
By Brennan ZamboUpdated
In short

Use your production page's network panel to identify current assets, then inspect local build output and public responses. Prefer file-name-only searches over dumping credential values. Separate expected public identifiers from private authority, rotate real exposed secrets and recheck the deployment. Preserve limitations when assets or runtime configuration could not be inspected.

Identify the assets a visitor really receives

Open your application in a clean browser session and inspect JavaScript requests in the network panel. Save the production URL and asset names privately. Framework chunks, deferred routes and runtime configuration can live outside the single file you expected, so do not stop after opening the main source file.

Look at the live HTML references as well as your local build directory. An old HTML document can still point to a previous asset. If the scanner could not fetch a large or unsupported asset, retain that coverage gap instead of assuming the missing file contains nothing important.

Search without distributing the results

For a local build you control, a file-name-only search can identify candidate files without printing full key values into a terminal transcript. Adjust the build directory and patterns for your application.

bash
# Example for a Vite build. Prints paths, not matching credentials.
rg --files-with-matches \
  'sk-proj-|sb_secret_|BEGIN PRIVATE KEY|sk_live_' dist/

This is a small example, not an exhaustive secret detector. A custom credential format may not match, and a matched string may be an example. Inspect candidates privately and avoid committing real secrets as regression fixtures. Do not assume that minification makes a key confidential; the browser still needs the value if the application uses it there.

Classify before declaring an incident

A Supabase public key, Stripe publishable key or restricted browser map identifier can be expected. A server secret or administrator key is a different category. Check the provider's intended key type and the application's permission model.

ProofForge masks observed credential-shaped values and distinguishes informational public-key patterns from more severe secret patterns. It does not try discovered secrets against provider APIs. That keeps the check bounded but means an owner review is still needed to establish whether a value is real, active and appropriately restricted.

Trace the value back to its source

Search source literals, client environment prefixes, imported configuration and server responses serialized into a page. A source map may reveal the original file location, but the absence of a map does not hide a literal already present in JavaScript.

Fix the mechanism as well as the individual string. If a provider call belongs on the server, move it to an authorized server endpoint rather than returning the key from a new API route. Review error handlers so a failed request does not print private configuration.

Rebuild, rotate and compare

Revoke or rotate any real exposed private credential through the provider, review usage and deploy a clean build. Verify normal users still succeed and unauthorized callers cannot abuse the replacement server path. Inspect the new live asset references and record anything you could not check.

Turn the check into a release decision

Keep a small record of the production URL, the time you checked it, the exact finding and the action you took. A local preview and a deployed application can have different environment variables, response headers and database projects. After a repair, deploy the intended version and check the public address again. Do not assume that changing a repository file changed the live system.

Read coverage as carefully as the score. A timed-out asset, an ambiguous backend configuration or a request that could not safely establish access should remain unknown. It should not disappear from your release notes merely because there is no red finding. If a check was not completed, decide who will review it and what additional evidence is needed.

ProofForge's free report includes the first fix. The $9 Fix Report unlocks all findings' available repair guidance and builder prompts, with a PDF and private report link. Fix + Guard costs $29 once and adds builder rules, on-demand deploy-hook scans for 30 days and four weekly rechecks you start yourself. These are different deliverables, not different promises that an application is completely secure.

Keep private report URLs out of public issues and commits. If you need shareable evidence, use the owner-verification and publication flow for an eligible receipt. A signature protects the recorded assessment against undetected changes; it does not make the assessment exhaustive, prove a business outcome, or show that a later deployment still matches an earlier result.

Questions builders ask

Does minifying JavaScript hide an API key?
No. If the browser needs the value, a visitor can retrieve it from the delivered code or requests.
Will searching a few prefixes find every secret?
No. Formats vary and some values are assembled at runtime. Treat the search as one bounded check, not a complete audit.
Should the report show the full key as proof?
No. Masked evidence and a source location are usually sufficient. Printing the credential creates another exposure channel.

Continue with a related guide

Sources

Read-only, about a minute

Scan your app free

See what your live app ships to every visitor, with the first fix free. A clean scan is not a full audit. Run it only on an app you own or have permission to test.

Scan your app free
All guides