Overview
As defined by OWASP:Unvalidated redirects and forwards are possible when a web application accepts untrusted input that could cause the web application to redirect the request to a URL contained within untrusted input. By modifying untrusted URL input to a malicious site, an attacker may successfully launch a phishing scam and steal user credentials.Open redirects are commonly used to:
- Phishing attacks: Legitimate-looking URL redirects to attacker site
- Credential theft: Clone of login page steals passwords
- Malware distribution: Redirect to exploit kit or malicious download
- OAuth/SSO bypass: Manipulate authentication flows
- SEO poisoning: Redirect search engine crawlers
- SSRF attacks: Chain with other vulnerabilities
Objective
Abuse the redirect functionality to move users off the DVWA site or to different pages than expected.Vulnerability Analysis by Security Level
Low Security
Vulnerability: No validation on redirect parameter whatsoever Source Code (/vulnerabilities/open_redirect/source/low.php:1-13):
dvwa.local domain and trusts the link.
4. Data exfiltration:
Medium Security
Mitigation Attempt: Block absolute URLs with protocol Source Code (/vulnerabilities/open_redirect/source/medium.php:1-21):
strpos() which checks if string appears anywhere in the URL
Bypass Method 1: Query String Injection
strpos($_GET['redirect'], "info.php")looks for “info.php” anywherehttps://evil.com?info.phpcontains “info.php” (as query parameter)- Validation passes
- Browser redirects to
https://evil.com?info.php
- Legitimate domain:
dvwa.local - Expected filename:
info.php - Trusts and clicks
Impossible Security
Proper Defense Implementation Source Code (/vulnerabilities/open_redirect/source/impossible.php:1-29):
2. Domain Whitelist
4. Comprehensive Validation Function
Common Bypass Techniques
Protocol-Relative URLs
Alternative Protocols
URL Encoding
Backslash Tricks (Windows/IE)
CRLF Injection
Unicode/Homograph
Subdomain Confusion
Real-World Attack Scenarios
OAuth Token Theft
SSO Session Hijacking
Search Engine Manipulation
Testing for Open Redirects
Manual Testing Checklist
-
Identify redirect parameters:
?url=,?redirect=,?next=,?return=,?continue=?redir=,?destination=,?target=,?returnUrl=
- Test with external URL:
- Test protocol-relative:
- Test alternative protocols:
- Test whitelist bypass:
