Open Redirect

User input passed directly to redirect()

warningSecurityopen-redirect

Why this matters

Open redirects let attackers craft URLs on your domain that redirect to phishing sites. Users trust your domain, so they click — and land on a credential-stealing page.

Example

Flaggedapp/go/route.ts
export async function GET(req: Request) {
  const url = new URL(req.url);
  const next = url.searchParams.get("next") ?? "/";
  redirect(next);
}
Fixedapp/go/route.ts
export async function GET(req: Request) {
  const url = new URL(req.url);
  const next = url.searchParams.get("next") ?? "/";
  // Only allow relative paths
  const safe = next.startsWith("/") &&
    !next.startsWith("//") ? next : "/";
  redirect(safe);
}

How to fix

Validate redirect targets are relative paths on your own domain. Reject absolute URLs, protocol-relative URLs (//), and any input that doesn't start with a single slash.

Reference

In the output
Findings carry "ruleId": "open-redirect" in --json and the same id in SARIF and in the terminal.
Silence one line
// prodlint-disable-next-line open-redirect
Silence a whole file
// prodlint-disable open-redirect at the top of the file
How it works
Reads the syntax tree, with a text fallback for files that don't parse. Source on GitHub