All articles

Secret scanning for websites before production launch

7 min read

Free security scan

Is your Next.js app secure? Find out in 30 seconds.

Paste your URL and get a full vulnerability report — exposed keys, missing headers, open databases. Free, non-invasive.

No code access requiredSafe to run on productionActionable report in 30

If you are about to publish a marketing site, SaaS app, or AI-built product, secret scanning for websites should answer one question: can a visitor download anything that exposes credentials? The practical goal is to inspect public pages, scripts, source maps, config files, and common forgotten paths for API keys, tokens, private URLs, and environment files before launch.

Secret scanning for websites scope

A useful website secret scan is narrow, external, and production-shaped. It should look at what an anonymous visitor, search engine, browser extension, or attacker can request without special access. That scope matters because many leaks are not in source control anymore. They are in built assets, deploy output, and public routes.

The first pass should cover:

  • public JavaScript bundles that may include embedded tokens or service URLs
  • runtime configuration exposed through hydration data or public config endpoints
  • source maps that reveal original variable names, comments, or removed code paths
  • forgotten files such as .env, .env.production, backup archives, and debug logs
  • API responses that include internal IDs, private keys, or overly detailed errors
  • HTML comments, robots.txt, sitemap files, and static JSON used by the frontend

This is different from a broad vulnerability scan. A general scanner may find headers, outdated software, or open directories. Secret detection focuses on sensitive strings and files that should never be publicly retrievable. For a narrower guide, see this exposed secrets scanner article.

The key rule is simple: if the browser needs it, a user can see it. Some values are designed to be public, such as analytics IDs or publishable payment keys. Other values, including signing secrets, admin tokens, database passwords, and service-role keys, must stay server-side.

Where leaks usually appear?

Most public secret exposure comes from build-time confusion. A developer adds a variable for local testing, the framework inlines it into a client bundle, and the final website ships a real credential. This is common when AI-generated code suggests public prefixes without explaining the security boundary.

A high-risk pattern is a name that sounds harmless but stores a privileged credential. For example, PUBLIC_API_KEY may be safe for a map tile service but unsafe for a backend admin API. NEXT_PUBLIC, VITE, PUBLIC, and similar prefixes tell build tools to expose values to the browser.

A second common pattern is source map exposure. Source maps are useful for debugging, but they can reveal function names, comments, endpoint paths, and constants. They do not always contain live secrets, but they make manual investigation faster for attackers. If source maps are public, scan them before deciding whether to keep them online.

A third pattern is static file leakage. Public roots sometimes contain .env files, compressed backups, old deployment folders, or test fixtures. These leaks are easy to miss because the normal app still works. A scanner should request common filenames directly instead of relying only on links found in the page.

This quick manual example shows the shape of a basic check. It is not a replacement for a full scan, but it helps explain the surface.

bash
BASE=https://example.com
curl -fsS $BASE/.env
curl -fsS $BASE/.git/config
curl -fsS $BASE/_next/static/chunks/main.js | grep -E 'sk_live_|AKIA|ghp_|xoxb-'
curl -fsS $BASE/assets/app.js.map | grep -Ei 'secret|token|password|api[_-]?key'
curl -I $BASE/.env.production

Real scanning needs better fingerprinting than grep. It should detect token formats, validate context, avoid logging sensitive values, and separate server-only credentials from acceptable public identifiers. It should also reduce false-positive noise, because teams ignore reports that flag every UUID as a leak.

For bundled apps, pair secret checks with a JavaScript bundle scan. For environment files specifically, run a public .env check before changing DNS or announcing the launch.

Run a focused launch check

Start with the exact host users will access. Scanning a preview branch is useful, but production CDNs, rewrites, and asset paths can differ. Include the apex domain, www host, app subdomain, and any static asset domain that serves compiled files.

