QA
Beginner LevelWeb Security & Cyber Defense

What is an Open Redirect vulnerability and how do attackers use it in phishing campaigns?

❓ Interview Prompt: Explain Open Redirect, unvalidated URL parameters (`?next=http://evil.com`), phishing campaigns, and URL domain whitelisting.

An Open Redirect vulnerability occurs when a web application accepts a user-controlled URL parameter and redirects the browser to that URL without validation:

Phishing Attack Scenario:

1
Attacker constructs link: 'https://trusted-bank.com/login?redirect=https://evil-phishing-bank.com'.
2
The victim sees 'trusted-bank.com' and trusts the link.
3
After logging in, the server issues 'Location: https://evil-phishing-bank.com'.
4
The victim is redirected to a fake replica site designed to steal secondary credentials!

Code Implementation Example

typescript
app.get('/login', (req, res) => {
  const redirectUrl = req.query.redirect as string;

  // ❌ VULNERABLE: Open Redirect
  // return res.redirect(redirectUrl);

  // ✅ SECURE: Enforce relative paths ONLY or check domain whitelist
  if (redirectUrl && redirectUrl.startsWith('/') && !redirectUrl.startsWith('//')) {
    return res.redirect(redirectUrl);
  }
  res.redirect('/dashboard'); // Default safe fallback
});
💡Preventing Open Redirects by enforcing relative path validation.
🎯 Interview Key Takeaway

Validate redirect URLs against relative path rules or trusted domain whitelists to block phishing redirects.

#Open Redirect#Phishing#Web Security#Beginner
Back to all Web Security & Cyber Defense Questions→

More Web Security & Cyber Defense Interview Questions

Beginner LevelSecurity & Web Security

Explain OWASP Top 10 vulnerabilities (XSS, CSRF, SQL Injection) and their defenses.

Beginner LevelSecurity & Web Security

What are the 3 types of XSS (Stored, Reflected, DOM-based) and how do they differ?

Beginner LevelSecurity & Web Security

How do Parameterized Queries (Prepared Statements) prevent SQL Injection attacks?