IntentiAI

Redirect to an address taken from the request

redirect, res.redirect or NextResponse.redirect to a value from the query string or body with no allow-list.

Check open-redirectShip Check

Why it matters

After sign-in, apps send people back where they came from, usually from a ?next= or ?returnTo= parameter. Agents wire the parameter straight into the redirect because it works for every link they try.

It also works for links nobody meant: a link to your real sign-in page that ends on a look-alike site asking for the password again. Mail filters and users trust it because it starts with your address.

Example

 export async function GET(request: Request) {
   const { searchParams } = new URL(request.url);
+  const next = searchParams.get("next") ?? "/";
+  return NextResponse.redirect(new URL(next, request.url));
 }

What it detects

  • A redirect call on an added line whose target is request data (searchParams.get, req.query, req.body, request.args, form data) or a name assigned from it in the same function.
  • Quiet when the function checks the target first (startsWith("/"), an allow-list, comparing the origin or host), or when the target is a path on this site with a value after it.

What to do when it fires

Only accept paths on this site (one leading slash, not two) or a short list of allowed addresses, and send anything else to the home page.

Redirect to an address taken from the request: AI code review check | IntentiAI