Introduction
Open the links below in new tabs and observe the behavior:
Why use rel="noopener noreferrer"?
Using rel="noopener noreferrer" prevents the new page from being able to access the window.opener property and ensures it runs in a separate process. This is particularly important for security and performance reasons.
Understanding the Exploit
When a link is opened with target="_blank" without using rel="noopener noreferrer", the new page has access to the window.opener property, which refers to the original page. This can be exploited by malicious pages to manipulate the content or URL of the original page.
Steps to Exploit example-without-noreferrer.html
- Open the Example without noreferrer link. A new tab will open
malicious.html. - Observe that
malicious.htmlattempts to manipulate the original page by redirecting it tohacked.htmlor changing its content to display a fake login form. - In a real-world scenario, this could be used to steal sensitive information by tricking users into entering their credentials on a phishing page that looks like a legitimate login form.
Mitigation with example-with-noreferrer.html
- Open the Example with noreferrer link. A new tab will open
malicious.html. - Observe that
malicious.htmlfails to manipulate the original page because thewindow.openerproperty isnull. - By using
rel="noopener noreferrer", the original page is protected from any manipulation attempts by the new page, thus preventing potential phishing attacks.
Explanation of malicious.html
The malicious.html page has been styled to look like a legitimate Skunkworks Mail login page.
It includes a form that checks for specific credentials (username: skunkworks, password: password123).
If the correct credentials are entered, the user is redirected to hacked.html. Otherwise, an error message is displayed.
The page still attempts to manipulate the opener's content or URL to demonstrate the security risk.
Credentials for Redirection
| Username | skunkworks |
|---|---|
| Password | password123 |
This setup should provide a clear and realistic demonstration of the security implications and how the rel="noopener noreferrer" attribute helps mitigate such risks.