Skip to content
Databases & keys · Secret guide

Leaked Clerk Secret Key: what to do in the first hour

Critical severityDetected onlyLast verified · 5 min read

A Clerk secret key lets whoever holds it call Clerk’s Backend API as your application. That is the server side of your authentication: with it, an attacker can read user profiles, list and end sessions, create or delete users, and change how organizations are set up. Your application’s sign-in flow depends on this key being private. Rotate it first, then check what the key was used for. The publishable key that appears in browser code is meant to be public and does not need the same response.

Check your GitHub account for leaked secrets — free

Provider
Clerk
Severity
Critical
Impact
Payments and customer data
Checked live by LeakWatch
No

What a Clerk Secret Key looks like

Clerk secret keys begin with sk_, then the environment name, test or live, then a fixed-length body of letters and digits:

sk_live_…XXXX   Clerk secret key, production (masked)
sk_test_…XXXX   Clerk secret key, development (masked)

The body is not shown here on purpose. The shape of the prefix is what matters for triage. A pk_ value is a publishable key, which the Clerk front-end SDK ships to browsers by design. A whsec_ value is a webhook signing secret, which lets someone forge the events your endpoint trusts, and it rotates separately from the secret key. Stripe uses the same sk_live_ prefix, so a bare value is not proof that it came from Clerk. In LeakWatch the rule only reports a sk_ value when the word clerk appears next to it, such as in a CLERK_SECRET_KEY variable.

How Clerk Secret Keys get leaked

  • Environment files committed by accident. A .env.local or .env file with a CLERK_SECRET_KEY line, pushed because the ignore rule was missing or added too late.
  • Server code moved into the browser. A secret key imported into a front-end component, where the bundle is downloadable by anyone who loads the page.
  • CI and deployment logs. A build step that prints its environment, or a script that echoes the configuration when a deploy fails.
  • Shared snippets. A key pasted into a support thread, a tutorial or a pull request description to explain a sign-in bug.
  • Copied local setups. A developer’s dotfiles or a shared project template that carries the development key along with the production one.

What to do in the first hour

  1. Add a new secret key. Open the account settings for your Clerk application and create a new secret key under the secret keys section. Give it a name that says where it is used, so the next rotation is easier to read.
  2. Deploy the new value to every place that reads CLERK_SECRET_KEY: your hosting provider, local .env files, CI variables and any serverless functions. Frameworks that prefix variables, such as Nuxt, need the prefixed name instead.
  3. Confirm the new key is in use. Check that the key shows recent activity in the dashboard before you remove anything. This avoids breaking a service that still reads the old value.
  4. Delete the leaked key. Once the new one is live everywhere, delete the old secret key. Clerk warns you if the key was used recently, which is a useful signal that something still depends on it.
  5. Review users and sessions. Look for accounts created, deleted or changed in the period since the exposure, and for sessions you do not recognize. Revoke sessions that look wrong and ask affected users to sign in again.
  6. Check webhooks. If the same file held a webhook signing secret, rotate it as well, and only remove the old endpoint secret after your app has been verified against the new one.
  7. Clean the repository. Remove the value from current files, add the file pattern to .gitignore, and decide whether to rewrite history. A deleted commit remains in every clone, so the rotation is the real fix. See I accidentally pushed an API key to GitHub for the full order of steps.

Not sure what else leaked from the same repository? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at Clerk

Secret keys are managed in the API keys page of the Clerk Dashboard, for the application and environment concerned. Clerk allows more than one active secret key per environment, which is what makes a zero-downtime change possible: create the new key, deploy it, and then delete the old one. Clerk’s own rotation guide describes exactly this sequence. Rotating the production secret key does not affect the development key, and the reverse is also true, so check that you are in the correct environment before you delete anything. Publishable keys do not need to be rotated when they are exposed, but webhook signing secrets do, and they follow their own steps. If a key you expected to find is missing, it may belong to another application or environment in the same account.

How LeakWatch detects it

The rule is called “Clerk Secret Key”. It looks for a value that starts with sk_test_ or sk_live_, followed by a fixed run of 32 letters or digits, and only when the word clerk appears a short distance before it, with an assignment sign or similar separator in between. The word requirement is what keeps the rule from reporting Stripe keys, which share the prefix. Values with a pk_ or whsec_ prefix are not reported by this rule. The severity is critical, and the impact class assigned to the rule is payment data, because of the shared prefix. This type is not checked live: LeakWatch does not send the value to Clerk, so a finding tells you that a value matching the shape was seen, not that it still works.

LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

FAQ

Is a development secret key as serious as a production one?

Less, but not harmless. A development key cannot reach production users, yet it can expose test accounts, and developers often copy production values into development by mistake. Treat it as exposed and rotate it, then check whether the production key was ever stored in the same place.

Do I have to rotate the publishable key too?

No. Publishable keys are designed to be visible in browser code, so a leaked one is not an incident on its own. The secret key and any webhook signing secret are the values to protect.

Can I delete the old key before deploying the new one?

You can, but the sign-in or API calls that still use the old value will fail until the new one is deployed. If the leak is active, that short outage is usually the right trade. If it is not, create the new key, deploy it, confirm it works, and then delete the old one.

Get alerted next time a secret leaks — create a free account

LeakWatch is not affiliated with Clerk.