a標簽跳轉referer漏洞


a標簽打開新頁面時需要添加  rel="noopener noreferrer" 

否則,在新打開的頁面(http://www.baidu.com)中可以通過 window.opener 獲取到源頁面的部分控制權,即使新打開的頁面是跨域的也照樣可以(例如 location 就不存在跨域問題)。

在 Chrome 49+,Opera 36+,打開添加了 rel=noopener 的鏈接, window.opener 會為null。在老的瀏覽器中,可以使用 rel=noreferrer 禁用HTTP頭部的Referer屬性

如下:

<a href="http://www.baidu.com" target="_blank" rel="noopener noreferrer">百度</a>

 

 

在element UI中 el-link 相當於a標簽

                 <el-table-column label="查看" prop="url" width="70">
                    <template slot-scope="{row}">
                      <el-link :href='row.url'
                        :underline="false"
                        target="_blank"
                        rel='noopener noreferrer'
                      >
                        <i class="el-icon-view el-icon--right"></i>
                      </el-link>
                    </template>
                  </el-table-column>

 

 

另外,可以使用 window.open 打開頁面,手動將 opener 設置為 null。

var otherWindow = window.open('http://www.baidu.com');
otherWindow.opener = null;
otherWindow.location = url;

 

 

參考:

https://blog.csdn.net/huolang110/article/details/80905596

https://element.eleme.cn/#/zh-CN/component/link

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM