Back to Blog
Security

How Hackers Break AI-Built Apps—and How to Fix Them

An AI coding agent can produce a working feature while missing the rule that keeps it safe. Check five attack paths—authorization, dependencies, secrets, untrusted input, and race conditions—with prompts, commands, and manual checks before launch.

“Check security” is not a test plan. It lets an agent choose what to inspect, skip what it did not think of, and report a tidy result. Security review works better when you name the attack paths, inspect server-side enforcement, and verify the behavior outside the interface.

This guide covers five paths that repeatedly matter in AI-built web apps: broken access control, compromised or invented dependencies, exposed secrets, untrusted input, and race conditions. It is not a list of every possible attack. Use it as a practical first pass, then review the rest of the OWASP Top 10:2025.

The OWASP list changed

The 2025 edition has two new categories and one consolidation. OWASP used data from more than 2.8 million applications, then used practitioner survey responses to promote two risks that automated testing data can underrepresent. The Top 10 is an awareness guide, not a complete security standard or a certification.

  • A01 — Broken Access Control
  • A02 — Security Misconfiguration
  • A03 — Software Supply Chain Failures (new)
  • A04 — Cryptographic Failures
  • A05 — Injection
  • A06 — Insecure Design
  • A07 — Authentication Failures
  • A08 — Software or Data Integrity Failures
  • A09 — Security Logging & Alerting Failures
  • A10 — Mishandling of Exceptional Conditions (new)

Security Misconfiguration moved from #5 in 2021 to #2 in 2025. Injection moved from #3 to #5. SSRF was consolidated into Broken Access Control. Software Supply Chain Failures expanded the old vulnerable-components category to cover dependencies, build systems, and distribution. See OWASP’s methodology and change notes.

1. Broken access control: the ID in the URL is not permission

A user changes /api/orders/1043 to /api/orders/1044 and receives somebody else’s order. An admin link is hidden, but its API still answers a regular user. A request accepts role: "admin" or changes the owner because the handler copies every field from the request body. A usage limit exists on the button, but the server never checks it.

These are authorization failures. Authentication answers “who signed in?” Authorization must also answer “may this person perform this action on this specific record?” OWASP ranks this category first. Its dataset reports findings across the applications it assessed; that sample result is not a claim that every application in the world has the same bug rate. See the A01 details.

For each read or write, check the user’s role and record ownership in the server-side query or immediately before the action. Build update objects from an allowlist. Derive fields such as user_id, price, and role from trusted server state rather than copying them from the request. Repeat the check in every route that can reach the same data.

If the app uses Supabase or another database API exposed to browsers, enable and test row-level security on every table reachable by public or authenticated client roles. Keep service-role credentials server-side. Also review A02 and A10: remove default credentials, turn off production debug output, return safe errors, and fail closed when validation or an authorization check cannot complete.

Send this to your agent

Code
Review every server-side route and mutation for access control.
Return a table with: route, required role, record it reads or changes,
and the exact server-side ownership check.

Separately list checks that exist only in the browser, fields accepted
from request bodies without an allowlist, and routes that accept an ID
without checking who owns that record.

Do not change code. Give file paths, line numbers, and evidence.

Tenzai’s small 2025 coding-agent experiment found examples where an API checked ownership for one role but skipped it for another, and an unauthenticated delete path bypassed its ownership check. That is why a role check alone is not enough. Read the test details.

2. Supply-chain failures: review what the agent installs

A package manager can execute code during installation. A compromised maintainer account can publish a malicious release under a familiar name. A coding model can also suggest a plausible package that does not exist yet; an attacker may register it before someone installs it.

In September 2025, Shai-Hulud showed how a self-propagating npm worm could steal credentials and republish infected packages. In August 2026, Microsoft described CHAINDROP affecting more than 400 packages. It could propagate through stolen npm credentials and use stolen GitHub credentials to add Claude Code or VS Code configuration files to repositories. In March 2026, malicious Axios releases were available for about three hours after a maintainer account was compromised. These incidents are documented by Microsoft and the Axios maintainers.

