Course contentsShow
← Security
Lesson 1145 of 3,05223. Web Security - Modern Web AttacksFree lesson

Tabnabbing Attack Mechanics

Understanding reverse tabnabbing attacks where opened tabs rewrite the opener page using window.opener references.

Tabnabbing Attack Mechanics

You'll learn: How attackers exploit browser tabs you've opened to secretly rewrite the page you came from.

What Is Tabnabbing?

Tabnabbing (or "reverse tabnabbing") is a sneaky attack where a page you open in a new tab can reach back and modify the original page that opened it. Imagine clicking a link that opens in a new tab—while you're distracted reading the new content, the malicious page uses JavaScript to change what's displayed on your original tab, typically to a fake login page.

How the Attack Works

When you open a link with target="_blank", the newly opened page receives a reference called window.opener. This reference points back to the window that created it. The malicious page can then use this to navigate your original tab:

From the attacker's page (in the new tab):

if (window.opener) {
    window.opener.location = "https://evil.com/fake-login";
}

You're now reading content in the new tab, unaware that behind the scenes, your original tab has been replaced with a phishing page that looks identical to the legitimate site. When you switch back, you might not notice the URL changed and enter your credentials.

The Timing Advantage

The attack works because of divided attention—you're focused on the new tab while the old one silently transforms. It's like someone switching the picture in a frame while you're looking away.

Cross-Origin Impact

Even though Same-Origin Policy prevents the malicious page from reading the opener's content, it can still navigate it to a different URL—that's enough for the attack.

Key Takeaway: Tabnabbing exploits window.opener to rewrite the originating tab's location while users are distracted, typically delivering phishing pages. The next lesson covers defenses using rel="noopener".