Skip to content
Open redirect Disclosed report Beginner

Redirect while opening links in new tabs

Links on HackerOne opened in new tabs did not set window.opener to null, so the opened page could change the original tab's location. An attacker could redirect a user to a scam page in the background, potentially stealing credentials or private reports.

thetime Follow

Originally disclosed on HackerOne

Bounty$500 View original
  • Triaged in 24 hours
  • Fixed in 4 days
  • Paid in 4 days
  • Disclosed after 34 days

Hello HackerOne,

I'd like to report to you a nice little bug about opening links in new tabs.

When you open a link in a new tab ( target="_blank" ), the page that opens in a new tab can access the initial tab and change it's location using the window.opener property.

POC: http://daniel-tomescu.com/hackerone/landpage.php (just click on the link, don't worry, no harm will be done).

Don't right-click it and open it in new tab, don't use the mouse wheel to open it, don't Ctrl+Click, just do a normal click on the link.

The javascript code that does all the magic: window.opener.location.replace(newURL);

Ways to solve this:

  1. Don't open links from hackerone.com in new tabs using the target="_blank";
  2. Set the window.opener attribute to null on the new tab before redirecting to the landing page, like this:

a) open in a new tab hackerone.com/redirect?link=landingpage b) use a javascript code: <script>window.opener = null; </script> c) redirect to the landing page: <script>window.location.reload(landingpage)</script>

I hope you see why this is dangerous: this method has huge potential for tricking hackerone.com that click on external links from this site to be a victim of a scam page because the redirecting is made in the background, while the user is focused on another tab.

More then that, some browsers like Mozilla for Android don't even display the URL, just the page title, so the user has no way of knowing that he was redirected to a scam page.

If an attacker uses this trick while submitting a bug on hackerone.com/someTarget, he may obtain the logon credentials for a representative of "someTarget" and gain access to his account, private reports submitted by other researchers etc.

Tested on Chrome version 36 (latest version), Firefox for Windows and Android (latest versions). Websites that protect themselves against this kind of attack: google.com websites, twitter.com (they open links in new tabs, but the window.opener property is set to null)

Thank you!

The original report as published on HackerOne, by thetime. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

HackerOne is a bug bounty platform where researchers submit reports against customer programs. The feature at the centre of this report is the ordinary outbound link: when a page on hackerone.com points to an external site, the link is opened in a new tab using the target="_blank" attribute. That is the normal, intended behaviour, and it is exactly what makes the bug possible.

The weakness class is open redirect, but the mechanism is not a server-side redirect. It is the browser's window.opener relationship between a page and the tab that opened it. The researcher, thetime, reported it on HackerOne and it was disclosed on 12 September 2014 with a bounty of 500.00 USD.

Setup

The report describes no accounts, roles or tooling beyond a browser. The researcher tested on:

  • Chrome version 36 (described as the latest version at the time)
  • Firefox for Windows, latest version
  • Firefox for Android, latest version

The precondition is that a user opens a target="_blank" link by clicking it normally. The researcher is explicit that the proof of concept must be reached with a plain left click, not by right-clicking and choosing to open in a new tab, not with the mouse wheel, and not with Ctrl+Click.

Finding it

The observation is a property of the web platform: when a link carries target="_blank", the page that opens in the new tab can reach back to the tab that opened it through the window.opener property. That reference is not read-only. The new page can assign to window.opener.location, which navigates the original tab.

Because the navigation happens in the background while the user is looking at the new tab, the user does not see the original tab change. The researcher frames this as the core danger: a site that sends users to external links can be used to silently move those users onto a scam page.

Exploitation

Step 1: Open the proof of concept with a normal click

The researcher supplied a proof of concept and asked the reader to click the link in the ordinary way:

Text
http://daniel-tomescu.com/hackerone/landpage.php

The instruction is deliberate: a normal click on a target="_blank" link creates the opener relationship. Opening the same link through the context menu, the mouse wheel or Ctrl+Click does not produce the same setup, so the demonstration only works with a plain click.

Step 2: The new tab rewrites the opener's location

The code that performs the redirect is a single line:

JavaScript
window.opener.location.replace(newURL);

window.opener is the window object of the tab that opened the current page. location.replace(newURL) navigates that window to newURL and, unlike assigning to location.href, does not leave the previous page in the session history. The result is that the original hackerone.com tab, still in the background, is now showing an attacker-controlled page.

Root cause

The issue is that opening external links with target="_blank" leaves the new tab a live reference to its opener. By default the new tab keeps a live reference to its opener, and that reference exposes a writable location. Nothing on the hackerone.com side validates or controls where the new tab sends the original window, because the navigation is initiated by the external page, not by hackerone.com.

