Open Redirect
Open Redirect
Description
Open Redirect occurs when a web application allows untrusted input to redirect users to external URLs without proper validation. This can lead to phishing attacks and loss of user trust.
Example with Scenario
Scenario: A web application uses a URL parameter to redirect users after login. An attacker can craft a malicious URL that redirects users to a phishing site.
Payloads and Test Cases
Payloads
Basic Open Redirect:
URL Encoding:
Relative Path:
Test Cases
Basic Open Redirect:
Payload:
Test Case:
URL Encoding:
Payload:
Test Case:
Relative Path:
Payload:
Test Case:
Mitigation
Whitelist URLs:
Implement a whitelist of allowed URLs for redirection.
Ensure that only trusted URLs are allowed for redirection.
URL Validation:
Validate the URL parameter to ensure it points to a trusted domain.
Reject any URL that does not match the allowed patterns.
Use Relative URLs:
Use relative URLs for internal redirection to prevent external redirects.
Avoid using user-supplied input directly in redirection logic.
Security Headers:
Implement security headers like Content Security Policy (CSP) to restrict loading of external resources.
Use X-Frame-Options to prevent clickjacking attacks.
Last updated