Skip to content
Access control Write-up Intermediate

Authorization Bypass in Next.js Middleware

Next.js applications that perform authorization checks inside middleware could be bypassed, allowing an attacker to reach protected routes without passing the check. The advisory notes that deployments on Vercel are automatically protected.

github.com

Published on github.com

It is possible to bypass authorization checks within a Next.js application, if the authorization check occurs in middleware.

The author, on github.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a flaw in how Next.js middleware handles a request header that lets a request be treated as an internal sub-request, skipping the middleware authorization logic.

Impact

An attacker could bypass middleware authorization checks and reach protected parts of a Next.js application, though deployments hosted on Vercel are automatically protected.

What the attacker needed

App uses middleware for authorization; attacker can send crafted requests

The fix

It was fixed in the listed Next.js versions, and as a workaround external requests carrying the relevant header should be blocked from reaching the application.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Next.js is a framework for building web apps, and middleware is code that runs before a request reaches a page, often used to check whether a user is allowed in. This report says that check could be skipped, so someone could get to pages they should not see. The exact trick is not described in the text.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.