The researcher notes that some sites already defend against this. Google sites and twitter.com open links in new tabs but set window.opener to null, so the new page has no handle on the original tab. The researcher notes that some sites already defend against this: Google sites and twitter.com open links in new tabs but set window.opener to null.

Impact

An attacker who can get a hackerone.com user to click an external link can silently replace the hackerone.com tab with a page of their choosing. The user's attention is on the new tab, so the swap goes unnoticed, and the researcher points out that some browsers, Mozilla for Android among them, show only the page title and not the URL, leaving the user no way to tell that the tab was redirected to a scam page.

The researcher describes a specific escalation. If the trick is used while a user is submitting a bug on hackerone.com/someTarget, the attacker may obtain the logon credentials of a representative of that target program and gain access to their account, including private reports submitted by other researchers. That outcome depends on the redirected tab being used to harvest credentials, which the report presents as a possibility rather than a demonstrated capture.

Fix

The report offers two remedies.

  1. Do not open links from hackerone.com in new tabs using target="_blank".
  2. Set the window.opener attribute to null on the new tab before redirecting to the landing page. The researcher sketches this as a three-part flow:
Text
a) open in a new tab hackerone.com/redirect?link=landingpage
b) use a javascript code: <script>window.opener = null; </script>
c) redirect to the landing page: <script>window.location.reload(landingpage)</script>

The idea is that an intermediate page on hackerone.com clears the opener reference first, so that by the time the user reaches the external landing page there is no handle left to navigate the original tab. The report does not record which of these options was adopted.

Variants to test

  • Any outbound link rendered with target="_blank" on a site that handles sensitive sessions. A positive result is that the linked page can read window.opener and assign to window.opener.location, moving the original tab.
  • Links inside user-generated content, such as submitted reports or comments, where an attacker controls the destination. A positive result is the same background navigation of the victim's tab.
  • Mobile browsers that display only the page title. A positive result is that the redirected tab gives the user no visible URL to check.

Hunting notes

This class of bug hides wherever a site sends users to external destinations in a new tab: profile links, report attachments, redirect endpoints and any user-supplied URL that is rendered as a link. During recon, the signal is a target="_blank" on links whose destination is not fully controlled by the site, combined with a session worth stealing on the originating tab.

The researcher made the impact concrete by naming a scenario: a target representative submitting a report on hackerone.com/someTarget, whose credentials and private reports could be exposed.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

What happened, in plain words

HackerOne is a website where security researchers send in reports about bugs they find in other companies' software. Those companies are called programs, and they pay for good reports. The researcher in this report, thetime, found a small but serious problem with a very ordinary feature: the links on hackerone.com that point to other websites.

When you click a link that points to another site, HackerOne opens it in a new browser tab. That is normal and intended. The problem is that the new tab keeps a live connection back to the tab that opened it. The page in the new tab can use that connection to send the original tab somewhere else, without the user noticing, because the user is looking at the new tab.

The report was disclosed on 12 September 2014 and paid a bounty of 500.00 USD. The weakness is classed as an open redirect, though the mechanism here is not a redirect performed by a server. It is a browser feature called window.opener.

The setup

The report needs no accounts, no special tools and no software beyond a browser. The researcher tested on:

  • Chrome version 36, described as the latest version at the time
  • Firefox for Windows, latest version
  • Firefox for Android, latest version

The only precondition is that a user opens a target="_blank" link by clicking it normally. The researcher is very specific about this: the demonstration only works with a plain left click. Right-clicking and choosing to open in a new tab, using the mouse wheel, or holding Ctrl while clicking all fail to set up the same situation.

Finding it

The observation is a property of how the web works. When a link carries the attribute target="_blank", the browser opens the destination in a new tab. The page in that new tab can reach back to the tab that opened it through a property called window.opener. That reference is not read-only: the new page can assign to window.opener.location, and doing so navigates the original tab.

Because the navigation happens in the background while the user is looking at the new tab, the user does not see the original tab change. The researcher calls this the core danger: a site that sends users to external links can be used to silently move those users onto a scam page.

Exploitation

Step 1: Open the proof of concept with a normal click

The researcher supplied a landing page and asked the reader to click the link on it in the ordinary way:

Text
http://daniel-tomescu.com/hackerone/landpage.php

The researcher supplied this link as the proof of concept. The instruction to click normally is deliberate: a normal click on a target="_blank" link creates the opener relationship between the two tabs. Opening the same link through the context menu, the mouse wheel or Ctrl+Click does not produce the same setup, so the demonstration only works with a plain click.

Step 2: The new tab rewrites the opener's location

The code that performs the redirect is a single line:

JavaScript
window.opener.location.replace(newURL);

