当前位置:网站首页>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
边栏推荐
- The JS solution cannot be executed after Ajax loads HTML
- PHP backdoor hiding skills
- 如何解决谷歌Chrome浏览器空白页的问题
- How to optimize the decoding performance of dynamsoft barcode reader
- How to add modules to nginx image?
- ajax 载入html后不能执行其中的js解决方法
- 三步轻松理解Kerberos协议
- Using LWA and lync to simulate external test edge free single front end environment
- Introduction to Jenkins (2) declarative pipeline
- pc端与移动端适配解决方案之rem
猜你喜欢
Getting started with varhart xgantt
一种超参数优化技术-Hyperopt
Rech8.0 learning days 12 rh134
In simple terms, the large front-end framework angular6 practical course (angular6 node.js 、keystonejs、
Kubernetes (1): introduction to kubernetes
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
使用RabbitMQ实现分布式事务
Jenkins pipline stage setting timeout
How to create an interactive kernel density chart
About Devops seven misunderstandings, 99% of people have been hit!
随机推荐
Solution to st link USB communication error in stlink Download
一种超参数优化技术-Hyperopt
Windows 10 Bluetooth management page 'add Bluetooth or other devices' option click no response solution
Test the necessary skill points of siege lion! This article takes you to interpret the testing technology under Devops
如何利用PopupWindow实现弹出菜单并解决焦点获取以及与软键盘冲突问题
HandlerMethodArgumentResolver使用和原理
.NETCore3.1+Vue.js打造的低代码工作流引擎
Key points of C language -- index article (let you fully understand indicators) | understand indicators from memory | complete analysis of indicators
The first choice for lightweight GPU applications is the NVIDIA vgpu instance launched by Jingdong Zhilian cloud
频收罚单的浦发银行:增收不增利,曾遭骗贷数亿元,内控缺位?
A kind of super parameter optimization technology hyperopt
K-vim installation and the ycmd server shut down (restart with ': ycmrestartserver')
8.Swarm创建维护和水平扩展Service
Python3 operating gitlab
条形码识别性能低,如何优化Dynamsoft Barcode Reader解码性能
HMS Core推送服务,助力电商App开展精细化运营
Image processing toolkit imagexpresshow to view events
Yum [errno 256] no more mirrors to try solution
Using rabbitmq to implement distributed transaction
把 4个消息队列都拉到一个群里后,他们吵起来了