BETA Shoulder is in beta — Findings may sometimes be wrong. Your feedback shapes what we fix next. Share feedback

Open Redirect via Untrusted URLs

Description

Detects user input flowing into redirect functions without URL validation.

What Shoulder detects

Untrusted input from {source} reaches redirect function at {sink}. This allows an attacker to redirect users to malicious websites in phishing attacks.

How to fix

Validate redirect URLs against an allowlist or ensure they are relative paths.

```javascript
const ALLOWED = ['/home', '/dashboard', '/profile'];
if (ALLOWED.includes(url) || url.startsWith('/')) {
  res.redirect(url);
}
```

Learn more: https://shoulder.dev/learn/javascript/cwe-601/open-redirect

Applies to

Frameworks

nodejs express fastify koa hapi nestjs nextjs

References

Scan for this issue

Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=javascript-open-redirect .

Real-world examples

Known CVEs in the Open Redirect vulnerability class that this rule helps detect.

Related rules