Skip to content
Cloud · Secret guide

Leaked Sanity.io Auth Token: what to do in the first hour

High severityDetected onlyLast verified · 4 min read

A Sanity.io auth token gives a tool or service access to a Sanity project, which is the content backend that holds the structured content of many websites and apps. A token with write permission can change or delete documents, and a token with read permission can export content that you may not have meant to publish. Sanity tokens are created per project and carry a role, so the first question after a leak is which project the token belongs to and what that role allows.

Check your GitHub account for leaked secrets — free

Provider
Sanity.io
Severity
High
Impact
SaaS account access and billing
Checked live by LeakWatch
No

What a Sanity.io Auth Token looks like

Sanity auth tokens begin with sk, followed by a long block of letters and digits, which is how the detection rule finds them. The value is a single string:

sk…   Sanity auth token (masked)

The sk start is short and is also used by other vendors, so the rule relies on the word “sanity” appearing close to the value. Tokens are often stored in a SANITY_AUTH_TOKEN environment variable for a deployment, a build hook or a content migration script. A token pasted without any Sanity context may not be found by the scanner, so search your own repositories for the value directly if you suspect one leaked.

How Sanity.io Auth Tokens get leaked

  • Environment files. A .env file that contains SANITY_AUTH_TOKEN with the real value, committed because .gitignore did not list it.
  • Deployment configuration. A build or hosting setting that writes the token into a file in the repository.
  • Migration scripts. A content import script that was shared with a contractor or posted in a chat with the token inside.
  • Logs. A CI job or a Studio build that prints its environment when something fails.
  • Public templates. A starter project published with a working token left in its configuration.

What to do in the first hour

  1. Delete the token. Open the account settings for your Sanity project, go to the API section and delete the token that leaked. Deleting cuts off access at once, so do this before you rebuild anything.
  2. Create a replacement with the role that the tool actually needs. A build that only reads content should not hold a write token.
  3. Review the content. Look at the document history for recent edits, deletions and publishes. Restore anything that was changed without your approval.
  4. Check the datasets. If the token could export content, look for exports you do not recognize. Review which datasets are public, since a public dataset can be read without any token at all.
  5. Check webhooks and integrations attached to the project, and remove any you did not add.
  6. Look at other secrets in the same file, such as deployment keys and other service tokens. Rotate them too. See I accidentally pushed an API key to GitHub for the order of steps.
  7. Clean the repository. Store the token in your hosting provider’s secret settings and remove it from the files. Revocation is the real fix, because a deleted commit remains in clones.

Not sure what else leaked? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at Sanity.io

Tokens are listed in the project’s API settings in Sanity Manage. Open account settings, go to the project’s tokens and delete the one that leaked. Sanity also provides a command-line tool that can list tokens and delete one by its identifier, which is useful for scripting the change. Some tokens can be given an expiry date, which limits the window of a future leak, but an expiry cannot be removed once it is set. We have not confirmed every label in the current interface, so follow the wording you see.

How LeakWatch detects it

The rule is called Sanity.io Auth Token. It looks for the word “sanity” in any case, followed within about 40 characters by a value that begins with sk and has 79 further letters or digits, with word boundaries on both sides. Values that do not have the Sanity context are not reported by this rule. The severity is high, with the impact class for SaaS tools. This type is not checked live: LeakWatch does not send a request to Sanity with the value it found.

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 read-only Sanity token still a risk?

Yes, though less. It cannot change content, but it can export whatever it can read, which may include drafts or private datasets. Treat it as exposed.

Can I set an expiry instead of deleting?

An expiry only limits future use. For a token that has already leaked, delete it, because the leaked value keeps working until its expiry.

Will the site stop publishing?

Only the tools that use the deleted token. Create the replacement, deploy it, and test a publish before you rely on it.

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

LeakWatch is not affiliated with Sanity.io.