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→