Skip to main content

Command Palette

Search for a command to run...

Avoid target='_blank' attribute without rel='noopener noreferrer'

Updated
1 min read
Avoid target='_blank' attribute without rel='noopener noreferrer'
D

A passionate full-stack developer from @ePlus.DEV

Description

A malicious actor can gain full control over the user's DOM window object. This can lead to phishing attacks such as fake login prompts or password alerts being shown to the user.

Using target='_blank' links grants the page we are linking to a partial access to the source page via the window.opener object.

The newly opened tab can then change the window.opener.location to some phishing page. Or execute some JavaScript on the opener page on their behalf. Since the users trust the page that is already opened, they won't get suspicious and this might result in a security risk.

Bad Practice

  <a href="http://example.com" target="_blank" >link</a>
<a href="http://example.com" target="_blank" rel="noopener noreferrer">link</a>

References