Unsafe use of target=”_blank”
Developers have been frequently using this attribute to open a new webpage. But this attribute, though looks pretty simple, can create a major security threat to your application.
The threat associated is called Reverse Tabnabbing
. The issue is the webpage that we are linking our existing page to gains a partial access to the linking page, or in other words, the target page or url gains a partial access to our parent page from where the user is redirected to a new url.
to some malicious page and also the parent page. In case the parent page has the same look and feel of the user intended page, he might end up sharing credentials or secure information assuming that the webpage is secure.
To prevent pages from misusing window.opener property, we use
. This ensures that window.opener is assigned to NULL.
This works in Chrome 49 and above, Opera 36 and above, Firefox 52 and above, Desktop Safari 10.1+ and iOS Safari 10.3+. Though for older browsers,
works pretty fine. So, as a combination, we can use
Also, remember, whenever we open a new window using
property, we’re also vulnerable to this, so, its always advisable to reset the
Subscribe to get your daily round-up of top tech stories!