当前位置:网站首页>Introduction to referer and referer policy
Introduction to referer and referer policy
2022-07-07 20:25:00 【zzhongcy】
1. What is? Referer
referer Parameter is http Request header header A key parameter in , It means the source address of the link , For example, introduce pictures into the page 、JS And so on , Or jump links , Generally, the strategy is not modified , They'll bring Referer
Referer Security
Referer This http header If the parameters of are applied properly , It can improve security , such as , This parameter actually tells which website the link request comes from , So you can use this feature , Some interfaces can only be adjusted by this website , External websites cannot be adjusted
Case study :
For example, you have visited the bank in the browser A Website , So the browser has to save Cookie Of ,Cookie It's not overdue , At this time , You accidentally log in to a malicious forum website or some website , You visited the link ( In fact, what is added after the link is stealing Cookie, Transfer bank A Website transfer API), Now , If the website security cannot be verified , A malicious operation that will steal money
For this case of bank transfer theft , Maybe we can transform , We can add another verification project , Do not call the transfer interface directly , We add... To this verification project Referer Identification of the . Now ,CSRF Words of attack , It must be in a non bank A The server on the official website sends a request , After our transformation , This request will be sent to the verification project first , At this time, resolve the request , obtain Referer Property to identify , It's not a bank A Address of the official website , At this time, directly intercept , Access denied .
This case is a reasonable application Referer Of , Of course Referer Is the record source address , Obviously , This Referer Of url It is likely to bring some sensitive information , such as token Or user information , Once these are stolen by other websites , It's very dangerous , If for Referer Parameters should be used reasonably , So it is necessary to introduce w3c Proposed referrer policy
ps:http header Inside referer In fact, there is one missing spelling r, The correct spelling should be referrer , But at the beginning http When the standard is issued , I didn't find any spelling mistakes , So now I keep spelling mistakes
Related terms
The same-origin policy : Homology strategy refers to the agreement + domain name + The ports are the same , By Netscape A well-known security policy proposed , All support now JavaScript All browsers of will use this strategy . actually , This strategy is just a specification , It's not mandatory , The browsers of major manufacturers are only an implementation of the same source strategy
Cross-domain request : A cross domain request is a situation that does not conform to the source policy , That's the agreement 、 domain name 、 One or more ports are different , Are all cross domain requests , therefore https Link and http The mutual call of links is also a cross domain request
2. What is? Referrer-Policy
The Referrer-Policy
HTTP header governs which referrer information, sent in the Refererheader, should be included with requests made.
The popular point is Referrer The strategy of , Referrer Namely referrer Property to return the URL
.
Syntax
Referrer-Policy: no-referrer
Referrer-Policy: no-referrer-when-downgrade
Referrer-Policy: origin
Referrer-Policy: origin-when-cross-origin
Referrer-Policy: same-origin
Referrer-Policy: strict-origin
Referrer-Policy: strict-origin-when-cross-origin
Referrer-Policy: unsafe-url
If the value is invalid, it is the default value .
value
no-referrer
Whole Referer The first one will be removed . Access source information is not sent with the request
no-referrer-when-downgrade ( The default value is )
The default behavior of a user agent without specifying any policy . In the same level of security , The address of the reference page will be sent (HTTPS->HTTPS), But will not be sent in case of demotion (HTTPS->HTTP).
origin
In any case , Send only the source of the file as the reference address . for example https://example.com/page.html Will Example Domain As a reference address .
origin-when-cross-origin
For homologous requests , Will send the complete URL As a reference address , But for non homologous requests only send the source of the file .
same-origin
about Homologous request Will send the reference address , However, for non homologous requests, the reference address information is not sent
strict-origin
In the same level of security , Send the source of the file as the reference address (HTTPS->HTTPS), In the case of sending... But not degraded (HTTPS->HTTP).
strict-origin-when-cross-origin
For homologous requests , Will send the complete URL As a reference address ; In the same level of security , Send the source of the file as the reference address (HTTPS->HTTPS); Do not send this header in case of degradation (HTTPS->HTTP).
unsafe-url
Whether it's a homologous request or a non homologous request , Send the complete URL( After removing the parameter information ) As a reference address .( The most unsafe strategy )
Referrer Policy Delivery
Know what strategies can be used , You also need to know how to use . Here we introduce the designation Referrer Policy In three ways :
CSP Response head
CSP(Content Security Policy), Is a specification related to page content security . stay HTTP Through... In the response header Content-Security-Policy
Field to tell the browser what to use on the current page CSP Strategy . I wrote an article before Content Security Policy Introduce , You can have a look first . Now? CSP You can also use referrer
Instruction and five optional instruction values , To specify the Referrer Strategy , The format is very simple :
Content-Security-Policy: referrer no-referrer|no-referrer-when-downgrade|origin|origin-when-cross-origin|unsafe-url;
notes : according to file , adopt CSP Head set Origin When Cross-origin
strategy , The instruction value should be origin-when-cross-origin
, This is the same as that in the previous table origin-when-crossorigin
There are differences . Actually, after my test ,Chrome 42 Only support origin-when-crossorigin
, Whether it will change in the future is still unknown , It is recommended that you use , Test yourself first .
CSP Instructions and instruction values are separated by spaces , Multiple instructions are separated by English semicolon .
<meta> label
adopt <meta>
Labels can also be specified Referrer Strategy , It's also very simple :
<meta name="referrer" content="no-referrer|no-referrer-when-downgrade|origin|origin-when-crossorigin|unsafe-url">
It should be noted that ,<meta>
Only on the <head>...</head>
Between , If the position is wrong, it will be ignored . Again , If it is not defined content
attribute , perhaps content
Attribute is empty , It's also ignored . If content
Property is not a legal value , The browser will automatically select no-referrer
This most stringent strategy .
<a> Labeled referrer attribute
By giving <a>
Label increase referrer
Property can also be specified Referrer Strategy , The format is as follows :
<a href="http://example.com" referrer="no-referrer|origin|unsafe-url">xxx</a>
This way only works on this link . also ,<a>
Tags are available Referrer There are only three strategies : Don't pass on 、 Transmission only host Hedu Chuan . in addition , In this way, the policy priority set for a single link is higher than CSP and <meta>
higher .
It should be noted that : After my test , At present, no browser has realized the right referrer
Attribute support . At this stage , If you want to remove for a single link Referrer, It is recommended to use the following method with better support ( details ):
<a href="http://example.com" rel="noreferrer">xxx</a>
Again , At this stage, browsers still retain the right never、default and always Support for , But it is no longer recommended .
You can see , Adopt new Referrer Strategy , Website owners can choose a higher level of security to ensure that users' privacy is not compromised ; You can also choose a lower security level to get some convenience , Compared with the previous browser default policy, one size fits all , It's really flexible .
Reference resources :
HTTP Series of Referer and Referrer policy brief introduction - smileNicky - Blog Garden
边栏推荐
- EasyGBS级联时,上级平台重启导致推流失败、画面卡住该如何解决?
- 有了ST7008, 蓝牙测试完全拿捏住了
- 《数字图像处理原理与实践(MATLAB版)》一书之代码Part2[通俗易懂]
- 【哲思与实战】程序设计之道
- c语言如何判定是32位系统还是64位系统
- MIT science and technology review article: AgI hype around Gato and other models may make people ignore the really important issues
- You want to kill a port process, but you can't find it in the service list. You can find this process and kill it through the command line to reduce restarting the computer and find the root cause of
- Vulnhub tre1
- About cv2 dnn. Readnetfromonnx (path) reports error during processing node with 3 inputs and 1 outputs [exclusive release]
- Data sorting in string
猜你喜欢
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
智能软件分析平台Embold
php 获取图片信息的方法
Implement secondary index with Gaussian redis
H3C s7000/s7500e/10500 series post stack BFD detection configuration method
Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
Yolov6:yolov6+win10--- train your own dataset
最新版本的CodeSonar改进了功能安全性,支持MISRA,C ++解析和可视化
CodeSonar网络研讨会
AADL Inspector 故障树安全分析模块
随机推荐
Spark judges that DF is empty
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
怎样用Google APIs和Google的应用系统进行集成(1)—-Google APIs简介
目前股票开户安全吗?可以直接网上开户吗。
Solve the problem that the executable file of /bin/sh container is not found
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
浅尝不辄止系列之试试腾讯云的TUIRoom(晚上有约,未完待续...)
网络原理(1)——基础原理概述
阿里云有奖体验:如何通过ECS挂载NAS文件系统
【解决】package ‘xxxx‘ is not in GOROOT
九度 1201 -二叉排序数遍历- 二叉排序树「建议收藏」
使用 BR 恢复 Azure Blob Storage 上的备份数据
写了个 Markdown 命令行小工具,希望能提高园友们发文的效率!
Tensorflow2.x下如何运行1.x的代码
CodeSonar网络研讨会
最新版本的CodeSonar改进了功能安全性,支持MISRA,C ++解析和可视化
搞定带WebKitFormBoundary post登录
Mongodb learn from simple to deep
c语言如何判定是32位系统还是64位系统
解决/bin/sh进去的容器运行可执行文件报not found的问题