AI coding assistants produce clean-looking TypeScript, Python, SQL, and Terraform faster than a human reviewer can comfortably read a 900-line pull request. The code compiles. Unit tests pass on the first try. Yet that speed changes where defects hide, because a reviewer skimming a big diff rarely notices what was quietly left out.

In practice, coding models solve one prompt at a time. Ask for a new download endpoint and you get a clean route handler, though the assistant has no reason to remember how your existing routes enforce tenant isolation unless someone or something checks. How do you catch missing organization_id filters, invented package names, or overbroad IAM policies when large diffs land all week? Relying on human eyeballs alone is not enough.

Our production readiness guide for AI-built applications covers architecture, hosting, and operational ownership at the project level. Below, we walk through the five code-level failure patterns that pull-request reviewers and CI pipelines need to block before merge.

Broken Object-Level Authorization on Generated Endpoints

Coding models tend to write each route handler in isolation. A developer prompts for an invoice download or webhook replay endpoint, and the assistant produces a tidy query filtered by primary key (WHERE id = $1). It checks that the caller holds a valid JWT session, which looks thorough enough at a glance, except authentication alone does not verify that the invoice actually belongs to session.organization_id.

// VULNERABLE: Authenticates the user session, then looks up the record solely by primary key
app.get('/api/invoices/:invoiceId', requireSession, async (req, res) => {
  const invoice = await db.query('SELECT * FROM invoices WHERE id = $1', [req.params.invoiceId]);
  return res.json(invoice.rows[0]);
});

// FIXED: Bind organization_id inside a repository helper + enforce PostgreSQL Row-Level Security
app.get('/api/invoices/:invoiceId', requireSession, async (req, res) => {
  const invoice = await db.query(
    'SELECT id, number, total_cents, status FROM invoices WHERE id = $1 AND organization_id = $2',
    [req.params.invoiceId, req.session.organizationId]
  );
  if (invoice.rowCount === 0) return res.sendStatus(404);
  return res.json(invoice.rows[0]);
});

Expecting human reviewers to catch every missing WHERE clause across dozens of endpoints does not scale well. Require a tenant context inside a typed data-access wrapper, and back it with PostgreSQL Row-Level Security (ENABLE ROW LEVEL SECURITY and FORCE ROW LEVEL SECURITY) so an omitted filter returns nothing instead of leaking another customer's data.

Invented Package Names and Lifecycle Install Scripts

Language models occasionally predict package names across npm, PyPI, and Go modules—things like pg-cursor-stream-async or fastapi-jwt-guard—that sound completely ordinary even though no such library exists. Attackers watch for those recurring hallucinations, register the unclaimed name (a trick sometimes called slopsquatting), and publish a postinstall script that harvests .env files and cloud credentials off developer laptops and CI runners.

# Block arbitrary preinstall/postinstall script execution during deterministic CI builds
npm ci --ignore-scripts

# Inspect publication date, maintainer roster, and verified source repo before approving any new dependency
npm view <package-name> time.created maintainers dist.tarball repository.url

So, what keeps an invented dependency out of your repository? Turn off unattended execution of npm install or pip install for net-new libraries, commit your lockfiles (package-lock.json, uv.lock, poetry.lock), and fail CI whenever an unreviewed package shows up in a diff.

Time-of-Check to Time-of-Use State Races

Left to themselves, assistants write sequential code because sequential code reads cleanly. Fetch a wallet balance, seat count, or coupon redemption counter into application memory, check if (credits >= cost), and run a separate UPDATE query. Single-user tests pass every time. Send twenty concurrent HTTP requests at once, however, and all twenty SELECT queries pass before the first write commits, letting a caller overdraw credits or trigger duplicate refunds.

-- FIXED: Atomic conditional UPDATE with RETURNING + unique idempotency key constraint
BEGIN;

INSERT INTO processed_idempotency_keys (organization_id, idempotency_key)
VALUES ($1, $2);

UPDATE credit_wallets
SET available_credits = available_credits - $3,
    updated_at = now()
WHERE organization_id = $1
  AND available_credits >= $3
RETURNING available_credits;

-- Commit only if 1 wallet row matched; otherwise ROLLBACK and return HTTP 402/409
COMMIT;

Moving the balance check into a conditional UPDATE inside the same transaction as a unique idempotency insert lets PostgreSQL serialize concurrent requests cleanly.

Unverified Inbound Webhooks and Outbound SSRF Fetchers

Two network-facing bugs turn up regularly in generated SaaS scaffolding, sometimes in the very same sprint. One is trusting inbound JSON webhooks from Stripe, Clerk, GitHub, or Shopify without verifying HMAC signatures against the raw request bytes. If middleware parses JSON before the signature check runs, verification fails, and an assistant troubleshooting the error will sometimes strip the signature check out to get tests green.

// FIXED webhook handler: verify HMAC-SHA256 against raw bytes BEFORE JSON parsing
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
  let event;
  try {
    event = stripe.webhooks.constructEvent(
      req.body,
      req.headers['stripe-signature'],
      process.env.STRIPE_WEBHOOK_SECRET
    );
  } catch (err) {
    return res.status(400).send('Invalid webhook signature');
  }
  await handleIdempotentStripeEvent(event);
  return res.sendStatus(200);
});

The companion bug runs outbound: "import from URL" or webhook-preview handlers that fetch user-supplied URLs straight from backend servers. Without egress checks, callers can probe internal VPC services or the cloud instance metadata endpoint (169.254.169.254). Enforce IMDSv2 on EC2 (HttpTokens = required, hop limit 1), resolve DNS once through an SSRF-safe HTTP dialer that blocks RFC 1918 private ranges, loopback, link-local (169.254.0.0/16), and IPv6 unique-local addresses, and never echo raw upstream response headers back to the client.

Wildcard Cloud IAM Policies, Client Secret Leaks, and Unescaped Output

Watch what happens when an autonomous coding agent hits an AWS AccessDeniedException or an undefined browser variable while iterating on a build. Its immediate incentive is making the error disappear. It is not unheard of for an agent to widen Terraform IAM statements to "Action": "*" and "Resource": "*", or rename a private server key with a NEXT_PUBLIC_ or VITE_ prefix—specifically handing that secret to the frontend bundler so it ships inside public JavaScript files. A similar shortcut shows up when LLM-generated Markdown or HTML gets rendered through dangerouslySetInnerHTML without strict DOMPurify sanitization, turning indirect prompt injection into stored XSS.

Pairing focused human code review with deterministic CI checks catches both structural design gaps and mechanical slips before merge:

PR Security Gate Human Reviewer Check Automated CI Enforcement
Tenant and role authorization Every read and write query binds organization_id and role checks server-side Cross-tenant integration test suite asserting Tenant A receives 403/404 on Tenant B IDs
Dependency provenance Zero unrecognized packages or unpinned floating ranges in package.json or pyproject.toml npm ci --ignore-scripts, lockfile lint, OSV/Dependabot check, and license gate
SQL and output encoding Zero string-interpolated SQL; LLM and Markdown output sanitized before DOM rendering Semgrep or CodeQL rules blocking raw template-literal SQL and unsanitized HTML sinks
Secrets and cloud IAM No NEXT_PUBLIC_ or VITE_ secret keys; IAM scoped to exact bucket and KMS ARNs Gitleaks or TruffleHog pre-receive and CI scan; Checkov or tfsec failing wildcard IAM resources

If your team builds heavily with Cursor, Claude Code, or Copilot and is preparing for enterprise customer audits, these CI gates pay for themselves quickly. When you want an independent engineering review before launch, pair them with our AI-built application production review and grey-box web application penetration testing.