当前位置:网站首页>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
边栏推荐
- 2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
- Jenkins pipline stage setting timeout
- Three steps to understand Kerberos Protocol easily
- C# 枚举权限 |和||,&和&&的区别
- Chinese sub forum of | 2020 PostgreSQL Asia Conference: Pan Juan
- PHP backdoor hiding skills
- How to add modules to nginx image?
- “非洲用户的付费意愿并不低”——专访四达时代研发总监张亮
- DOM node operation
- Win7 AppCrash (solution)
猜你喜欢
CI / CD of gitlab continuous integrated development environment
Exclusive interview with alicloud database of | 2020 PostgreSQL Asia Conference: Wang Xu
Shanghai Pudong Development Bank, which frequently receives penalty tickets, has been cheated by hundreds of millions of yuan in loans, and lacks of internal control?
快進來!花幾分鐘看一下 ReentrantReadWriteLock 的原理!
PHP backdoor hiding skills
频收罚单的浦发银行:增收不增利,曾遭骗贷数亿元,内控缺位?
git 提交规范
南京标志设计,logo设计公司
Do you really know how to use search engines?
课堂练习
随机推荐
RFID fixed assets management system for fire equipment
JVM class loading mechanism
南京标志设计,logo设计公司
Key points of C language -- index article (let you fully understand indicators) | understand indicators from memory | complete analysis of indicators
In simple terms, the large front-end framework angular6 practical course (angular6 node.js 、keystonejs、
2020-11-06:go中,谈一下调度器。
抽絲剝繭——門面和調停者設計模式
.NETCore3.1+ Vue.js Low code workflow engine
你真的会使用搜索引擎吗?
想要忘记以前连接到Mac的WiFi网络,试试这个方法!
RECH8.0版本学习 days 12 rh134部分
How does LeadTools detect, read and write barcodes
Getting started with varhart xgantt
Didi's distributed ID generator (tinyid), easy to use
Shanghai Pudong Development Bank, which frequently receives penalty tickets, has been cheated by hundreds of millions of yuan in loans, and lacks of internal control?
嘉宾专访|2020 PostgreSQL亚洲大会中文分论坛:岳彩波
8. Swarm creates maintenance and horizontal extension service
嘉宾介绍|2020 PostgreSQL亚洲大会中文分论坛:潘娟
如何创建交互式内核密度图表
廬山真面目之二微服務架構NGINX版本實現