The service window nobody guards
Watch it happen
Mallory has no badge. The guard stops her at the main counter, but the forgotten side counter has no guard and hands her every account.
Mallory walks into the bank with no badge at all. Anyone can enter the lobby.
Mallory says: One statement, please.In bank terms and app terms
| In the bank | In your app |
|---|---|
Are you exposed?
Some of your API routes or Server Actions never call an auth function before touching data. You protect pages in the UI, but the API behind them can be called directly with curl. Login is only checked in the front end, or in some routes but not the ones added last month.
Require a verified session at the top of every route and Server Action, and fail with 401 if there is none. Make “protected” the default (a shared wrapper or middleware) and mark public routes explicitly. Call your own routes with no token as a test; anything that returns data should be a surprise.
It has happened to real companies
Optus Australia (2022) — The Australian regulator ACMA alleges a coding error left the access controls on an Optus API ineffective, so attackers could pull customer data through it by trial and error. The privacy regulator (OAIC) says about 9.5 million Australians were affected, with data that included passport and driver's licence numbers. These are allegations made by the regulators.
Peloton (2021) — API endpoints lacked authentication, allowing anyone to query user account data (age, gender, city, weight) for any Peloton user without logging in.
What it looks like in code
// BAD: No auth check — anyone can list all users
export async function GET() {
const users = await db.select().from(profiles)
return NextResponse.json(users)
}
// BAD: Auth on the page but not the API route
// src/app/dashboard/page.tsx → has auth check
// src/app/api/tasks/route.ts → no auth check (accessible directly)
Ask your AI tool to fix it
Paste this into Cursor, Claude, Lovable, Bolt or whatever you build with.
List every API route, Next.js route handler and Server Action in this project. For each one, tell me whether it verifies the caller’s session before doing anything. Add a shared auth guard to the ones that do not (return 401 when there is no valid session), and leave only health checks and docs public. Show me the list of routes you changed.Where this comes from
The facts, figures and fixes on this page were checked against these sources on 25 Oct 2026. They are linked so you can check for yourself.
- API2:2023 Broken AuthenticationOWASPEndpoints that skip authentication let anyone call them directly
- A01:2025 Broken Access ControlOWASPDeny by default except public resources; API write routes can lack access controls
- How to think about data security in Next.jsNext.jsServer Actions are reachable by direct POST; verify auth inside each one
- Peloton's leaky API let anyone grab riders' private account dataTechCrunchPeloton API answered unauthenticated requests with age, gender, city, weight
- Australian Information Commissioner takes civil penalty action against OptusOAICAbout 9.5 million affected; passport and licence numbers; Federal Court case
- Optus breach occurred due to a coding error, alleges ACMACSO OnlineACMA alleges a coding error left API access controls ineffective
Spot a mistake or something out of date? Report a correction · How these guides are made and checked
The free, open-source scanner checks for most of the problems in these guides.