KeyDrift
Free scan
highNext.js·Resend API key

NEXT_PUBLIC_ leaked your resend api key into the App Router bundle

Send email from your verified domains — the raw material for a phishing campaign with your DKIM signature on it.

Why Next.js does this

A server component can read `process.env.STRIPE_SECRET_KEY` safely. Move that same line into a client component and the build fails to find it, so the quickest fix — rename it with `NEXT_PUBLIC_` — is also the one that inlines it into the JavaScript every visitor downloads.

Confirm it first

Before rotating anything, check whether the key is actually being served. Paste your deployed URL — KeyDrift downloads the same JavaScript a visitor gets and tells you what is in it.

No account. Read-only — the scanner only ever issues GET requests, and never stores a key: findings carry a masked prefix and a fingerprint.

Rotate the key

Do this before changing any code. The key has been served to browsers, cached by CDNs and very likely scraped already — removing it from the source does not un-publish it.

  1. 1Revoke the credential with its provider. Rotation is the only fix — the key is in the browser cache, in CDN edge nodes, and in whatever scraped the page.
  2. 2Review the account for activity you did not initiate.
  3. 3Move the call that needed it to a server route, so the browser never receives the replacement.
Open the revocation page

Move the call to a server

The replacement key must not follow the old one into the bundle, which means the code that uses it cannot live in the browser. Any variable named NEXT_PUBLIC_ is inlined at build time by design — the prefix is the mechanism, not a mistake.

Before — shipped to the browser

// app/components/Chat.tsx  ("use client")
// NEXT_PUBLIC_ inlines this into the browser bundle.
const key = process.env.NEXT_PUBLIC_API_KEY;
const result = await callTheApi(key, body);

After — stays on a route handler or server action

// app/api/proxy/route.ts  — runs on the server only
import 'server-only';

export async function POST(request: Request) {
  const key = process.env.API_KEY; // no NEXT_PUBLIC_ prefix
  const result = await callTheApi(key, body);
  return Response.json(result);
}

// app/components/Chat.tsx  ("use client")
const result = await fetch('/api/proxy', { method: 'POST' }).then((r) => r.json());

How KeyDrift detects it

Matches the two-segment `re_` key format.

It will happen again

A server component can read `process. That has not changed because you fixed this one file — the next feature request produces the same shape of code. Continuous monitoring re-scans every deploy and tells you the moment a key comes back.