Consider a scenario. You’re building a SaaS product: the backend connects to a cloud database, the frontend is Next.js, and the iteration pace is fast. Before launch, you bring in the security team for a black-box assessment. Three days later, the report comes back with two high-severity findings:
- C1: On the homepage, “View Source” reveals that the
__NEXT_DATA__JSON block contains the complete backend configuration that should have stayed server-side — database addresses, message queue endpoints, internal service URLs, signing keys. - C2: Key material related to secp256k1 shows up in the frontend bundle. Someone starts checking on-chain balances.
Let me pause here and note the wording of C2: “key material.” A hex string that looks like a private key doesn’t mean it is a private key — it could be a public key, a demo value, or a long-retired test key. But both findings point to the same, more fundamental problem: the developer failed to recognize that there must be a deliberately designed boundary between “what the server knows” and “what the browser can obtain.” This article aims to clarify three things: where this boundary lies; why it disappears silently; and why, in the age of AI-written code, it’s disappearing faster than ever.
(Note: The opening scenario is a composite, loosely based on redacted test-report details and does not reference any specific product. The entire article discusses principles, risks, and defensive design only — no attack steps against real systems are provided.)
One: What Can the Browser Actually See?
Let’s establish a baseline that’s too often forgotten: The person using the browser is not your colleague. The browser runs on the attacker’s own device, where they have unlimited time, tools, and motivation to inspect every byte your application delivers.
What they can do includes: opening DevTools to inspect every request and response in the Network panel; using the command line to fetch raw HTML and JSON; reading localStorage, sessionStorage, IndexedDB, and cookies; prettifying minified JavaScript; running automated de-obfuscation on obfuscated code — open-source tools like webcrack have turned “restoring obfuscated code” into a mature workflow, and security vendors’ engineering blogs feature complete de-obfuscation playbooks. MITRE’s weakness catalog singles out “relying on obfuscation and hiding as a security measure” as CWE-656, precisely because it’s so common.
So the rule is a single sentence: Once data reaches the browser, it is no longer a server-side secret. The frontend is a public space, not a safe. As you’ll see, virtually every leak stems from ignoring this sentence.
Two: What Exactly Is Next.js’s __NEXT_DATA__?
__NEXT_DATA__ is not a vulnerability — it’s a data channel by design. In Next.js’s Pages Router architecture, every server-rendered page’s HTML contains a block like this:
| |
This JSON serializes the props returned by getServerSideProps, getStaticProps, or getInitialProps to the page component, along with the route, query, buildId, and several rendering flags (older versions also had publicRuntimeConfig, removed as of Next 16). Why does it exist? To guarantee hydration consistency: after the server pre-renders the visible HTML, React in the browser must recompute the same component tree using the same props — otherwise the page flickers or mismatches — and embedding props in a DOM JSON script is the most natural carrier. This is the mechanistic rationale that framework maintainers explained in the official repository discussion (#15117); it’s not an oversight.
The problem lies in what feeds into it. The official getServerSideProps documentation states plainly: props passed to the page component “will be visible to the client as part of the initial HTML,” and explicitly instructs not to put anything that shouldn’t reach the client into props. But that sentence carries about as much weight as an umbrella stand at a restaurant entrance: too many people grab one on the way out. A common pattern is to spread an entire database record or an entire configuration object directly into props:
| |
So the same secret ends up in three copies: the text baked into visible HTML, the __NEXT_DATA__ JSON block, and the /_next/data/<buildId>/<path>.json endpoint that returns JSON during client-side navigation (the official docs confirm that client-side navigation uses this API request to re-fetch props). If the page is statically generated (SSG), the props are also baked into static files and distributed via CDN with cache durations of up to one year (s-maxage=31536000, per the official CDN caching docs) — a single build-time mistake will sit on the CDN for a full year.

In the App Router era, the mechanism changed its carrier, but the boundary problem remains. The Pages-style __NEXT_DATA__ is replaced by the RSC (React Server Components) payload: render results are streamed into the page in React’s Flight serialization format (in practice, inline scripts like self.__next_f.push(...), an implementation detail), and client-side navigation reuses the normal URL with a ?_rsc= parameter. The key point: any props passed to a Client Component must be serialized across the network — the official “Data Security” guide directly provides an anti-pattern example, annotated “EXPOSED: This exposes all the fields in userData to the client,” categorizing it as the same class of anti-pattern as the previous generation. Server Actions work the same way: the official docs state that “an exported action is a public endpoint” that can be POSTed directly; while Next 16 added encrypted secure action IDs, the official data security guide still reminds you: don’t treat closure encryption as a means to hide sensitive values from the client. The 2025 CVE-2025-29927 (middleware bypass) serves as a reminder on another front: even the framework’s own boundary mechanisms can be circumvented — authentication must live inside each endpoint, not in a single-point middleware check.
The framework also provides convenient defensive primitives: import 'server-only' causes a build-time error if any client-side environment imports the module; another officially recommended technique is wrapping data in a class before passing it — because functions and class instances can’t be serialized by Flight, effectively using the type system as a last line of defense. As for the Taint API (taintObjectReference/taintUniqueValue), as of the Next 16.3.4 official docs in August 2026, it’s still marked experimental, with a note not to treat the Taint API as the sole防线 against sensitive data reaching the client — it can serve as a safety net, but not as the foundation.
Three: Why Does Configuration “Accidentally” Leak to the Frontend?
The C1 finding in the black-box report is not an isolated case. It typically arises from one of four pathways:
1. Spreading the entire configuration object into props. For convenience, config, runtimeConfig, or settings is handed wholesale to the page component — “I’ll cherry-pick the fields the frontend needs later.” But serialization happens on the whole package — whether or not the frontend picks specific fields, the data has already left the server.
2. The intuitive trap of environment variable prefixes. Next.js’s rule is: variables with the NEXT_PUBLIC_ prefix are inlined into the browser-bound JS bundle at build time (under the hood, this is a plain-text replacement via the webpack-family DefinePlugin); variables without the prefix are only available in the Node.js server-side runtime, and referencing them in client-side modules yields an empty string. Here’s the counter-intuitive part: NEXT_PUBLIC_ has “PUBLIC” in its name, but it’s the switch that makes a value public, not a switch that says “use a public variable.” Vite’s VITE_ and CRA’s REACT_APP_ follow the same logic, and their official docs discourage the practice: Vite’s docs suggest “to avoid accidentally leaking environment variables to the client, do not use this prefix,” while CRA’s warning is more blunt — “never store any secret in a React app; environment variables are embedded in the build output, and anyone inspecting the app files can see them.”
Two chain effects that are easy to overlook: inlining happens at build time, so the value is frozen from that point on — changing the environment variable after deployment has no effect on the live bundle; if a leak is discovered and you only update the value in the Secret Manager without doing a full rebuild and clearing the CDN cache, the old value continues to be served.
3. Passing entire database records to Client Components. In App Router, a Server Component fetches from the database and hands the entire userData object to a Client Component — this is the most common anti-pattern called out in the official data security guide, annotated EXPOSED.
4. Not thinking through the environment variable version chain. .env files have a precedence chain (existing shell env > .env.$(NODE_ENV).local > .env.local > .env.$(NODE_ENV) > .env), and where a given variable actually comes from, or whether it ends up in the container image, is something many teams can’t answer.
Note the common pathology across the first three: they are all the shortest path to “get the code running.” This will become important in Part Six.
Four: From API Keys to secp256k1 Private Keys
Let’s classify what gets leaked by severity, which clarifies the gravity of C2. Two official classification schemes from the industry are worth adopting directly:
Stripe’s official terminology: pk_-prefixed publishable keys are labeled “Safe to expose: Yes” — they only identify the account and convert payment information into tokens, and “cannot perform sensitive operations like creating charges or reading account data”; sk_-prefixed secret keys are labeled “Safe to expose: No” and carry full permissions. Firebase’s official documentation has a similar two-tier statement: with proper API restrictions in place, “an API key scoped to Firebase services does not need to be treated as secret,” with real access control handled by Security Rules and App Check. One sentence summarizes this classification: publicly shareable material (public keys, addresses, publishable keys, frontend configuration) serves only an “identification” function; confidential material (private keys, secret keys, mnemonic phrases) serves an “authorization” function. When something with an authorization function crosses the browser boundary, its nature changes.
secp256k1 is an elliptic curve defined in the SECG standards body’s SEC 2 specification — the curve parameters themselves are public, and it’s famous because Bitcoin chose it for ECDSA (Elliptic Curve Digital Signature Algorithm) transaction signing at implementation time (the white paper only describes using digital signatures; the curve was chosen during implementation in 2009 and finalized with the standard in 2010), and Ethereum adopted the same curve. Its most critical property is point multiplication’s one-way nature: deriving a public key from a private key is computationally easy, but the reverse is cryptographically infeasible — this is the exact logic described in ethereum.org’s documentation. An Ethereum address is “the last 20 bytes of the Keccak-256 hash of the public key, prefixed with 0x.” One level deeper: the only legitimate scenario where a user should hold a private key is when the key belongs to the user — for example, with MetaMask and similar non-custodial wallets, the mnemonic phrase stays in an encrypted vault on the user’s device, and the service provider never touches it. “A website operator putting their own signing private key into their own frontend” is an entirely different species: that’s the equivalent of printing sk_ on the front door and handing it to every visitor.
“If the exposed material is indeed a private key,” the location determines the shape of the consequences:
- Baked into the JS bundle: Supply chain incidents have demonstrated what happens when keys end up in bundles — in 2018, the npm package event-stream was taken over and injected malicious code specifically targeting Copay wallet private keys of projects that integrated it; in December 2024, two counterfeit
@solana/web3.jsversions replaced functions with code that exfiltrated private keys. Every line in your bundle can be read by any link in the dependency chain. - localStorage / IndexedDB: Browser-based persistent storage is the primary target for XSS and malware. The AMOS trojan, first seen in 2023, explicitly lists MetaMask, Phantom, and other wallet extensions as theft targets — if that’s true for legitimate wallets, custom storage solutions fare no better.
- Frontend configuration / injected scripts: BadgerDAO lost approximately $120 million in 2021 when attackers obtained their Cloudflare credentials and injected scripts into the frontend to trick users into authorizing fraudulent transactions (Microsoft named this class of attack “ice phishing”); in 2023, the MyAlgo web wallet was injected with malicious JS, resulting in approximately $9.2 million in losses. Frontend configuration compromised = the right side of the equation is the user’s entire set of authorizations.
- API Response / server-side telemetry: In 2022, Slope Wallet sent user mnemonic phrases to their own Sentry instance; 9,231 addresses were drained of approximately $4.1 million; that same year, 3Commas leaked approximately 100,000 user exchange API keys on the platform side. Once a key enters the response or logging pipeline, there is no taking it back.
- Source Maps: On March 31, 2026, the Claude Code npm package published by Anthropic accidentally included
cli.js.map, wheresourcesContentembedded approximately 510,000 lines of complete proprietary source code that anyone could restore with a single click — source maps reduce the “unreadability” provided by minification to zero, and any constant hidden inside is exposed along with it. - As a boundary reference point: the extreme consequence of a service provider’s signing key compromise was demonstrated by the Harmony Horizon cross-chain bridge in 2022 — validator private keys were breached, and approximately $100 million in assets was emptied. A service provider’s private key doesn’t need any frontend involvement to be a complete landmine on its own.
Now back to the wording discipline around C2: the secp256k1 material seen in the black-box report “may involve” a real private key, and “if the exposed material is a private key,” all of the above consequences apply; but it could equally be a public key, a test vector, or a long-deprecated demo value — this “requires further verification” (verification directions: can a public key and address corresponding to live assets be derived from it; what is its source location and lifecycle). The truly defensible conclusion is not “a specific private key was leaked here,” but rather “this application’s architecture has no key classification whatsoever, causing key-shaped material to appear where it shouldn’t. Obfuscation provides no protection — minification, string encryption, homegrown “client-side encryption” all amount to handing the lock and the key to the adversary together (a variant of CWE-656); any code that can run in DevTools, the adversary can analyze.
Five: The Secret Leakage Surface of Modern Web Applications: An Eight-Layer Map
Stringing the scattered points together, the secret leakage surface of a modern web application spans roughly eight layers. Each layer is backed by an official definition or a public incident.
Layer 1: Frontend Bundle. Hardcoded keys in plaintext, visible in files downloadable by every visitor; NEXT_PUBLIC_/VITE_/REACT_APP_ prefixes turn environment variables into plaintext literals at build time; AWS long-term keys starting with AKIA, private keys starting with -----BEGIN, and sk_ prefixes are all stable patterns scannable by machine. The detection toolchain has matured: gitleaks / trufflehog scan repos and build artifacts; semgrep has ready-made hardcoded-jwt-secret rules. Note that the scan target must be build output — scanning source code alone will miss inlined results.
Layer 2: Environment Variables. Prefix semantics (public or not), build-time freezing, and stale values persisting after rotation were covered in Part Three. One additional point: file names like .env.local may not describe “for local debugging” so much as “at risk of falling into git.”
Layer 3: API Over-Exposure. OWASP API Top 10 2019 defines Excessive Data Exposure as an API that “by design returns sensitive data to the client, typically filtered only before client-side rendering,” with the first official defensive measure being “never rely on the client to filter sensitive data.” The official example is spot-on: a monitoring API returns the full camera list and each camera’s live_access_token — “the guard’s UI only shows authorized buildings,” but the API returns everything. The 2023 version folded this into API3 Broken Object Property Level Authorization (merging excessive exposure and Mass Assignment), shifting focus from symptom to root cause: the absence of object-property-level authorization. Another related major category is BOLA (Broken Object Level Authorization, API1; what the public knows as IDOR, “Insecure Direct Object Reference,” is its typical form), which describes the problem of changing an ID to read someone else’s object. A real-world example is Venmo: from 2018, a researcher downloaded approximately 208 million transaction records covering all of 2017 via its public API and built a website to display them — the lesson being that the “privacy settings” in the app UI are client-side filtering; the data-layer API remains public by default. ASVS 5.0 (published May 2025) writes the baseline as an L2 requirement: “Secrets must not be included in application source code or included in build artifacts.”
Layer 4: Source Maps. The ECMA-426 standard defines the sourcesContent field of .map files — when present, the complete original source code is embedded in the publicly accessible map file; the sources array also frequently leaks server-side absolute paths and even developer machine usernames. Three dangerous misconceptions: Vite’s hidden mode only removes the reference comment — the map file is still generated; Next.js with productionBrowserSourceMaps enabled explicitly serves these files per the official docs; “uploaded to Sentry but no public reference” does not mean safe — Vercel’s official Conformance rule NEXTJS_NO_PRODUCTION_SOURCE_MAPS states that enabling production source maps is equivalent to “publicly sharing your application source code,” and the recommended workflow is to upload to error-tracking platforms and then clean and deploy. The real costs are documented: in a Sentry security team case study from 2025, an attacker restored an undocumented password-change endpoint from a public map and completed an account takeover; another case that year involved a researcher recovering a hardcoded Stripe secret key from a production map.
Layer 5: Browser Storage. localStorage / sessionStorage / IndexedDB / cookies. A simple decision tree: sensitive values that need to be read by JavaScript (tokens, keys) will share the fate of XSS wherever they’re placed; session credentials should use httpOnly cookies; “secrets” as a category have no business being in browser storage at all. Even wallet extensions themselves need encrypted vaults to protect data — the storage location provides no isolation on its own.
Layer 6: Git. History is forever. GitHub’s official “Removing sensitive data” documentation takes a clear-eyed stance: the moment a secret enters the repository, it’s considered compromised — the first step is always to revoke/rotate the key; cleaning history is remediation only — forks, colleagues’ clones, and cached views all still exist. The chain of public incidents is complete: Uber in 2016 had their AWS keys downloaded from GitHub, exposing their S3 backup repository, affecting 57 million users, resulting in a $148 million settlement and the then-CSO being convicted for covering it up; Toyota T-Connect pushed source code containing access keys to GitHub in December 2017, which wasn’t discovered until September 2022, exposing 296,000 customers’ information. Scale numbers come from GitGuardian’s 2026 report: from 2024 to 2025, publicly leaked secrets on GitHub increased by 28.65 million, a 34% year-over-year growth, with AI service keys growing 81%; of the leaked credentials verified in 2022, 64% were still valid when re-tested in early 2026 — most people simply don’t rotate after a leak.
Layer 7: CI/CD. GitHub’s secret scanning covers full history and provides free coverage for public repositories; push protection blocks secrets before they’re pushed. The real gap is CI log masking: the official docs note that structured values containing whitespace (JSON/XML/YAML) “significantly reduce the probability of being properly masked” — and CI logs themselves can print environment variable values. CI supply chain is a higher-dimensional threat: in March 2025, tj-actions/changed-files, used by over 23,000 repositories, had a tag modified to inject a backdoor that wrote runner memory secrets into logs, prompting a CISA alert (CVE-2025-30066); in 2021, Codecov’s Bash Uploader was tampered with, exfiltrating client CI environment variables for months.
Layer 8: Docker and Cloud. Docker’s official documentation explicitly warns not to use ARG for secrets — build arguments persist in the final image metadata, provenance, and image history; the correct approach is BuildKit secret mounts. Empirical data: a study covering 337,171 Docker Hub images and 8,076 private registry images found that 8.5% of images overall contained secrets — 52,107 private keys in total (9.0% for Docker Hub alone); the Codecov incident’s starting point was the attacker extracting GCS credentials from a public self-hosted image’s history layers. The cloud side is structurally identical: the 2017 public S3 bucket leak wave (Accenture et al.); Terraform officially acknowledges that state files are plaintext and sensitive values are written as-is; AWS officially recommends storing sensitive credentials in Secrets Manager rather than Lambda environment variables.

The bad news about this map is that it closes into a ring: credentials leaked from any single layer can be used to attack the other seven — for instance, BadgerDAO in 2021 was attacked via a leaked Cloudflare key that injected frontend scripts, fishing out approximately $120 million — one layer falls, all seven get attacked.
Six: Why AI Coding Makes the Problem Worse
This is the part the article truly wants to discuss. The core judgment in one sentence: In the age of AI Agents and AI Coding, the biggest security risk is not that attackers are getting smarter, but that the speed at which developers produce and deploy software has outpaced their ability to understand security boundaries.
The evidence comes in three layers.
Layer 1: Code quality itself. A user study published at ACM CCS 2023 by Perry et al. from Stanford and other institutions was the first large-scale empirical study: participants using AI assistants wrote significantly less secure code while being more likely to believe their code was secure — overconfidence is an amplifier for insecure code. A control group study (Lost at C, USENIX Security 2023) in C programming scenarios reached a milder, opposite conclusion, suggesting this isn’t fate but a condition-dependent risk — but vendors’ ongoing testing shows the risk is widespread: Veracode’s 2025 GenAI report tested Java/Python/C#/JavaScript generated by multiple models, finding 45% of samples failed security testing and introduced OWASP Top 10-level vulnerabilities, with Java’s failure rate as high as 72%. More troubling is the perception gap: in Snyk’s 2024 survey, over 75% of developers believed AI-written code was more secure than human-written code, while 56% acknowledged that AI-generated code sometimes or frequently introduced security issues; only about 10% of developers scanned most of their AI-generated code. GitClear’s analysis based on 211 million lines of changes showed a structural decline: clone/copy-paste went from 8.3% in 2021 to 12.3% in 2024, with “copy-paste” lines exceeding “refactored move” lines for the first time in history. Copy-paste debt doesn’t encrypt keys, but it makes auditing “where keys appeared” practically impossible.
Layer 2: Secret-specific data. GitGuardian’s 2026 report provides a directly relevant new data point: Claude Code-assisted commits have a secret leak rate of 3.2%, more than double the 1.5% baseline of all public commits. The mechanism can be reasoned through (the behavioral patterns below are common observations in the security community; there is not yet a one-to-one public case mapping): the AI’s objective function is “make the code run,” while leaks happen in the future, on someone else’s cost sheet, with no pain signal at generation time; one of the common patterns in training data is “put the key in a convenient spot for debugging”; and when an Agent has read permissions, files like .env are right at its fingertips. The “vibe coding app loses $300 due to API key leak” Hacker News post from 2025, along with the “forced to shut down and rewrite” cases documented by security vendors, are individual-scale samples of this mechanism. The term “vibe coding” itself was coined by Karpathy in February 2025 (“fully surrender to vibes, embrace exponential growth, and even forget the code exists,” paraphrased); security criticism followed swiftly, with ReversingLabs’ summary being the sharpest: the volume of AI-generated code has already exceeded the capacity of human review, and vibe developers don’t read code, don’t write tests, and let vulnerabilities and malicious packages go straight to production.
Layer 3: The Agent itself. When you hand filesystem, shell, Git, cloud, and network permissions to an Agent that acts autonomously, the leakage surface escalates from “code written poorly” to “systems being roamed.” At the standards level, OWASP LLM Top 10 (2025) has LLM05 (Improper Output Handling) and LLM06 (Excessive Agency) directly hitting this category; OWASP published “Agentic AI – Threats and Mitigations” in February 2025, and in December 2025 released the 2026 version of the Agentic Applications Top 10 (the published draft names three: Agent Behavior Hijacking, Tool Misuse and Exploitation, Identity and Privilege Abuse). At the toolchain level, MCP’s official specification itself states it’s an “implicit trust” model and requires clients to treat MCP servers as untrusted input sources; Invariant Labs’ April 2025 real-world test is a footnote on this path — a malicious MCP tool description guided the Cursor agent to read away ~/.ssh/id_rsa. Code Agents themselves can also be compromised: Claude Code has successively fixed a DNS data exfiltration vulnerability (CVE-2025-55284) and a malicious repo configuration leading to RCE/key theft (CVE-2025-59536, CVSS score 8.7).

The positive answer on the permissions model front is actually being pursued by all sides: Claude Code’s official security documentation is structured around Manual mode defaulting to read-only, dangerous commands being reviewed by classifiers, filesystem and network sandboxing, and bounded working directories, with one sentence repeated throughout — “Claude Code only has the permissions you grant it”; Copilot’s agent mode is embedded in the workspace trust system; Replit has even launched “safe vibe coding,” scanning and intercepting secrets at AI generation time. The leverage point for risk prevention isn’t in the model — it’s in the hand that grants permissions.
Returning to that word “convenient” from the opening. AI doesn’t necessarily hack into your system — it may simply use the fastest path to complete your task, and the fastest path often looks like this: stuff server-side config into pageProps so the page stops throwing an error; slap a NEXT_PUBLIC_ prefix on a key so the build doesn’t fail; temporarily disable auth to get the flow working, then commit the disabled auth to production along with everything else. It has no malice — it just doesn’t know where the boundary is. And knowing the boundary was supposed to be the responsibility of “the person writing the code.” When the speed of writing code exceeds the speed of understanding boundaries, the interest on the security debt goes from “an occasional incident” to “structural baseline leakage.”
Seven: A Genuinely Secure Secret Management Architecture
The correct shape and the wrong shape are each a chain.
The wrong chain (every case above lives on this chain):
| |
The correct chain:
| |
The correct chain has six structural requirements, each with official backing:
- Secret Manager: ASVS (Application Security Verification Standard) 4.0.3 requirement 6.4.1 and 5.0 requirement 13.3.1 (content-corresponding, not an official mapping) for key vault requirements; the best practices of AWS Secrets Manager, GCP Secret Manager, and Azure Key Vault (least privilege, version references, audit logs) all point to the same thing — the creation, storage, access, and destruction of secrets must have a carrier independent of the application.
- Environment Isolation: Each environment gets its own vault, minimizing blast radius (the conceptual approach from Azure’s official best practices); production credentials never enter development environments or the Agent’s working context.
- Least Privilege: Grant the minimum permissions per service; prefer rotatable short-lived credentials and workload identity over long-term keys. Stripe’s newer
rk_Restricted Key represents the industry direction: remove “unlimited-permission keys” from the default options. - Server-Side Signing: All signing, encryption, and private-key-holding operations stay on the server (BFF / API routes); the browser gets sessions (httpOnly cookies) or one-time user authorizations, not materials that can sign long-term. A secp256k1 private key never has travel expenses to the frontend.
- Key Rotation: Rotation is a first-class citizen, not post-incident remediation. AWS’s official leak-response blog prescribes the order: first assess the credential’s reach, then immediately deactivate (disable, not delete — deactivation is reversible); GitHub’s official stance is likewise that revoke/rotate takes priority over cleaning history — once a key is revoked, the ciphertext in history is harmless.
- Secret Scanning Pre-deployment: push protection + gitleaks pre-commit + CI full-history scanning + scanning of build artifacts (bundles, images, map files), forming four gates. Plus response minimization: APIs return DTOs (Data Transfer Objects) containing only necessary fields rather than entire rows (OWASP EDE’s “never rely on client-side filtering”), with schema validation on responses.
An acceptance sentence that can hold up in a team: “What the server knows” and “what the browser can obtain” must be two deliberately designed sets; any data crossing this line must have a written reason and type. A crossing without a reason is C1; a crossing without a type is C2.
Eight: A Security Checklist for Independent Developers
Each item in this checklist corresponds to a layer above, ordered “stop the bleeding first, then harden”; all checks below target your own applications and assets — running them against any non-owned, unauthorized target constitutes overreach:
- □ Check Git history:
gitleaks detect --allor trufflehog to scan full history; on a hit, revoke/rotate first, then consider cleaning history - □ Check public repositories: confirm the repo is not public; enable GitHub push protection and secret scanning alerts
- □ Check build artifacts: scan the dist/build directory for
NEXT_PUBLIC_,VITE_,REACT_APP_,AKIA,-----BEGIN,sk_, and similar patterns - □ Check page source: view-source the homepage; inspect the
__NEXT_DATA__JSON block and RSC payload for anything that shouldn’t be there - □ Check /_next/data and API responses: do APIs return entire objects? Are fields beyond what the page needs?
- □ Check Source Maps: is map generation disabled in production; if uploaded to Sentry, are
.mapfiles cleaned from the deployed artifacts? - □ Check browser storage: are there keys, tokens, or ciphertext in localStorage/sessionStorage; does session management use httpOnly cookies?
- □ Check CI/CD logs: are any secrets printed in logs; are outputs from sensitive steps masked?
- □ Check Docker images:
docker historyand public registry image layers; are build arguments using BuildKit secret mounts? - □ Check the environment variable chain: for a given variable
X, which layer of.envdoes its final value come from — can anyone answer? - □ Check AI-generated code gates: scan on generation (semgrep/gitleaks in CI), review on generation, write key-boundary rules in project rules files
- □ Check Agent permissions: is the Agent’s shell, network, and cloud credential set minimal; are sensitive projects run in sandboxes/containers?
Closing
If this article were compressed into one sentence: the first lesson of frontend security isn’t “prevent injection” — it’s first understanding which bytes will be sent to the browser. In the past, this lesson was enforced by code review; today, mass-produced code comes from a generator that doesn’t care whether this process is secure — which isn’t a reason to reject AI, but rather a reason to move the security gate from “when code is written” to “before code enters production.”
Review doesn’t have to be as fast as generation, but it can’t be absent.
References
- Next.js official docs: getServerSideProps, Environment Variables, Server and Client Components, Data Security Guide, CDN Caching, productionBrowserSourceMaps, Taint API
- React official: Server Functions / experimental_taintObjectReference; ECMA-426 Source Maps specification (tc39.es)
- OWASP: API Security Top 10 (2019/2023), Web Top 10 2021, ASVS 4.0.3 and 5.0, WSTG-INFO-05, LLM Top 10 2025, Agentic AI Threats & Mitigations, MCP Security Cheat Sheet
- Stripe official Keys docs (including Restricted Keys
rk_section); Google Firebase official API Keys docs; ethereum.org Accounts docs; Vite / CRA / webpack official configuration docs - GitHub official: secret scanning, push protection, Security hardening for GitHub Actions, Removing sensitive data; 2024-02-29 official blog (over 1 million leaked secrets in the first eight weeks)
- GitGuardian “State of Secrets Sprawl 2026”; Veracode “2025 GenAI Code Security Report”; Snyk “AI
