← All advisories
VV-008mediumBroken access control2025-03

Protecting routes only in middleware

Vercel recommends against middleware being the sole method of protecting routes. Check auth again where data is read or changed.

01.

What it is

Vercel’s postmortem: "We do not recommend Middleware to be the sole method of protecting routes in your application." Middleware cookie checks are an optimistic early redirect, not the final authorization.

02.

How to check

  1. Find server actions, route handlers and data-fetching functions that read user data. Each should verify the session itself.
03.

How to fix

  1. Add a session/role check inside each server action and route handler (defense in depth).
'use server';
export async function deleteProject(id: string) {
  const user = await requireUser();            // don't trust middleware alone
  const project = await db.project.findUnique({ where: { id } });
  if (project?.ownerId !== user.id) throw new Error('Forbidden');
  await db.project.delete({ where: { id } });
}
04.

Sources

More advisories for this tool
The weekly email

One email a week. Only what changed.

New advisories, CVEs and fixes for Lovable, Bolt, v0, Replit, Base44 and Cursor apps. No roundups of things you already read.

Free. The list is new, so the first issues go out once there are readers. Unsubscribe from any email in one click. We never sell or share addresses.