Security risk for opening new tabs or windows
Background
Today eslint reports an error when I introduce Opening a new tab/window, either by hyperlinks (i.e <a> tag with target attribute set to Add Specify Reset Note: this technique is subject to Same Origin Policy If you want to follow the latest news/articles for the series of my blogs, Please 「Watch」to Subscribe.Why
_blank
) or programmatically calling window.open, will grant the newly-opened tab/window access back to the originating tab/window via window.opener. Therefore, the newly opened tab/window can then change the window.opener.location
to redirect to the phishing page in the background, or execute some JavaScript on the opener-page on your behalf.How to fix
rel="noopenner"
to outgoing links. E.g.<a >
noopener
in window featureswindow.open('https://abc.com', 'security', 'noopener');
opener
propertylet nw = window.open('https://abc.com', 'security');
nw.opener = null;
Reference
Notice
作者:不吃猫的鱼_zjh
链接:https://www.jianshu.com/p/8d3e10279251
共同學習,寫下你的評論
評論加載中...
作者其他優(yōu)質文章