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

## **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**

```apache
  <a href="http://example.com" target="_blank" >link</a>
```

### **Recommended**

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

## **References**

* [OWASP A05:2021 - Security Misconfiguration](https://owasp.org/Top10/A05_2021-Security_Misconfiguration/)
    
* [Reverse Tabnabbing](https://owasp.org/www-community/attacks/Reverse_Tabnabbing)
    
* [Links to cross-origin destinations are unsafe](https://web.dev/external-anchors-use-rel-noopener/)
    
* [rel-noopener](https://mathiasbynens.github.io/rel-noopener/)
