当前位置:网站首页>chrome浏览器跨域Cookie的SameSite问题导致访问iframe内嵌页面异常
chrome浏览器跨域Cookie的SameSite问题导致访问iframe内嵌页面异常
2020-11-07 18:55:00 【麦漁翁】
Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute
问题还原
原先一直访问正常的系统,最近打开页面一直加载不出来。
- 初步分析,该系统为iframe内嵌第三方系统页面,将iframe中的链接复制出来可以单独访问,排除第三方系统的问题。
- 进一步尝试,将这个带有链接的iframe放在一个全新的html文件中也不能正常访问,排除当前系统的iframe加载问题。
- 发现问题,将刚刚新建的html文件再火狐浏览器中打开可以正常访问。 最后定位是浏览器兼容性问题,当前浏览器:Google Chrome ,版本85.0.4183.102(正式版本) (64 位)。
打开浏览器控制台发现接口请求报500错,控制台出现以下提示(Indicate whether a cookie is intended to be set in a cross-site context by specifying its SameSite attribute):
原因分析
Google 在2020年2月4号发布的 Chrome 80 版本(schedule:https://www.chromestatus.com/features/schedule)中默认屏蔽所有第三方 Cookie,即默认为所有 Cookie 加上 SameSite=Lax 属性(https://www.chromestatus.com/feature/5088147346030592),并且拒绝非Secure的Cookie设为 SameSite=None(https://www.chromestatus.com/feature/5633521622188032)
SameSite的作用就是防止跨域传送cookie,从而防止 CSRF 攻击和用户追踪,此举是为了从源头屏蔽 CSRF 漏洞。
关于 SameSite 属性的介绍,可参考阮一峰的《Cookie 的 SameSite 属性》。
上述问题中,在当前系统访问第三方系统时,带了一些cookie过去,然后被这个SameSite机制拦截掉了。
可能在 Chrome 80 中受到影响的场景如下
组件数据基于第三方网站的登录态返回相关用户数据的API请求
HTTP 本地部署
解决方案
- Chrome浏览器打开新标签页,地址栏中分别输入
chrome://flags/#same-site-by-default-cookies
chrome://flags/#cookies-without-same-site-must-be-secure
然后如上如图所示将这两个配置均设置为Disabled
-
不使用谷歌浏览器或者将谷歌浏览器降级到 Chrome 79 及以下版本,并关闭自动更新。
-
将两个系统部署在同一台服务器,通过相同IP同源策略传送cookie。
-
购买SSL证书,升级HTTP服务,将 API 切换为 HTTPS 协议请求,并且检查响应头中的 Set-Cookie 中是否包含了 SameSite=None 和 Secure字样。
版权声明
本文为[麦漁翁]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/3204029/blog/4707684
边栏推荐
- 一种超参数优化技术-Hyperopt
- Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
- Blazor 準備好為企業服務了嗎?
- RFID fixed assets management system for fire equipment
- 谈了多年的数字化转型,为什么还有很多企业依然“口头管理”
- 9. Routingmesh service communication between clusters
- k-vim安装及The ycmd server SHUT DOWN (restart with ':YcmRestartServer')这种错误的解决方法
- Gantt chart grouping activities tutorial
- 使用LWA和Lync模拟外部测试无边缘单前端环境
- 想要忘记以前连接到Mac的WiFi网络,试试这个方法!
猜你喜欢
JS array the usage of array is all here (array method reconstruction, array traversal, array de duplication, array judgment and conversion)
In simple terms, the large front-end framework angular6 practical course (angular6 node.js 、keystonejs、
How does varhart xgantt represent working days on a calendar
Gantt chart grouping activities tutorial
如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
.NETCore3.1+ Vue.js Low code workflow engine
confd
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
Getting started with varhart xgantt
Logo design company, Nanjing
随机推荐
JVM class loading mechanism
Web API interface design: swaggerui document / unified response format / unified exception handling / unified authority verification
Dynamsoft barcode reader v7.5!
Git SSH bad permissions
7. Swarm builds clusters
2020-11-06:go中,谈一下调度器。
南京标志设计,logo设计公司
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
嘉宾专访|2020 PostgreSQL亚洲大会中文分论坛:岳彩波
confd
Using LWA and lync to simulate external test edge free single front end environment
DOM node operation
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
9. Routingmesh service communication between clusters
【涂鸦物联网足迹】物联网主流通信方式
Idea activation to 2089 failure
如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
python3操作Jenkins模块api