Track 09 · Lesson 1 of 9Shipping safely
Secrets and their blast radius
Lesson 1 of 9· 6 min
A secret is any value that grants access: API keys, signing keys, database URLs, tokens. Its blast radius is how much damage one leak allows, and you choose most of it on the day you create the key.
What does each key open?
Pick a key, then narrow it
If this leaked today, the holder could:
- Read every customer upload
- Overwrite any upload
- Delete every upload
- Change account settings
Doors open across all five keys
14 of 14
Narrow before you need to#
Most providers offer scoped keys: read-only, one bucket, one repository, restricted to the calls you make. Admin keys are convenient on day one and catastrophic on the day they leak. Some secrets can’t be narrowed at all, like a JWT signing secret, which can forge any session. Those must never leave the server.
Keep an inventory#
For every secret, write down where it lives, who and what can read it, when it was last rotated, and how to rotate it. Writing the rotation steps before a leak turns a panic into a checklist.
What ships to the browser#
In Next.js, any environment variable prefixed NEXT_PUBLIC_ is written into the JavaScript bundle at build time, for every visitor to read. Some keys are designed for that; many aren’t.
Public or secret?
Judge each variable
NEXT_PUBLIC_PAYMENTS_PUBLISHABLE_KEY=pk_live_51Hx…Ships to the browserNEXT_PUBLIC_AI_API_KEY=sk-proj-8f2…Ships to the browserPAYMENTS_SECRET_KEY=sk_live_51Hx…Server onlyNEXT_PUBLIC_SENTRY_DSN=https://4f1…@o123.ingest…Ships to the browserNEXT_PUBLIC_DB_ANON_KEY=eyJhbGciOi…Ships to the browserDATABASE_URL=postgres://app:…@db:5432/appServer onlyNEXT_PUBLIC_ADMIN_PASSWORD=hunter2…Ships to the browser
0 of 7 judged
Check yourself