Line by line:

  • window is the browser's name for the current tab, the one running this code.
  • window.opener is the tab that opened this one. It is a handle to the other tab, not a copy.
  • .location is the address bar of that other tab, the thing that decides which page it is showing.
  • .replace(newURL) tells that address bar to go to newURL. Unlike simply assigning a new address, replace does not leave the previous page in the browser's back history, so the user cannot easily step back to where they were.

The result is that the original hackerone.com tab, still in the background, is now showing a page the attacker controls.

Root cause

The issue is that opening external links with target="_blank" leaves the new tab a live reference to its opener. By default the new tab keeps a live reference to its opener, and that reference exposes a writable location. Nothing on the hackerone.com side checks or controls where the new tab sends the original window, because the navigation is started by the external page, not by hackerone.com.

The researcher notes that some sites already defend against this. Google sites and twitter.com open links in new tabs but set window.opener to null, so the new page has no handle on the original tab. The researcher notes that some sites already defend against this: Google sites and twitter.com open links in new tabs but set window.opener to null.

Impact

An attacker who can get a hackerone.com user to click an external link can silently replace the hackerone.com tab with a page of their choosing. The user's attention is on the new tab, so the swap goes unnoticed. The researcher also points out that some browsers, Mozilla for Android among them, show only the page title and not the URL, leaving the user no way to tell that the tab was redirected to a scam page.

The researcher describes a specific escalation. If the trick is used while a user is submitting a bug on hackerone.com/someTarget, the attacker may obtain the logon credentials of a representative of that target program and gain access to their account, including private reports submitted by other researchers. That outcome depends on the redirected tab being used to harvest credentials, which the report presents as a possibility rather than a demonstrated capture.

Fix

The report offers two remedies.

  1. Do not open links from hackerone.com in new tabs using target="_blank".
  2. Set the window.opener attribute to null on the new tab before redirecting to the landing page. The researcher sketches this as a three-part flow:
Text
a) open in a new tab hackerone.com/redirect?link=landingpage
b) use a javascript code: <script>window.opener = null; </script>
c) redirect to the landing page: <script>window.location.reload(landingpage)</script>

What each part does:

  • Part a) is an intermediate page on hackerone.com itself. The user first lands on a page the site controls, not on the external site.
  • Part b) is a small script that sets window.opener to null. In plain terms, it throws away the handle back to the original tab, so the page can no longer reach it.
  • Part c) then sends the user on to the external landing page. By this point there is no handle left, so the external page cannot navigate the original tab.

The idea is that the intermediate page clears the opener reference first, so that by the time the user reaches the external landing page there is no way left to move the original tab. The report does not record which of these options was adopted.

Variants to test

  • Any outbound link rendered with target="_blank" on a site that handles sensitive sessions. A positive result is that the linked page can read window.opener and assign to window.opener.location, moving the original tab.
  • Links inside user-generated content, such as submitted reports or comments, where an attacker controls the destination. A positive result is the same background navigation of the victim's tab.
  • Mobile browsers that display only the page title. A positive result is that the redirected tab gives the user no visible URL to check.

Hunting notes

This class of bug hides wherever a site sends users to external destinations in a new tab: profile links, report attachments, redirect endpoints and any user-supplied URL that is rendered as a link. During recon, the signal is a target="_blank" on links whose destination is not fully controlled by the site, combined with a session worth stealing on the originating tab.

The researcher made the impact concrete by naming a scenario: a target representative submitting a report on hackerone.com/someTarget, whose credentials and private reports could be exposed.

Glossary

  • Bug bounty platform: a website where researchers report security bugs in exchange for payment.
  • Program: a company or project on such a platform that accepts reports about its own software.
  • Bounty: the money paid for an accepted report.
  • Open redirect: a weakness where a site can be made to send a user to an address the site does not control.
  • target="_blank": an HTML attribute on a link that tells the browser to open the destination in a new tab.
  • Tab: one page view inside a browser window.
  • window: the browser's name for the current tab and the page running in it.
  • window.opener: a handle from a tab back to the tab that opened it.
  • location: the part of a tab that holds the address it is showing.
  • location.replace(newURL): a command that sends a tab to a new address without keeping the old one in the back history.
  • Session history: the list of pages a tab has visited, which the back and forward buttons walk through.
  • Proof of concept (POC): a small demonstration that shows a bug is real.
  • Credentials: the username and password (or similar) used to log in to an account.
  • Recon: the early stage of testing where you look around a site for things worth investigating.
  • User-generated content: text or links that ordinary users, rather than the site owner, put on the site.
  • Session: the period during which a site remembers that you are logged in.

More by thetime

View all

1 more disclosed report, best first.

More from HackerOne

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.