Skip to content

Files

Latest commit

 

History

History
22 lines (16 loc) · 721 Bytes

jsx-no-target-blank.md

File metadata and controls

22 lines (16 loc) · 721 Bytes

Pattern: Unsafe target="_blank" usage

Issue: -

Description

Using target="_blank" without rel="noreferrer" creates a security vulnerability. The opened link can access the original window's window.opener property and potentially redirect to malicious sites. Adding rel="noreferrer" prevents this security issue.

Examples

Example of incorrect code:

<a target="_blank" href="https://example.com/"></a>
<a target="_blank" href={dynamicLink}></a>

Example of correct code:

<a target="_blank" rel="noreferrer" href="https://example.com"></a>
<a target="_blank" rel="noopener noreferrer" href="https://example.com"></a>
<a target="_blank" href="/absolute/path/in/the/host"></a>