Hallucinated package names are a separate risk. A USENIX Security 2025 study checked 2.23 million package references from generated code and found 19.7% referred to packages that did not exist in PyPI or npm at the time. A later 2026 preprint found lower hallucination rates among newer models, but still reported repeated nonexistent package names. These are measurements of particular models and prompts, not a rate for every install suggestion. Verify the package, publisher, repository, release history, and intended use before installing it. See the USENIX study and the 2026 replication.

Keep a lockfile, review dependency changes, prefer trusted maintainers, and scan production dependencies against a vulnerability database. Do not run install commands supplied by an agent until you have checked what package they resolve to.

Send this to your agent

Code
Review the dependency manifests and lockfiles without changing them.
For each direct dependency, report its purpose, exact locked version,
publisher or maintainer, official source, release history, and direct
and transitive dependency count.

Flag packages added recently, names that cannot be confirmed in the
official registry, suspicious install scripts, and packages that appear
unused. Do not update or remove anything. Cite the file and line.

3. Secrets and cryptography: remove exposure, then rotate

A key in source code or a public build is already exposed. Deleting the line does not revoke the key, and deleting the commit does not guarantee that nobody can still reach it in Git history or a fork. Revoke or rotate the credential first, then clean up its storage and history. Never paste the value into an AI chat or a bug report.

GitGuardian counted 28.65 million newly exposed hardcoded secrets in public GitHub commits during 2025, up 34% from 2024. Its report measured a 3.2% secret-leak rate in Claude Code-assisted commits versus a 1.5% baseline across public GitHub commits. That comparison is an observed association, not proof that the tool alone caused the leaks. See the 2026 report.

Store secrets in server-side environment variables or a secrets manager. Keep them out of client-prefixed environment variables, browser JavaScript, logs, screenshots, and prompts. Use established cryptographic libraries and password-hashing functions; do not design your own encryption or password storage.

To scan the full Git history with Gitleaks, run this from the repository root:

Code
gitleaks git -v .

Review the output locally and avoid pasting secret values into a chat. If a valid credential appears in any historical commit, revoke it even if the current files are clean.

Send this to your agent

Code
Review source files, build configuration, browser-bound code, logs, and
the full Git history for credentials or key material.

Do not print any secret values. For each finding, report only the file,
commit, line, likely service, and recommended rotation steps. Identify
public environment-variable prefixes and explain whether their values
are included in the browser bundle.

Do not edit files or rewrite Git history.

4. Untrusted input: validate at the boundary and encode at output

Forms are only one source of external data. An attacker can also control URL parameters, uploaded files, webhook bodies, imported records, and responses from third-party services. Trace each value from entry to database, file system, command, and rendered page.

  • Use parameterized queries for database values. Never build SQL by joining request text into the query.
  • Escape output for its exact context: HTML text, HTML attributes, JavaScript, URLs, and CSS have different rules. Use the framework’s safe rendering path; sanitize HTML only when rich HTML is intentionally allowed.
  • For uploads, check file size and content, not only the filename extension. Generate the stored filename and keep executable files outside the public web root.
  • For payment and other webhooks, verify the provider’s signature over the raw body before writing the event to the database. Add replay protection where the provider supports it.
  • If the server fetches a user-provided URL, use an explicit host and scheme allowlist, reject private and link-local destinations, and re-check redirects and DNS resolution to prevent SSRF.

Parameterized SQL has a clear safe pattern. Browser rendering and server-side URL fetching depend on context, so a generic “sanitize everything” instruction is not enough.

Send this to your agent

Code
Map every externally controlled value: form fields, route parameters,
query strings, uploads, webhooks, and third-party API responses.

For each value, show validation at the server boundary, storage or
execution sinks, and output encoding. Verify SQL is parameterized,
HTML is rendered safely, uploads are checked by content, webhook
signatures are verified before database writes, and URL fetches cannot
reach private network addresses.

Do not change code. Return file paths, line numbers, and concrete
examples of unsafe input and the resulting behavior.

5. Races, business rules, and server-side limits

Some failures appear only when requests overlap. Two checkout requests can redeem one coupon twice, apply the same credit twice, or create duplicate work. A user can also change a price or quantity if the server trusts client-supplied values.

