Background
Today eslint reports an error when I introduce eslint-plugin-react
error Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blankWhy
Opening a new tab/window, either by hyperlinks (i.e tag with target attribute set to _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 fixhtyperlink types
Add rel="noopenner" to outgoing links. E.g.
Specify noopener in window features
window.open("https://abc.com", "security", "noopener");
Reset opener property
Note: this technique is subject to Same Origin Policy
let nw = window.open("https://abc.com", "security"); nw.opener = null;Reference
About rel=noopener
Target="_blank" - the most underestimated vulnerability ever
NoticeIf you want to follow the latest news/articles for the series of my blogs, Please 「Watch」to Subscribe.
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/11397.html
阅读 3011·2021-11-22 12:06
阅读 598·2021-09-03 10:29
阅读 6524·2021-09-02 09:52
阅读 2013·2019-08-30 15:52
阅读 3411·2019-08-29 16:39
阅读 1189·2019-08-29 15:35
阅读 2060·2019-08-29 15:17
阅读 1416·2019-08-29 11:17