Use this checklist before launch:

  1. production host: scan the real public URL, not only localhost or staging.
  2. Crawl public pages, including pricing, signup, docs, changelog, and legal pages.
  3. Fetch linked JavaScript, CSS, JSON, source maps, and static assets.
  4. Request common sensitive paths, including .env, .env.local, .git/config, backup.zip, and debug logs.
  5. Search for token formats, private key blocks, cloud keys, webhook secrets, and database URLs.
  6. Review findings by severity, separating public identifiers from privileged secrets.
  7. Rotate any exposed credential, then redeploy and rescan the same URLs.

Keep the scan external and safe. A launch secret check should use no authenticated fuzzing unless you have a clear test account and permission boundary. It should not submit destructive forms, mutate data, or brute force paths aggressively. The goal is to find what is already public, not stress the application.

A good finding should include the URL, asset path, matched secret type, confidence level, and surrounding context with sensitive parts masked. For example, reporting sk_live_...abcd in /assets/app-93f2.js is actionable. Reporting key found somewhere is not.

When reviewing results, ask whether the value grants access, whether it is intended for client use, and whether it is scoped. A publishable key may be acceptable if it only starts a client-side payment session. A service-role key, database connection string, private webhook signing secret, or cloud access key is not acceptable in browser-visible code.

If you need broader coverage, use a deeper crawl through authenticated flows, generated routes, and hidden static assets. AISHIPSAFE supports a deep scan when a simple homepage check is not enough.

Fix findings without breaking production

Do not just remove the string from the frontend and assume the incident is over. Once a secret has been public, treat it as compromised. Logs, browser caches, CDN caches, build artifacts, and third-party crawlers may already have copied it.

Use this fix order:

  • rotate before redeploy so the old credential stops working immediately
  • remove the secret from client code, static files, and build output
  • replace browser access with a server-side endpoint or short-lived token flow
  • purge CDN caches for affected assets and source maps
  • remove or restrict public source maps if they expose sensitive implementation detail
  • add a prelaunch scan to CI or release review

The safest architecture is to keep privileged actions behind your backend. The browser can call your server. Your server can then call the third-party API with a private credential. That pattern gives you rate limits, authorization checks, logging, and revocation control.

Be careful with quick fixes that create new risk. Moving a secret into a public runtime config endpoint is still exposure. Renaming a variable does not help. Obfuscating a token in JavaScript is not protection, because the browser must reconstruct the value to use it.

After rotation, verify that the old credential fails. This step catches partial fixes where one environment was updated but another still accepts the leaked key. Also check error monitoring, deployment logs, and build caches for the same value. A clean website does not guarantee clean operational history.

For AI-built apps, add a rule to your review process: public prefixes are for client-safe keys only. If generated code suggests placing a privileged value in a public variable, reject that change and move the operation server-side.

A reliable launch process combines delete leaked artifacts, least privilege, block risky paths, and scan every release. Before publishing, run an external AISHIPSAFE security scan to catch exposed credentials and other public launch risks from the visitor's point of view.

Faq

What secrets should a website scan detect?

It should detect API keys, cloud access tokens, private key blocks, database URLs, webhook signing secrets, session secrets, and exposed environment files. It should also flag suspicious source maps or config files. The best reports distinguish privileged secrets from public identifiers, so teams can fix real risk first.

Is a public frontend API key always unsafe?

No. Some keys are designed for browser use and are restricted by domain, scope, quota, or backend policy. The risk comes from privileged keys that can read data, write data, bypass billing controls, or call admin endpoints. Review every exposed key by permission, not just by name.

When should i run a website secret scan?

Run it before launch, after major frontend changes, after framework or hosting changes, and after adding third-party integrations. Also scan after rotating credentials to confirm the old value disappeared from public assets. For fast-moving teams, make it part of every production release checklist.

Start with one public scan before launch. If it finds anything sensitive, rotate first, fix the exposure, then rescan until the public surface is clean.

Free security scan

Is your Next.js app secure? Find out in 30 seconds.

Paste your URL and get a full vulnerability report — exposed keys, missing headers, open databases. Free, non-invasive.

No code access requiredSafe to run on productionActionable report in 30