The previous lesson established rel="noopener noreferrer" as a checklist rule to always pair with target="_blank". This lesson explains the actual mechanism and named attack — reverse tabnabbing — that makes this rule genuinely necessary, not just conventional.
1window.opener: A Live Reference Back
When a page opens a new tab via target="_blank" (or window.open()), the newly opened page's JavaScript automatically receives window.opener — a genuine, live reference to the original tab's window object. Critically, this includes the ability to set window.opener.location, which silently navigates the *original* tab to any URL the new page's JavaScript chooses, with zero warning or user interaction required in the original tab.
This is the specific, concrete technical mechanism underlying the checklist rule from the previous lesson — without blocking it, any link using target="_blank" to an untrusted or externally-controlled destination hands that destination real, exploitable power over the tab the user came from.
2The Full Reverse Tabnabbing Attack Scenario
This vulnerability has a specific, documented name: 'reverse tabnabbing'. The attack sequence: a user clicks a link on a legitimate site that opens, via target="_blank", an attacker-controlled destination in a new tab. The user's attention naturally follows to that new tab. Meanwhile, the attacker's page JavaScript silently redirects the *original* tab — out of the user's current view — to a convincing fake login page mimicking a real, trusted service (a bank, an email provider, the original site itself).
When the user eventually switches back to what they believe is still the original, trusted tab, they instead see a phishing page and, trusting it precisely because it's 'the tab I had open before', may enter real credentials directly into the attacker's fake form.
3What noopener And noreferrer Each Precisely Do
rel="noopener" specifically sets window.opener to null in the newly opened tab, completely and directly blocking the mechanism described above — the new page simply has no reference back to the original tab at all, making the attack technically impossible.
rel="noreferrer" provides that identical protection (also nulling window.opener) but goes further: it additionally omits the Referer HTTP header that would otherwise tell the destination site which page linked to it, an added privacy benefit unrelated to the tabnabbing vulnerability itself. Since noreferrer is a strict superset of noopener's protection plus this additional privacy benefit, using both together — rel="noopener noreferrer" — is the common, comprehensive, safe default recommendation, with the redundancy also serving as a compatibility fallback across different browser support levels.
4Step-by-Step Breakdown
The Mechanism Behind The Attribute You Always Add. The previous lesson established that target="_blank" always needs rel="noopener noreferrer" as a checklist rule. This lesson explains exactly why: the specific window.opener mechanism that creates a real vulnerability called 'reverse tabnabbing', and precisely what each half of that rel value actually does.
window.opener Gives The New Tab A Reference Back. When a link with target="_blank" opens a new tab, that new page's JavaScript receives window.opener — a live reference back to the original tab's window object, letting the new (potentially malicious) page manipulate the original tab's location.
The window.opener Mechanism. What does window.opener give a page opened via target="_blank" access to?
- →Direct read access to the original tab's cookies
- →A live JavaScript reference to the original tab's window object, including its location
- →Nothing meaningful; it's just a boolean flag
Reverse Tabnabbing: The Actual Attack Scenario. A legitimate-looking site includes an external link (target="_blank" to an attacker-controlled destination). Once opened, that destination's JavaScript silently redirects the ORIGINAL tab — which the user isn't looking at anymore — to a convincing fake login page mimicking a real service, phishing for credentials.
The Reverse Tabnabbing Attack. In a reverse tabnabbing attack, which tab does the user actually notice being manipulated?
- →The newly opened tab, which visibly changes
- →Neither directly — the ORIGINAL tab is silently redirected while the user's attention is on the new one
- →Both tabs flash a visible warning simultaneously
noopener Blocks Access, noreferrer Also Hides Origin. rel="noopener" specifically sets window.opener to null in the new tab, completely blocking the attack mechanism. rel="noreferrer" does that too, AND additionally omits the Referer header, preventing the destination from even knowing what page linked to it — a privacy bonus beyond the core security fix.
noopener vs noreferrer. What does rel="noreferrer" do beyond what rel="noopener" alone already accomplishes?
- →Nothing; they're functionally identical in every way
- →It also omits the Referer header, preventing the destination from knowing which page linked to it
- →It forces the link to open in the same tab instead of a new one
The Full Mechanism Understood. You now understand exactly why the checklist rule from the previous lesson exists: the window.opener mechanism enabling reverse tabnabbing, the real attack scenario it powers, and the precise, distinct effects of noopener versus noreferrer — completing the HTML Security module.
Fully Secure An External Link. noopener blocks window.opener access; noreferrer additionally hides the referrer header.
Level Up 🚀
Advanced cheat sheets, SEO tricks, and interview prep for this topic.
Browser Support
Fully supported.
Fully supported.
Fully supported.
Fully supported.
Accessibility (A11y)
1Understanding The Real Mechanism Reinforces Why This Isn't An Optional Convention
Recognizing reverse tabnabbing as a genuine, exploitable phishing technique — not just a stylistic best practice — helps teams correctly prioritize consistently applying this protection across an entire codebase.
SEO Implications
- 1
This Attribute Pairing Has No Direct SEO Weight But Protects Against A Reputationally Damaging Phishing Vector
A site whose links are exploited for reverse tabnabbing phishing attacks, even against third-party destinations, faces genuine reputational and trust damage if discovered and publicized.
Best Practices
Use rel="noopener noreferrer" (Both Values Together) As The Default For Any target="_blank" Link To An External Destination
noreferrer's protection is a strict superset of noopener's, and combining both provides the most comprehensive, broadly-compatible protection against reverse tabnabbing plus an added referrer-privacy benefit.
Apply This Protection Consistently Across An Entire Codebase, Not Just Obviously Untrusted Links
Since window.opener grants real access regardless of how trustworthy a destination currently appears, and destinations can change ownership or be compromised later, consistent application is safer than case-by-case judgment calls.
Frequent Bugs
A security audit flags numerous target="_blank" links across a site missing rel="noopener".
Add rel="noopener noreferrer" consistently to every target="_blank" link pointing to an external destination.
A team debates whether noopener alone is 'good enough' compared to noopener noreferrer.
Use both together as the standard default — noreferrer's protection is a superset of noopener's, with the added referrer-privacy benefit costing nothing extra to include.
Real-World Examples
A Correctly Protected External Link
A blog post's external citation link, fully protected against reverse tabnabbing.
<a href="https://external-source.example.com/article" target="_blank" rel="noopener noreferrer">
Read the original source
</a>