AIToday
AI Coding AssistantsAI Safety & AlignmentZenn AI/MLPublished: Oct 10, 2026, 10:00 JST

AI-written Next.js 15.5.2 app: all 12 attacks worked

AI-written Next.js 15.5.2 app: all 12 attacks worked

In a small Next.js 15.5.2 App Router blog app (TypeScript, 17 source files, 352 lines), all 12 attack tests (A01–A12) succeeded before fixes and were all blocked after them.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The write-up's test app is deliberately small: Next.js 15.5.2 on the App Router, React 19.1, TypeScript, SQLite via node:sqlite, and Node.js 22.22.0, with 17 source files amounting to 352 lines. Before fixes, all 12 attack tests succeeded; after fixes, all 12 were blocked. The tests ran only against a local copy and dummy data, and the author warns against trying them on a live server.

Several holes trace back to specific shortcuts. A profile-update form sent the target's userId in a hidden field, so changing it and adding role=admin let a logged-in Bob rename Alice and promote her; the fix reads the target from the session and accepts only the name. Route handlers had no auth or ownership check at all, so deleting other people's posts and reading drafts without logging in both worked, and a users API returned SELECT * output including plaintext passwords. The password fix uses scrypt with a salt and the settings N=2^15, r=8, p=3, which OWASP lists alongside the N=2^17, r=8, p=1 minimum as using about 32MiB per computation.

Other flaws were about what was never restricted: a search box and an ID parameter let SQL be embedded into queries; an image proxy fetched any URL handed to it (SSRF), a concern the author ties to private networks like Railway's *.railway.internal; uploads used the client-supplied file name, so ../../pwned.html was written outside public/uploads; CORS echoed the request Origin with credentials allowed; the post-login redirect followed an absolute URL to an external site; and the session cookie lacked HttpOnly, Secure, and SameSite with a one-year lifetime and a token made from Math.random(). The version pin also mattered — the author notes AI often writes the version it learned and misses later patches. After twelve app-specific Semgrep rules were written, 17 matches appeared before the fixes and 0 after, but the author cautions that this and the zero public-rule findings only mean no rule matched, not that the code is safe.

FAQ
Did the public Semgrep rulesets catch any of these flaws?
No. Even on the unfixed code, p/typescript (74 rules), p/react (4), p/owasp-top-ten (80), and p/secrets (41) all returned 0 findings. The author notes this is because many holes were missing checks, not unusual code.
What did npm audit find in the project?
npm audit --omit=dev flagged a critical advisory for next, including GHSA-9qr9-h5gf-34mp (remote code execution in React Server Components' communication handling), with 33 advisories against next in total. Upgrading to 15.5.27 cut the count from 3 (one critical, two high) to 2 (one high, one medium), leaving postcss and next, which depends on it.
Where should the secret API key live instead of NEXT_PUBLIC_?
Use a server-only LLM_API_KEY and call the AI API from a server route (POST /api/posts/[id]/summary), letting the browser call that route instead. A NEXT_PUBLIC_ key such as the dummy sk-demo-LEAK-CHECK-123 was embedded into the browser JavaScript at build time and readable by anyone.

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleUkraine drones knock out Yandex AI data center