WordPress · Drupal · Site Maintenance · Technical SEO · Editorial Policy

How to Tell if Your Sanity Site Has Been Compromised

A Sanity site is really several systems working together. The Content Lake is hosted by Sanity. Sanity Studio is a React app your team configures and deploys. Your front-end is code you host elsewhere. A compromise can start in any of these, so checking one place is not enough.

This guide covers the warning signs, how to confirm what happened, and what to do first.

Why a headless site needs a different mindset

On a traditional CMS, one login often gives access to content, plugins and the server. A headless setup splits those parts. An attacker may never touch the Content Lake directly. They might instead reach your front-end hosting, a build pipeline, a leaked API token or a Studio plugin pulled in through npm.

That split helps you, because each layer leaves its own trail. It also means you need to look in several places before you decide the site is clean.

Signs something is wrong

Most compromises show up as small oddities before anything dramatic. Watch for these:

  • Unexpected project members. Someone you do not recognise appears in your project’s member list, or a known person has a higher role than they should.
  • Content you did not write. Documents contain unfamiliar links, hidden text, changed calls to action or altered contact details.
  • Changed redirects. Redirects stored in your content, or in your front-end configuration, send visitors or search engines to another domain.
  • Spam pages. New pages appear in your sitemap or in search results, often with pharmacy, gambling or counterfeit-goods keywords, even though nobody on your team created them.
  • Injected scripts. Pages load JavaScript from a domain you do not use, or the page source includes code you never added.
  • Search warnings. Your search console reports security issues or manual actions, or browsers show a warning when visitors arrive.
  • Odd API activity. Writes to your dataset at times when nobody on your team is working.

Any one of these can have an innocent cause, such as a colleague’s edit or a marketing tag you forgot about. Several together deserve immediate attention.

How to confirm it

Work through the layers one at a time and write down what you find.

Check access in your Sanity project

Open your project in the Sanity management console and review the members and their roles. Remove anyone who should not be there and look for roles that are broader than needed.

Then review the list of API tokens. Each token has a permission level, and a token with write access can change your content. Delete any you do not recognise or no longer use. Which roles and access controls are available can depend on your plan, so check what your project offers in the Sanity documentation.

Check CORS origins

CORS origins decide which websites can make browser requests to your project’s API, and some of those can be allowed to send credentials. Look for origins you did not add. An unfamiliar entry that allows credentials is a strong warning sign.

Review content history

Studio keeps document history, so you can see how a suspicious document changed over time and compare it with earlier versions. Look at the content that looks wrong and trace when the change happened. If your plan includes audit or activity information, use it too. Availability depends on plan and setup.

Inspect your Studio and its plugins

Your Studio is code your team owns. Open the repository and look at recent commits you do not recognise. Review the dependency list for packages nobody remembers adding. A Studio plugin is an npm package that runs inside your editing environment, so treat an unexpected one as serious.

Inspect the front-end

Many injected scripts live in the front-end rather than in the content. Compare the code your site serves with what is in your repository. Check your hosting dashboard for unexpected deployments, changed environment variables, new build hooks and new team members. A Content Security Policy can block scripts from unapproved domains and report attempts, which makes injected code easier to spot.

First steps to take

Act in this order so that you stop further damage before you start cleaning up:

  1. Limit access. Remove unknown project members, lower unnecessary roles and require every remaining person to review their own account security.
  2. Rotate secrets. Delete suspicious API tokens and create fresh ones with the lowest permissions that work. Update every place that uses them, including build settings and webhooks.
  3. Tighten CORS. Remove origins you do not recognise and keep only your real domains.
  4. Review webhooks and integrations. Check for endpoints you did not set up, since they can leak content or trigger unwanted builds.
  5. Secure the code. Revoke access for unknown collaborators on your repository and hosting. Rotate deployment keys and any credentials stored in environment variables.
  6. Clean the content. Restore affected documents from their history, or fix them by hand, then republish and clear any caches or CDN copies.
  7. Rebuild and redeploy. Reinstall dependencies from a clean lockfile, remove anything unexplained, and deploy the Studio and front-end again.

Before you change anything large, export your dataset so you have a copy of the current state to examine later.

Check search and visitors afterwards

Once the site is clean, confirm that outsiders see what you see. Load key pages in a private browser window and view the source. Search for your own domain together with suspicious keywords to find spam pages that may still be indexed. If your search console reported a warning, fix the cause first and then use its review process.

Spam URLs that remain indexed after you remove them can take time to fall out of results. Keep checking until they are gone.

Reduce the chance of a repeat

A few habits make the next incident less likely and easier to catch:

  • Give each person and integration the smallest role or token permission that does the job.
  • Use separate tokens for separate purposes so one leak does not expose everything.
  • Never expose a write token in browser code.
  • Pin and review Studio plugins and other dependencies, and update them on a schedule.
  • Keep a short list of allowed CORS origins and review it regularly.
  • Learn the common web risks in the OWASP Top Ten and compare them with your own setup.

Frequently asked questions

Can the Content Lake itself be compromised without my access being involved?

Sanity hosts and operates the Content Lake, so the more common problems come from what you control: member accounts, tokens, CORS settings, plugins and front-end code. If you suspect a platform-level problem, contact Sanity through its official support channels.

Should I take the site offline while I investigate?

It depends on the risk. If visitors could be harmed, for example by an injected script, a temporary maintenance page is reasonable. If the issue is limited to a few edited documents, you can usually fix access first and keep the site running.

How do I know the problem is really gone?

Check that unknown members and tokens are gone, compare the served code with your repository, review content history for further unexpected edits, and watch your search console. If new unexplained changes appear, a credential or dependency is probably still exposed.

We use essential cookies to make this site work and remember your preferences. We do not use advertising or analytics cookies. Privacy Policy. Cookie Policy.