Open Redirect vulnerabilities are common in web applications and can lead to serious security issues like phishing, credential theft, and bypassing security controls. In this blog post, we’ll dive into what open redirects are, how attackers exploit them, real-world examples, the tools you can use to find them, and how to prevent this vulnerability from affecting your applications.
What is an Open Redirect Vulnerability?
An Open Redirect occurs when an application takes a user-supplied URL and redirects the user to it without proper validation. This allows attackers to redirect users to malicious websites, phishing pages, or sites that attempt to steal sensitive information under the guise of being legitimate.
How Open Redirects Work
Many web applications use redirect functionality for user navigation. For instance, after a login, an application might redirect a user back to a specific page. If the redirect URL is not validated or sanitized, attackers can manipulate it.
Example of an Open Redirect
Imagine a login URL like this:
https://example.com/login?redirect=https://example.com/dashboard
After a successful login, the user is redirected to the dashboard page. If the application does not validate the redirect parameter, an attacker could modify the URL:
https://example.com/login?redirect=https://malicious-site.com/phishing
In this case, after logging in, the user is redirected to a malicious site that might impersonate the legitimate application, leading to phishing attacks.
Exploiting Open Redirect Vulnerabilities
Exploiting an open redirect vulnerability typically involves crafting a URL with a manipulated redirect or similar parameter. The attack vector can vary, but here’s a common exploitation technique:
Example Attack Scenario
A legitimate website provides this URL for redirecting after login:
https://example.com/login?redirect=https://example.com/home
An attacker crafts the following malicious link:
https://example.com/login?redirect=https://malicious-site.com
The attacker sends this link via email, social media, or other means. The user, trusting the legitimate domain (example.com), clicks on it, expecting to be redirected back to the home page. Instead, after logging in, they are redirected to the attacker’s phishing page.
Implications:
- The attacker can impersonate a legitimate page to steal credentials.
- Users might unknowingly provide sensitive information, such as usernames and passwords, to attackers.
- This type of attack is often used in phishing schemes or to bypass security mechanisms like multi-factor authentication (MFA).
Tools for Finding Open Redirect Vulnerabilities
Here are some tools that can help you identify and exploit open redirects:
1. Burp Suite
- Why Use It: Burp Suite is a widely-used tool for testing web vulnerabilities, including open redirects. With its ability to modify HTTP requests, Burp Suite can easily identify insecure redirects by intercepting requests and modifying parameters.
- How to Use: Set up Burp Suite to intercept requests, find redirect URLs, and modify the
redirectparameter to check if you can redirect the user to an external site.
2. OWASP ZAP (Zed Attack Proxy)
- Why Use It: OWASP ZAP is an open-source web application security scanner. It includes functionality for testing redirects and is an excellent tool for security researchers looking for open redirects.
- How to Use: Similar to Burp Suite, use ZAP to intercept requests, identify redirects, and test them by modifying the target URLs to malicious destinations.
3. Fuzzing Tools
- Why Use Them: Fuzzers like
wfuzzorffufcan automate the process of testing parameters in the URL to check if an application is vulnerable to open redirects. - How to Use: Use these tools to fuzz common redirect parameters like
url,next,goto, orcontinueand see if they accept external domains as valid redirect destinations.
4. Manually Test Redirects
- Why Use It: While automated tools are effective, manually inspecting how redirects are handled in an application can provide additional insights.
- How to Use: Look for endpoints that perform redirects, typically found in login flows, logout links, and error pages. Try replacing the intended redirect URL with an external domain and check the response.
Real-World Examples of Open Redirects
1. Google Open Redirect Vulnerability:
A few years ago, a researcher found an open redirect vulnerability on Google’s domain, allowing users to be redirected to external websites by modifying the continue parameter. A crafted URL would look something like:
https://accounts.google.com/ServiceLogin?continue=https://malicious-site.com
Although Google patched this vulnerability, it highlights how even large companies can be susceptible to open redirects.
2. Facebook Open Redirect Incident:
Facebook once had an open redirect vulnerability in its next parameter during the OAuth flow. An attacker could exploit this by sending users to a phishing page post-authentication.
How to Prevent Open Redirect Vulnerabilities
Preventing open redirects requires careful validation of user-supplied input, particularly when accepting URLs for redirection. Here are the best practices for securing your application against open redirects:
1. Validate Allowed Domains for Redirects
- Only allow redirects to trusted domains, such as your own domain or subdomains. Ensure that any external URLs are explicitly whitelisted and checked.
- Example: Instead of allowing any URL in the
redirectparameter, check if the destination is part of your application:
const allowedDomains = ['example.com', 'sub.example.com'];
const redirectUrl = new URL(userInputRedirect);
if (!allowedDomains.includes(redirectUrl.hostname)) {
throw new Error('Invalid redirect URL');
}
2. Use Relative URLs
- Instead of accepting full URLs, use relative URLs for redirection within the application. This ensures that users are only redirected within your own domain.
- Example: Instead of accepting
https://example.com/home, restrict redirects to paths like/home.
const redirectPath = userInputRedirect;
if (!redirectPath.startsWith('/')) {
throw new Error('Invalid redirect path');
}
3. Implement URL Encoding
- Ensure that the redirect URLs are properly encoded, and avoid directly inserting user-supplied input into redirection logic. Malicious URLs may contain special characters like
%00,//, etc., which can be exploited if not encoded.
4. Display a Confirmation Page for External Redirects
- If your application must redirect users to external domains, display an intermediary confirmation page informing users of the redirection and asking for their explicit consent.
<p>You are being redirected to an external site: https://external-site.com</p>
<p>Do you want to continue?</p>
<button>Continue</button>
5. Use Security Headers
- Implement security headers like
Content-Security-Policy (CSP)to limit the sources from which your application can load content, reducing the impact of open redirect vulnerabilities.
Content-Security-Policy: default-src 'self';
6. Regularly Audit and Test
- Regularly review your application’s redirection logic and ensure that any changes or new functionality doesn’t introduce open redirects. Use security scanners, penetration testing, and code reviews as part of your security workflow.
Here are a few examples of Common Vulnerabilities and Exposures (CVE) related to Open Redirect vulnerabilities:
1. CVE-2020-5251 (Strapi CMS)
- Description: Strapi CMS prior to version 3.0.0-beta.19.3 was vulnerable to an open redirect vulnerability. The application failed to validate user-provided URLs, which allowed attackers to redirect users to arbitrary external sites.
- Impact: Phishing attacks and potential credential theft.
- Fix: The developers released a patch in version 3.0.0-beta.19.3 that added validation for the
redirectURL. - Reference: CVE-2020-5251
2. CVE-2019-12000 (GitLab)
- Description: GitLab prior to version 12.3 was found vulnerable to open redirects via user input in URLs. By manipulating the
redirect_toparameter in GitLab links, an attacker could redirect users to a malicious site. - Impact: Could lead to phishing or tricking users into downloading malicious software.
- Fix: GitLab fixed the issue by validating and sanitizing the
redirect_toparameter. - Reference: CVE-2019-12000
3. CVE-2021-27651 (SAP NetWeaver AS JAVA)
- Description: SAP NetWeaver AS JAVA (Administrator’s Web Interface) before versions 7.50 and 7.30 allowed an open redirect vulnerability. An attacker could exploit this by providing a malicious URL to the redirection logic.
- Impact: This could lead to phishing attacks, enabling the attacker to harvest sensitive information.
- Fix: SAP issued a patch to address the improper validation of the redirection logic.
- Reference: CVE-2021-27651
4. CVE-2018-1000603 (Jenkins)
- Description: Jenkins before version 2.138.2 and LTS before 2.138.1 had an open redirect vulnerability in the handling of URLs during login. It allowed an attacker to craft a malicious link that redirected users to phishing websites after logging in.
- Impact: Attackers could use the vulnerability for phishing attacks or credential theft by impersonating Jenkins.
- Fix: The vulnerability was fixed by sanitizing the
redirectparameter during login. - Reference: CVE-2018-1000603
5. CVE-2022-21515 (Oracle GoldenGate)
- Description: Oracle GoldenGate versions before 21.3 contained an open redirect vulnerability. An attacker could craft a malicious URL to redirect users to untrusted external websites.
- Impact: This allowed phishing attacks by redirecting users to malicious websites.
- Fix: Oracle addressed the issue in subsequent updates by validating URLs before redirection.
- Reference: CVE-2022-21515
These examples highlight how even high-profile applications and platforms can be vulnerable to open redirects and how they can lead to serious security issues.
Conclusion
Open Redirect vulnerabilities may seem minor, but they can lead to severe consequences such as phishing attacks, social engineering, and security bypasses. As a bug bounty hunter, finding and exploiting open redirects can uncover significant security flaws. On the other hand, as a developer, you should focus on validating user input, restricting allowed redirect destinations, and regularly auditing your applications to prevent these attacks.
By following the mitigation strategies outlined here and using the right tools, you can protect your applications from open redirect vulnerabilities and ensure that your users are not misled or compromised.

One comment