Why AI-generated web apps fail in predictable ways
Language models learn from public tutorials, starter templates, and example snippets where shortcuts are normal. When you prompt an editor to wire up authentication, Stripe checkout, a database client, or an AI feature, the generated code frequently:
- places a server-only credential inside a browser-visible environment variable prefix such as
NEXT_PUBLIC_orVITE_; - leaves development defaults enabled in production, including public Swagger or OpenAPI documentation, GraphQL introspection, verbose stack traces, or framework debug panels;
- pins older package versions from the model’s training window instead of the latest patched releases;
- omits response security headers, email authentication records, and backup verification because the app still loads without them.
The OWASP Top 10 groups these failures under Broken Access Control, Security Misconfiguration, Cryptographic Failures, and Vulnerable and Outdated Components. Catching them does not require an enterprise security team; it requires checking what your live deployment actually exposes after every release.
Check it now. The frontend secret leak checker scans public HTML, __NEXT_DATA__ and up to four first-party JavaScript bundles across 12 live credential families without storing any secret; the lockfile CVE checker parses lock files and SBOMs locally in your browser and groups OSV and CISA KEV advisories into one upgrade command per package. No account, and the address is not stored.
1. Audit every credential reachable from the browser
Anything sent to a visitor’s browser is public. When an AI assistant scaffolds a frontend client for payments, email, storage, or an LLM API, verify that only publishable keys reach client bundles.
Check these four places on every production build:
- Client environment prefixes: inspect every
NEXT_PUBLIC_*,VITE_*,REACT_APP_*, andNUXT_PUBLIC_*variable. Never put Stripesk_live_keys, AWSAKIAkeys, OpenAI or Anthropic API keys, Resend or SendGrid keys, database connection strings, or Supabaseservice_roletokens in client-prefixed variables. - Server-rendered page state: inspect
<script id="__NEXT_DATA__">and__NUXT__payloads in the raw HTML of your public pages. Passing a whole database row or configuration object from a server loader straight into page props often serializes internal fields straight into the HTML response. - Inline scripts and HTML comments: check rendered pages for pasted webhook URLs, temporary tokens, or test credentials left behind during debugging.
- Public
.envand backup files: verify that/.env,/.env.production,/.git/HEAD, and database dumps return 404 or 403 rather than file contents.
If a live secret appeared on a public page even briefly, treat it as known. Rotate the credential in the provider console first, move the call behind a server route, and check provider usage logs. For a detailed breakdown of key boundaries and rotation steps, read leaked API keys in frontend JavaScript.
2. Turn off production source maps and public API schemas
Automated scanners and AI reconnaissance scripts map a newly deployed site in seconds by requesting predictable metadata paths.
- JavaScript source maps (
.js.map): if your bundler publishes.mapfiles alongside minified bundles, anyone can reconstruct your original TypeScript and React components, internal route paths, and validation logic. Keep source maps private or upload them only to your error tracker rather than serving them publicly. - OpenAPI and Swagger files (
/openapi.json,/swagger.json): FastAPI, Express, and Spring starters often expose full endpoint specifications by default. Unless your API is intentionally public, require authentication or disable the schema route in production. - GraphQL introspection (
/graphql): disable schema introspection in production environments so unauthenticated requests cannot enumerate every query, mutation, and internal field name. - Framework debug tools: confirm that Symfony Profiler (
/_profiler/), Laravel Telescope (/telescope), Rails info (/rails/info/properties), and Spring Boot Actuator (/actuator/env) are unreachable from the public internet.
The OWASP API Security Top 10 highlights Improper Inventory Management and Security Misconfiguration as leading causes of unauthorized API access. Closing public metadata endpoints shrinks what automated crawlers can discover without affecting normal users.
3. Check exact dependency versions across your real stack
AI assistants frequently generate package.json, requirements.txt, Gemfile, Cargo.toml, or composer.json files containing package versions from months or years ago. Worse, transitive dependencies pull in dozens of libraries you never explicitly asked for.
Do not rely only on public HTTP headers to spot vulnerable software. Modern frameworks strip version headers or run behind a CDN, and Linux distributions often backport security patches without changing an upstream version banner. Instead:
- match exact locked versions from your build lockfile or SBOM (
package-lock.json,pnpm-lock.yaml,yarn.lock,composer.lock,requirements.txt,poetry.lock,uv.lock,Gemfile.lock,Cargo.lock,go.mod, or CycloneDX/SPDX); - prioritize flaws listed in CISA’s Known Exploited Vulnerabilities Catalog over low-severity backlog noise;
- group multiple advisories affecting the same package so you perform one clean upgrade instead of chasing dozens of overlapping CVE alerts.
For an ecosystem-by-ecosystem patching workflow, see continuous CVE and Exploit Watch monitoring.
4. Verify CORS, cookies and response security headers
Generated backends often copy permissive development CORS snippets such as reflecting any incoming Origin header alongside Access-Control-Allow-Credentials: true. When a site reflects arbitrary origins with credentials enabled, a malicious third-party page can make authenticated requests on behalf of signed-in users.
Confirm these baseline transport and browser controls on production:
- HTTPS and HSTS: redirect every HTTP request to HTTPS and send a valid
Strict-Transport-Securityheader with an appropriatemax-age. - Session cookies: mark authentication cookies
HttpOnly,Secure, andSameSite=Lax(orStrict). - Framing and content sniffing: set
X-Content-Type-Options: nosniff,X-Frame-Optionsor CSPframe-ancestors, and a sensibleReferrer-Policy. - Explicit CORS allow-list: allow only the exact frontend origins that need API access, never a reflected origin wildcard with credentials.
You can inspect your current response headers right away with the free security headers checker or run a broader external check at /scan.
5. Lock down email authentication and DNS hygiene
Even if your web app only sends password resets and receipts, missing SPF and DMARC records allow third parties to spoof mail from your domain, which hurts inbox deliverability and exposes users to phishing. Likewise, an unused subdomain CNAME pointing to a deleted cloud hosting app creates a subdomain takeover path where someone else can serve pages under your domain and read parent-domain cookies.
After launch, watch DNS records (A, AAAA, NS, MX, TXT, CAA, CNAME) for unexpected edits and keep DMARC moving from p=none toward p=quarantine or p=reject once legitimate senders pass alignment.
6. Confirm backups before patching fast
Speed is the main advantage of AI-assisted development, and it is also how teams break production during an emergency fix. Before upgrading a framework major version, applying a database migration, or rotating infrastructure settings, verify that a recent backup exists outside the primary server and record how it is restored.
7. Pair external monitoring with your coding assistant
Running a checklist once before launch is useful, but AI-built apps change daily. Every new prompt can reintroduce a NEXT_PUBLIC_ secret, re-enable a debug route, or pull in a vulnerable dependency.
Beamfar checks live websites continuously from outside and, on paid plans (Solo, Team, Agency, and Agency Plus), includes daily security checks, Exploit Watch against CISA’s Known Exploited Vulnerabilities list, passive public secret detection, lockfile matching across JS, PHP, Python, Ruby, Rust, Go, Java, and .NET, and optional read-only connected layers. Free plans cover one site with five-minute uptime, TLS, and DNS checks plus read-only REST and MCP access (3,000 requests a month) without daily security scans.
If you build in Claude Code, Cursor, Codex, or Gemini CLI, you can also connect the read-only Beamfar MCP server so your coding assistant reads live headers, verified findings, exposed surfaces, and blind spots directly from production while auditing your local repository. See pricing for exact plan boundaries or run a one-off free site check first.
Sources
Read on . Standards and vendor pages change; confirm the current text before you rely on it.
- OWASP Top 10 Web Application Security Risks (owasp.org)
- OWASP API Security Top 10 (owasp.org)
- CISA Known Exploited Vulnerabilities Catalog (www.cisa.gov)