For each operation that must happen once, check how the database enforces it. A transaction helps keep related writes together; a unique constraint, conditional update, or idempotency key can prevent duplicate effects. A check in application code alone may race if two requests pass it at the same time.

Apply rate limits on the server to login, registration, password reset, public forms, and routes that call paid services. The limit must use client identity derived from trusted proxy configuration; blindly trusting X-Forwarded-For lets a caller spoof their address. Test concurrency and limits in a staging environment using test accounts and payment modes, not against real customer charges.

Send this to your agent

Code
Find operations that must happen once: payments, credits, coupon use,
account creation, and other one-time actions.

For each, explain what two concurrent requests can do and identify the
database transaction, unique constraint, conditional update, or
idempotency key that prevents duplicate effects. List routes without
server-side rate limits, including login, registration, password reset,
forms, and paid API calls.

Do not run requests against production or change code. Give file paths,
line numbers, and a safe staging test plan.

What the measurements say

Security results depend on the test. Veracode’s 2025 study sent more than 100 models 80 short code-completion tasks; 45% of generated completions failed the security checks. Its Fall 2026 report raised the average pass rate from 56% to 62%. The improvement was uneven: the October 2026 mean was 83.7% for SQL injection tasks and 18% for XSS tasks. These are controlled code-generation results, not estimates of how many production apps are vulnerable. Veracode explains the methodology and limitations.

A separate Tenzai experiment asked five coding agents to build 15 applications and found 69 vulnerabilities. It found no exploitable SQL injection or XSS in those apps, but all five agents introduced an SSRF flaw in the test scenario, none of the 15 apps had proper CSRF protection, and the generated apps omitted common security headers. This small experiment is one sample, not a verdict on every tool or application. Read Tenzai’s full test.

The useful lesson is not that every generated line is unsafe. It is that working code and secure code are different checks. Some patterns have strong framework defaults; ownership rules, business logic, and missing controls need deliberate review.

Four checks to run before launch

Run dependency and template scanners only against projects and websites you own or are authorized to test. These tools find known patterns; they do not prove that business logic or access control is correct.

Code
# Node.js projects: known production dependency advisories
pnpm audit --prod

# Scan supported lockfiles recursively against the OSV database
osv-scanner scan source -r .

# Scan the repository's Git commit history for secrets
gitleaks git -v .

# Scan an authorized web target for known templates and exposures
nuclei -u https://your-authorized-host.example

Check the current documentation for OSV-Scanner, Gitleaks, and Nuclei. A clean scan does not demonstrate that IDs are owned by the current user, a webhook signature is checked, or a money-moving action cannot run twice.

What automation cannot tell you

A dependency scanner can match a locked package against known advisories. A secret scanner can detect credential patterns. A template scanner can find known exposures. None of those results answers whether a user can fetch a neighbor’s order by changing an ID, bypass a purchase rule through a valid sequence of requests, or trigger one charge twice.

For those checks, use an account with limited permissions, try adjacent record IDs in a test environment, submit the same action concurrently, and verify that the server—not just the interface—rejects it. Keep the tests reproducible and use data that cannot charge or email a real customer.

For a reusable, evidence-based review prompt, see Send Your Agent: Audit a Project Against OWASP Top 10:2025.

Pre-launch checklist

  • Every server-side route checks the current user’s role and ownership of the specific record.
  • Request fields use an allowlist; clients cannot set roles, owners, or trusted prices.
  • Dependencies and newly added packages have been checked against their official registry and publisher.
  • Secrets are outside browser code, logs, and chat history; Git history has been scanned.
  • Any exposed credential has been revoked or rotated, even if its commit was removed.
  • SQL queries are parameterized and rendered output follows context-specific encoding rules.
  • Webhook signatures are validated before event data is stored.
  • Uploads and server-side URL fetches have explicit content and destination checks.
  • Payments and other one-time operations resist duplicate and concurrent requests.
  • Authentication, forms, and paid API routes have server-side rate limits.
  • Debug details stay in server logs; error responses do not disclose secrets or internals.
  • Scanners are treated as evidence for specific checks, not as proof that the app is secure.
Back to Blog