Tabnabbing via target="_blank"
What you'll learn: How opening links in new tabs with target="_blank" gives those pages unexpected control over your original page.
When you click a link that opens in a new tab (using target="_blank"), you'd expect the new page to be completely separate. Surprisingly, that's not always true. By default, the newly opened page receives a reference to your original page through the window.opener object, allowing it to manipulate the parent window.
The Attack Mechanism
When a link uses target="_blank" without the rel="noopener" attribute, the opened page can execute JavaScript like:
window.opener.location = "https://evil-phishing-site.com/fake-login";
This code runs in the new tab but changes the URL of the original tab (the parent window). The user, now focused on the new tab, doesn't notice their original tab has been replaced with a malicious look-alike.
Why This Is Dangerous
Imagine you're on your bank's website and click a link to their blog that opens in a new tab. While you're reading, the blog page (if compromised) could redirect your bank tab to a convincing phishing site. When you switch back, you see what looks like your bank asking you to "log in again" — but it's actually an attacker's page harvesting credentials.
The Fix
Always include rel="noopener" (and optionally rel="noreferrer") on external links:
<a href="https://example.com" target="_blank" rel="noopener noreferrer">
Safe external link
</a>
This severs the window.opener connection, preventing the opened page from controlling your original tab.
Key Takeaway: Links with target="_blank" grant opened pages access to the parent window via window.opener unless explicitly blocked with rel="noopener", enabling tabnabbing attacks where attackers silently replace the original page with phishing sites.