Skip to content
Exposed keys

JWT signing secret exposed: what to do next

If the secret your server uses to sign JSON Web Tokens is public, anyone can create tokens that your server will accept as genuine. Rotate the secret on the server, end existing sessions, and check that the browser never needed the secret in the first place.

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

A JWT signing secret belongs only on the server that issues or verifies tokens. If it appears in a bundle, repository or public file, treat it as compromised: generate a new secret, deploy it, invalidate sessions signed with the old one and review what forged tokens could have reached. ProofForge does not run a dedicated check for this.

Why this secret is different from an ordinary API key

Most leaked keys let someone call a provider as you. A leaked HS256 signing secret is worse in a specific way: it lets someone produce a token with any user id or role claim, and your own server will verify it successfully. The damage depends on what your server trusts inside the token. If it reads a role or tenant claim without checking the database, a forged token can impersonate an administrator.

Do not confuse a signing secret with a token. A single leaked token is one session; the secret is the ability to create unlimited sessions. Also distinguish asymmetric setups: with RS256 or ES256 the public key is meant to be public, and only the private key must stay secret.

Decoding is not verification

Anyone can base64-decode a JWT and read its claims, so seeing readable claims is not evidence of a leak. Verification means checking the signature with the expected algorithm and key, plus expiry, issuer and audience. Client code that "checks" a token by decoding it provides no security; only the server decision counts.

ts
// Server only. Never import this module from browser code.
import { jwtVerify } from "jose";

const secret = new TextEncoder().encode(process.env.JWT_SECRET);

export async function readSession(token: string) {
  const { payload } = await jwtVerify(token, secret, {
    algorithms: ["HS256"],
    issuer: "https://your-app.example",
    audience: "your-app",
  });
  return payload; // still look up the user's current role in your database
}

Contain it in this order

  1. Generate a new long random secret and store it in your host's server-side secret settings, not a public VITE_ or NEXT_PUBLIC_ variable.
  2. Deploy, so new tokens are signed and verified with the new value. Old tokens should now fail verification, which signs users out. That is expected.
  3. If you use a hosted auth provider, rotate through its dashboard rather than inventing your own procedure, and follow its documented rotation steps.
  4. Review logs for requests that used unusual roles or user ids during the exposure window.
  5. Remove the value from the bundle or repository and rebuild. Removing it alone does not invalidate copies people already have.

If the secret reached Git history, follow the history-cleanup advice in the exposed key guide, but rotate first.

What ProofForge does and does not check here

ProofForge does not currently perform a dedicated JWT signing secret check. This is a manual guide, not a claim of detection: a clean ProofForge report says nothing either way about this issue. The public scan covers the areas listed on the methodology page, such as exposed files, bundle secrets, security headers, CORS and selected database access. Use the steps above on an app you own or have permission to test, and keep your own notes as evidence.

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

Is it a problem that I can read my JWT claims in the browser?
Not by itself. JWT payloads are encoded, not encrypted. What matters is that the signing secret stays on the server and that the server verifies every token.
Will rotating the secret log everyone out?
Usually yes for tokens signed with the old secret. That is the point of containment. Some providers support a short overlap; follow their documented process.
Does ProofForge detect a leaked JWT secret?
Not as a dedicated check. Its bundle secret scan looks for selected provider key patterns, and a generic signing secret may not match them. Use this guide manually.

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