CWE

Common Weakness Enumeration

A Community-Developed List of Software Weakness Types

CWE/SANS Top 25 Most Dangerous Software Errors
Home > CWE List > CWE- Individual Dictionary Definition (3.1)  
ID

CWE-1022: Use of Web Link to Untrusted Target with window.opener Access

Weakness ID: 1022
Abstraction: Variant
Structure: Simple
Status: Incomplete
Presentation Filter:
+ Description
The web application produces links to untrusted external sites outside of its sphere of control, but it does not properly prevent the external site from modifying security-critical properties of the window.opener object, such as the location property.
+ Extended Description
When a user clicks a link to an external site ("target"), the target="_blank" attribute causes the target site's contents to be opened in a new window or tab, which runs in the same process as the original page. The window.opener object records information about the original page that offered the link. If an attacker can run script on the target page, then they could read or modify certain properties of the window.opener object, including the location property - even if the original and target site are not the same origin. An attacker can modify the location property to automatically redirect the user to a malicious site, e.g. as part of a phishing attack. Since this redirect happens in the original window/tab - which is not necessarily visible, since the browser is focusing the display on the new target page - the user might not notice any suspicious redirection.
+ Alternate Terms
tabnabbing
+ Relationships

The table(s) below shows the weaknesses and high level categories that are related to this weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore.

+ Relevant to the view "Research Concepts" (CWE-1000)
NatureTypeIDName
ChildOfBaseBase - a weakness that is described in an abstract fashion, but with sufficient details to infer specific methods for detection and prevention. More general than a Variant weakness, but more specific than a Class weakness.266Incorrect Privilege Assignment
+ Relevant to the view "Development Concepts" (CWE-699)
NatureTypeIDName
MemberOfCategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic.442Web Problems
ChildOfBaseBase - a weakness that is described in an abstract fashion, but with sufficient details to infer specific methods for detection and prevention. More general than a Variant weakness, but more specific than a Class weakness.266Incorrect Privilege Assignment
+ Modes Of Introduction

The different Modes of Introduction provide information about how and when this weakness may be introduced. The Phase identifies a point in the software life cycle at which introduction may occur, while the Note provides a typical scenario related to introduction during the given phase.

PhaseNote
Architecture and DesignThis weakness is introduced during the design of an application when the architect does not specify that a linked external document should not be able to alter the location of the calling page.
ImplementationThis weakness is introduced during the coding of an application when the developer does not include the noopener and/or noreferrer value for the rel attribute.
+ Applicable Platforms
The listings below show possible areas for which the given weakness could appear. These may be for specific named Languages, Operating Systems, Architectures, Paradigms, Technologies, or a class of such platforms. The platform is listed along with how frequently the given weakness appears for that instance.

Languages

JavaScript (Often Prevalent)

Paradigms

Web Based (Often Prevalent)

+ Common Consequences

The table below specifies different individual consequences associated with the weakness. The Scope identifies the application security area that is violated, while the Impact describes the negative technical impact that arises if an adversary succeeds in exploiting this weakness. The Likelihood provides information about how likely the specific consequence is expected to be seen relative to the other consequences in the list. For example, there may be high likelihood that a weakness will be exploited to achieve a certain impact, but a low likelihood that it will be exploited to achieve a different impact.

ScopeImpactLikelihood
Confidentiality

Technical Impact: Alter Execution Logic

The user may be redirected to an untrusted page that contains undesired content or malicious script code.
+ Likelihood Of Exploit
Medium
+ Demonstrative Examples

Example 1

In this example, the application opens a link in a named window/tab without taking precautions to prevent the called page from tampering with the calling page's location in the browser.

There are two ways that this weakness is commonly seen. The first is when the application generates an <a> tag is with target="_blank" to point to a target site:

(bad code)
Example Language: HTML 
<a href="http://attacker-site.example.com/useful-page.html" target="_blank">

If the attacker offers a useful page on this link (or compromises a trusted, popular site), then a user may click on this link. However, the attacker could use scripting code to modify the window.opener's location property to redirect the application to a malicious, attacker-controlled page - such as one that mimics the look and feel of the original application and convinces the user to re-enter authentication credentials, i.e. phishing:

(attack code)
Example Language: JavaScript 
window.opener.location = 'http://phishing.example.org/popular-bank-page';

To mitigate this type of weakness, some browsers support the "rel" attribute with a value of "noopener", which sets the window.opener object equal to null. Another option is to use the "rel" attribute with a value of "noreferrer", which in essence does the same thing.

(good code)
Example Language: HTML 
<a href="http://attacker-site.example.com/useful-page.html" target="_blank" rel="noopener noreferrer">

A second way that this weakness is commonly seen is when opening a new site directly within JavaScript. In this case, a new site is opened using the window.open() function.

(bad code)
Example Language: JavaScript 
var newWindow = window.open("http://attacker-site.example.com/useful-page.html", "_blank");

To mitigate this, set the window.opener object to null.

(good code)
Example Language: JavaScript 
var newWindow = window.open("http://attacker-site.example.com/useful-page.html", "_blank");
newWindow.opener = null;
+ Potential Mitigations

Phase: Architecture and Design

Specify in the design that any linked external document must not be granted access to the location object of the calling page.

Phase: Implementation

When creating a link to an external document using the <a> tag with a defined target, for example "_blank" or a named frame, provide the rel attribute with a value "noopener noreferrer".

If opening the external document in a new window via javascript, then reset the opener by setting it equal to null.

Phase: Implementation

Do not use "_blank" targets. However, this can affect the usability of your application.

+ References
[REF-39] Alex Yumashev. "Target="_blank" - the most underestimated vulnerability ever". 2016-05-04. <https://medium.com/@jitbit/target-blank-the-most-underestimated-vulnerability-ever-96e328301f4c>.
[REF-40] Ben Halpern. "The target="_blank" vulnerability by example". 2016-09-11. <https://dev.to/ben/the-targetblank-vulnerability-by-example>.
[REF-958] Mathias Bynens. "About rel=noopener". 2016-03-15. <https://mathiasbynens.github.io/rel-noopener/>.
+ Content History
Submissions
Submission DateSubmitterOrganization
2017-09-26David DeatherageSilicon Valley Bank
Modifications
Modification DateModifierOrganization
2018-03-27CWE Content TeamMITRE
updated Alternate_Terms, Demonstrative_Examples, Description, Modes_of_Introduction, Name, Potential_Mitigations, References
Previous Entry Names
Change DatePrevious Entry Name
2018-03-27Improper Restriction of Cross-Origin Permission to window.opener.location

More information is available — Please select a different filter.
Page Last Updated: March 29, 2018