Security rules
NGB033: window.open() without noopener
Reports window.open(url) calls that open another site (an absolute external URL or a dynamic URL) in a new browsing context without noopener or noreferrer in the features argument, when the returned window handle is not used.
| Property | Value |
|---|---|
| Rule ID | NGB033 |
| Category | iframe & cross-window communication |
| Default severity | low |
| CWE | CWE-1022 |
| Built-in presets | recommended: warn, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reports window.open(url) calls that open another site (an absolute external URL or a dynamic URL) in a new browsing context without noopener or noreferrer in the features argument, when the returned window handle is not used. The opened page then receives window.opener and can navigate your tab.
Why it matters
Unlike <a target="_blank"> (which browsers now treat as noopener), window.open() still gives the new page a reference to your window. A malicious or compromised destination can run window.opener.location = 'https://phish.example/login' and replace your application with a look-alike while the user is reading the other tab (reverse tabnabbing).
Detection behavior and supported patterns
window.open(url),window.open(url, "_blank"),open(url, name, "width=600")resolved to the DOMWindow.open- Reported when the URL is dynamic or an absolute
http(s)://URL, the target is not_self/_parent/_top, the features do not containnoopener/noreferrer, and the return value is discarded - Relative same-origin URLs (
/help) are not reported
Example
window.open(this.partnerUrl, '_blank');Safer alternative
window.open(this.partnerUrl, '_blank', 'noopener,noreferrer');Remediation
Pass noopener,noreferrer: window.open(url, '_blank', 'noopener,noreferrer'), or set popup.opener = null immediately when you need the handle.
False-positive considerations
- A dynamic URL that always points to your own origin is reported; the impact is nil in that case.
Known limitations
- Popups whose handle is kept (e.g. OAuth or payment popups that use
postMessage) need the opener and are not reported. - Dynamic feature strings are treated as not containing
noopener.
References
Run it
ngbastion explain NGB033