Skip to content

Secret in a variable the browser can see

Gaphigh severity · reads .ts .tsx .js .jsx .mjs .cjs .envBeta

Variables starting with NEXT_PUBLIC_, VITE_, EXPO_PUBLIC_ or REACT_APP_ are copied into the JavaScript every visitor downloads. Anyone can read a secret, service-role or private key put there. Keys that are public by design (Supabase anon, Stripe publishable, Firebase) are not flagged. When Lintsure finds this, it marks it as a Gap: the code itself shows the problem.

What it looks like

A line Lintsure flags in its own test app:

// src/stack-client.tsx
const stripe = process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY;

How to fix it

Rename the variable without the public prefix (NEXT_PUBLIC_, VITE_ and so on), use it only in server code, and rotate the key, since it has already been shipped to browsers.

Through a coding agent, Lintsure suggests the change and waits. Nothing is edited until you approve it.

Controls it relates to

What the framework asks

GDPR Art. 32: Security of processing

Protect personal data with security that fits the risk: encryption, access control, testing and the ability to recover.

Evidence a reviewer may ask for: Security measures and when they were last tested.

OWASP Top 10 A04:2025: Cryptographic Failures

Protect data with sound cryptography: HTTPS everywhere, certificate checks on, strong password hashing, modern ciphers, unpredictable tokens, signed tokens that are verified, and no keys in code.

Evidence a reviewer may ask for: Where data is encrypted in transit and at rest, and how keys are stored and rotated.

Cyber Resilience Act Annex I Part I (2)(e): Confidentiality of data

Data stored or sent is protected with current encryption, and keys stay out of code and out of the browser.

Evidence a reviewer may ask for: Where data is encrypted in transit and at rest, and how keys are stored.

OWASP LLM Top 10 LLM02:2026: Sensitive Information Disclosure

Keys, personal data and internal details must not reach the model, its logs or its answers unless they're meant to.

Evidence a reviewer may ask for: What data is sent to the model provider, and the provider's data retention terms.

CWE Top 25 CWE-200: Exposure of sensitive information

Personal data, secrets and internals don't leak into logs, URLs, errors or the browser.

Summaries are our own reading of the public texts, not the official wording.

Read more: NEXT_PUBLIC_ and VITE_ variables: which keys are safe in the browser

Check your code for this

Runs on your machine. Your code is never uploaded.

npx lintsure scan

Quickstart · Use it in Claude Code or Cursor

This rule is in Beta: its mapping to framework controls is our own reading of the public texts, not independently reviewed. Lintsure is a readiness tool, not an audit or legal advice. A finding, or the lack of one, doesn't make you compliant. Disclaimer

We improve these rules all the time. If you see a false alarm, a missed problem or anything that could work better, tell us in a review and we will use it to improve your experience.

Related rules

Did this rule flag something that's fine, or miss a real problem? Tell us on GitHub. Every report becomes a test case, so the same mistake can't come back.