SlideShare a Scribd company logo
What’s wrong with w/ WebSocket API?
Unveiling vulnerabilities in
WebSocket APIs
Mikhail Egorov / @0ang3el
#HACKTIVITY2019
# whoami
2
▪ Security researcher / full-time bug hunter
▪ https://bugcrowd.com/0ang3el
▪ https://hackerone.com/0ang3el
▪ Conference speaker
▪ https://www.slideshare.net/0ang3el
▪ https://speakerdeck.com/0ang3el
Previous work
3
▪ https://media.blackhat.com/bh-us-
12/Briefings/Shekyan/BH_US_12_Shekyan_Toukharian_Hacking_Websocket_Slides
.pdf
▪ https://www.nccgroup.trust/us/about-us/newsroom-and-
events/blog/2017/may/wssip-a-websocket-manipulation-proxy/
▪ https://chybeta.github.io/2018/04/07/spring-messaging-Remote-Code-Execution-
%E5%88%86%E6%9E%90-%E3%80%90CVE-2018-1270%E3%80%91/
▪ https://www.twistlock.com/labs-blog/demystifying-kubernetes-cve-2018-1002105-
dead-simple-exploit/
▪ https://github.com/andresriancho/websocket-fuzzer
▪ https://www.irongeek.com/i.php?page=videos/derbycon9/stable-35-old-tools-new-
tricks-hacking-websockets-michael-fowl-nick-defoe
4
WebSocket protocol essentials
WebSocket protocol – RFC 6455
5
▪ Efficient two-way communication protocol
▪ WebSocket is stateful (HTTP is stateless)
▪ Two main parts: handshake and data transfer
WebSocket protocol – RFC 6455
6
▪ Extensibility: subprotocols and extensions
▪ Subprotocols
▪ https://www.iana.org/assignments/websocket/websocket.xml#subpro
tocol-name
▪ Wamp
▪ Stomp
▪ Soap
▪ …
WebSocket protocol – RFC 6455
7
▪ Extensibility: subprotocols and extensions
▪ Extensions
▪ https://www.iana.org/assignments/websocket/websocket.xml#extens
ion-name
▪ permessage-deflate
▪ bbf-usp-protocol
WebSocket protocol – RFC 6455
8
▪ Origin-based security model (Browser clients)
▪ No authentication
▪ Client must do client-to-server masking
WebSocket protocol support
9
▪ Major web browsers
▪ Web servers / Proxies
▪ Apache httpd, Nginx, IIS, …
▪ HAProxy, Traefik, Varnish, Envoy, …
▪ Cloud providers
▪WebSocket API (api gateways)
▪WebSocket proxying (load balancers)
WebSocket handshake
10
Upgrade request
Base64(Random nonce)
Protocol version
Required HTTP version
WebSocket handshake
11
Required status code
BASE64(SHA1(Sec-WebSocket-Key || CONST ))
WebSocket data transfer
12
x00 – continuation frame
x01 – text frame
x02 – binary frame
x08 – close frame
x09 – ping
x0A – pong
other values are reserved
WebSocket data transfer - masking
13
▪ Masking key is 32-bit long passed inside frame
▪ Client must send masked data
▪ MASKED = MASK ^ DATA (^ - XOR)
▪ Mechanism protects against cache poisoning and
smuggling attacks
14
Cross-Site WebSocket Hijacking
WebSocket security for Web Browser
15
▪ SOP doesn’t work for WebSocket in web browser
▪ Read from WebSocket cross-origin
▪ Write to WebSocket cross-origin
▪ Header Origin should be checked on handshake
step (origin-based security model)
CSWSH
16
▪ Cookies are used to authenticate upgrade request
▪ Header Origin isn’t checked or checked poorly
CSWSH
17
▪ CORS tricks from @albinowax are applicable to
WebSocket
▪ https://portswigger.net/research/exploiting-cors-misconfigurations-
for-bitcoins-and-bounties
▪ Null origin
▪ Pre-domain wildcard
▪ Post-domain wildcard
▪ …
CSWSH – Null origin
18
▪ nullorigin.html
<iframe src="data:text/html,
<script>const socket = new
WebSocket('wss://example.com');
</script>"></iframe>
CSWSH
19
▪ Playground
▪ https://portswigger.net/web-security/websockets/cross-site-
websocket-hijacking
CSWSH – template for attack
5
Demo
5
22
Authentication / IDOR issues
Authentication
23
▪ WebSocket protocol doesn’t offer authentication
▪ Developers have to roll out their own AuthN
▪ It’s secure to check AuthN only during handshake
▪ Common secure implementations
▪ Session cookies
▪ Tokens
Broken authentication – Case 1
24
▪ Some ID / GUID is required in Upgrade request
▪ Guess ID
▪ Leak GUID (minor IDOR, …)
Broken authentication – Case 2
25
▪ No authentication during handshake step
▪ Some ID / GUID required in API messages
▪ Guess ID
▪ Leak GUID (minor IDOR, …)
Broken authentication – Case 2
26
▪ Exposing GraphQL subscriptions w/o AuthN
▪ https://github.com/righettod/poc-graphql#subscriptions-
websocket-endpoint-default-enabling
▪ Path /subscriptions
Insecure Direct Object Reference issues
27
▪ Strong authentication during handshake step
▪ Some ID / GUID required in API messages
▪ Guess ID
▪ Leak GUID (minor IDOR, …)
28
Smuggling through WebSocket
Reverse proxying WebSocket connection
29
Client
Frontend
Reverse proxy
Backend
/socket.io/
Public WebSocket API
Reverse proxying WebSocket connection
30
Client
Frontend
Reverse proxy
Upgrade request Upgrade request
Backend
/socket.io/
Reverse proxying WebSocket connection
31
Client
Frontend
Reverse proxy
Upgrade request Upgrade request
HTTP/1.1 101HTTP/1.1 101
Backend
/socket.io/
Reverse proxying WebSocket connection
32
Client
Frontend
Reverse proxy
Upgrade request Upgrade request
HTTP/1.1 101HTTP/1.1 101
WebSocket connection
direct WebSocket connection
Client - Backend
Backend
/socket.io/
Smuggling through WebSocket connection
33
Client
Frontend
Reverse proxy
(vulnerable)
Private REST API
Public WebSocket API
Backend
/internal
/socket.io/
34
BackendClient
Frontend
Reverse proxy
(vulnerable)
/internal
Upgrade request
/socket.io/
Sec-WebSocket-Version: 1337
Upgrade request
Sec-WebSocket-Version: 1337
Version correctness isn’t checked!
Smuggling through WebSocket connection
35
BackendClient
Frontend
Reverse proxy
(vulnerable)
/internal
Upgrade request
/socket.io/
Sec-WebSocket-Version: 1337
Upgrade request
Sec-WebSocket-Version: 1337
HTTP/1.1 426HTTP/1.1 426
Response correctness isn’t checked!
Smuggling through WebSocket connection
36
BackendClient
Frontend
Reverse proxy
(vulnerable)
/internal
Upgrade request
/socket.io/
Sec-WebSocket-Version: 1337
Upgrade request
Sec-WebSocket-Version: 1337
HTTP/1.1 426HTTP/1.1 426
TLS connection
direct TLS connection
Client – Backend
not WebSocket!!!
Client can access
/internal
Smuggling through WebSocket connection
Challenge – challenge.0ang3el.tk
37
▪ URL
▪ https://challenge.0ang3el.tk/websocket.html
▪ You need to access flag on localhost:5000
▪ Seems no one solved
Challenge – challenge.0ang3el.tk
38
▪ Frontend
▪ Not disclosed WebSocket reverse proxy
▪ socket.io.js
▪ Proxies only WebSocket API - /socket.io/ path
▪ Backend
▪ Flask, Flask-SoketIO, Flask-Restful
▪ Listens on localhost:5000 only
challenge1.py
challenge1.py - DEMO
Vulnerable reverse proxies
41
▪ Vulnerable
▪ Varnish, Envoy proxy <= 1.8.0, other non-disclosed
▪ Not vulnerable
▪ Nginx, HAProxy, Traefik, others
Varnish response
42
▪ WebSocket proxying configuration
▪ https://varnish-cache.org/docs/6.3/users-guide/vcl-example-
websockets.html
Smuggling through WebSocket connection
43
Client
Frontend
Reverse proxy
(Nginx or another)
Private REST API
Public WebSocket API & REST API
Backend
/internal
/api/socket.io/
/api/health
Smuggling through WebSocket connection
44
Client
Frontend
Reverse proxy
(Nginx or another)
Backend
/internal
/api/socket.io/
/api/health
example.com
GET
HTTP/1.1 200
Smuggling through WebSocket connection
45
Client
Frontend
Reverse proxy
(Nginx or another)
Backend
/internal
/api/socket.io/
/api/health
Only Upgrade: websocket header is checked!
POST /api/health?u= POST /api/health?u=
Smuggling through WebSocket connection
46
Client
Frontend
Reverse proxy
(Nginx or another)
Backend
/internal
/api/socket.io/
/api/health
attacker.com
GET
HTTP/1.1 101
HTTP/1.1 101HTTP/1.1 101
Only status code is checked for response!
POST /api/health?u= POST /api/health?u=
Smuggling through WebSocket connection
47
Client
Frontend
Reverse proxy
(Nginx or another)
Backend
/internal
/api/socket.io/
/api/health
HTTP/1.1 101HTTP/1.1 101
TLS connection
direct TLS connection
Client – Backend
not WebSocket!!!
Client can access
/internal
POST /api/health?u= POST /api/health?u=
Client-to-Server
masking isn’t checked
by proxy!!!
Challenge2 – challenge2.0ang3el.tk
48
▪ URL
▪ https://challenge2.0ang3el.tk/websocket.html
▪ You need to access flag on localhost:5000
▪ Seems no one solved
Challenge2 – challenge2.0ang3el.tk
49
▪ Frontend
▪ Nginx as WebSocket reverse proxy
▪ socket.io.js
▪ Proxies only /api/public path (socket.io and healthcheck)
▪ Backend
▪ Flask, Flask-SoketIO, Flask-Restful
▪ Listens on localhost:5000 only
Challenge2 – challenge2.0ang3el.tk
50
▪ Nginx config
Challenge2 – challenge2.0ang3el.tk
51
▪ REST API - healthcheck
Challenge2.py
5
Challenge2.py - Demo
5
Vulnerable reverse proxies
54
▪ Almost all proxies are affected
▪ But exploitation is limited
▪ External SSRF is required that returns status code
▪ …
55
Discovering WebSocket APIs
Discovering WebSocket API
56
▪ Monitor Upgrade requests
▪ Analyze JavaScript files
▪ Try to establish WebSocket connection to each
URL
▪ …
57
Conclusion
Ideas for further research
58
▪ Security of WebSocket subprotocols
▪ More smuggling techniques
▪ HTTP/2 and WebSocket
▪ …
Thank you!
@0ang3el

More Related Content

What's hot (20)

PDF
A story of the passive aggressive sysadmin of AEM
Frans Rosén
 
PDF
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
Mikhail Egorov
 
PDF
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
PDF
A Hacker's perspective on AEM applications security
Mikhail Egorov
 
PPTX
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
PDF
Securing AEM webapps by hacking them
Mikhail Egorov
 
PDF
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
hacktivity
 
PDF
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
Marco Balduzzi
 
PDF
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
Frans Rosén
 
PPTX
Understanding JWT Exploitation
AkshaeyBhosale
 
PPTX
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
PPTX
XXE: How to become a Jedi
Yaroslav Babin
 
PDF
Racing The Web - Hackfest 2016
Aaron Hnatiw
 
PPTX
Pentesting jwt
Jaya Kumar Kondapalli
 
PDF
Modern API Security with JSON Web Tokens
Jonathan LeBlanc
 
PPTX
Reverse proxies & Inconsistency
GreenD0g
 
PDF
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
Masato Kinugawa
 
PDF
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
Frans Rosén
 
PPTX
Taking Hunting to the Next Level: Hunting in Memory
Joe Desimone
 
PDF
Frans Rosén Keynote at BSides Ahmedabad
Security BSides Ahmedabad
 
A story of the passive aggressive sysadmin of AEM
Frans Rosén
 
AEM hacker - approaching Adobe Experience Manager webapps in bug bounty programs
Mikhail Egorov
 
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
A Hacker's perspective on AEM applications security
Mikhail Egorov
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
Securing AEM webapps by hacking them
Mikhail Egorov
 
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
hacktivity
 
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
Marco Balduzzi
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
Frans Rosén
 
Understanding JWT Exploitation
AkshaeyBhosale
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
XXE: How to become a Jedi
Yaroslav Babin
 
Racing The Web - Hackfest 2016
Aaron Hnatiw
 
Pentesting jwt
Jaya Kumar Kondapalli
 
Modern API Security with JSON Web Tokens
Jonathan LeBlanc
 
Reverse proxies & Inconsistency
GreenD0g
 
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
Masato Kinugawa
 
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
Frans Rosén
 
Taking Hunting to the Next Level: Hunting in Memory
Joe Desimone
 
Frans Rosén Keynote at BSides Ahmedabad
Security BSides Ahmedabad
 

Similar to What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs. (20)

PPTX
14. html 5 security considerations
Eoin Keary
 
PDF
Programming WebSockets - OSCON 2010
sullis
 
PDF
Node.js on microsoft azure april 2014
Brian Benz
 
PDF
Nodejs and WebSockets
Gonzalo Ayuso
 
PPTX
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
lior mazor
 
PDF
Websocket shanon
Takafumi Ikeda
 
PDF
Programming WebSockets - April 20 2010
sullis
 
PPTX
CodeIgniter i18n Security Flaw
Abbas Naderi
 
PDF
Attack Chaining: Advanced Maneuvers for Hack Fu
Rob Ragan
 
PDF
Analyzing the Performance of Mobile Web
Ariya Hidayat
 
PPTX
Everybody loves html5,h4ck3rs too
Nahidul Kibria
 
PDF
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Viktor Gamov
 
PPTX
Jon Stace Web Cryptography API
Jon Stace
 
PPTX
Malware Analysis For The Enterprise
Jason Ross
 
PDF
Single sign-on
Marek Stępniowski
 
PDF
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
 
DOCX
Exploration note - none windows based authentication for WCF
Shahzad
 
PPTX
Cross Context Scripting attacks & exploitation
Roberto Suggi Liverani
 
PDF
Ruby On Rails Security 9984
Dr Rushi Raval
 
PPTX
Html5 security
Krishna T
 
14. html 5 security considerations
Eoin Keary
 
Programming WebSockets - OSCON 2010
sullis
 
Node.js on microsoft azure april 2014
Brian Benz
 
Nodejs and WebSockets
Gonzalo Ayuso
 
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
lior mazor
 
Websocket shanon
Takafumi Ikeda
 
Programming WebSockets - April 20 2010
sullis
 
CodeIgniter i18n Security Flaw
Abbas Naderi
 
Attack Chaining: Advanced Maneuvers for Hack Fu
Rob Ragan
 
Analyzing the Performance of Mobile Web
Ariya Hidayat
 
Everybody loves html5,h4ck3rs too
Nahidul Kibria
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Viktor Gamov
 
Jon Stace Web Cryptography API
Jon Stace
 
Malware Analysis For The Enterprise
Jason Ross
 
Single sign-on
Marek Stępniowski
 
Chrome Devtools Protocol via Selenium/Appium (English)
Kazuaki Matsuo
 
Exploration note - none windows based authentication for WCF
Shahzad
 
Cross Context Scripting attacks & exploitation
Roberto Suggi Liverani
 
Ruby On Rails Security 9984
Dr Rushi Raval
 
Html5 security
Krishna T
 
Ad

Recently uploaded (20)

PPTX
原版一样(毕业证书)法国蒙彼利埃大学毕业证文凭复刻
Taqyea
 
PDF
Empowering Local Language Email with IDN & EAI – Powered by XgenPlus
XgenPlus Technologies
 
PDF
Strategic Plan New and Completed Templeted
alvi932317
 
PDF
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
PPTX
Introduction-to-the-AWS-Solution-Architect.pptx
Prince391830
 
PPTX
Ransomware attack and its effects on cyber crimes
ShilpaShreeD
 
PPTX
美国电子毕业证帕克大学电子版成绩单UMCP学费发票办理学历认证
Taqyea
 
PDF
Learning Exemplar_Technology and Livelihood Education 7 Q1_W2.pdf
mjhiludo16
 
PPTX
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
PDF
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
PPTX
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
PDF
AI security AI security AI security AI security
elite44
 
PDF
The Hidden Benefits of Outsourcing IT Hardware Procurement for Small Businesses
Carley Cramer
 
PDF
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
PDF
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
PPTX
Meloniusk_Communication_Template_best.pptx
howesix147
 
PPTX
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
PDF
google promotion services in Delhi, India
Digital Web Future
 
PDF
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
PPTX
Metaphysics_Presentation_With_Visuals.pptx
erikjohnsales1
 
原版一样(毕业证书)法国蒙彼利埃大学毕业证文凭复刻
Taqyea
 
Empowering Local Language Email with IDN & EAI – Powered by XgenPlus
XgenPlus Technologies
 
Strategic Plan New and Completed Templeted
alvi932317
 
Beginning-Laravel-Build-Websites-with-Laravel-5.8-by-Sanjib-Sinha-z-lib.org.pdf
TagumLibuganonRiverB
 
Introduction-to-the-AWS-Solution-Architect.pptx
Prince391830
 
Ransomware attack and its effects on cyber crimes
ShilpaShreeD
 
美国电子毕业证帕克大学电子版成绩单UMCP学费发票办理学历认证
Taqyea
 
Learning Exemplar_Technology and Livelihood Education 7 Q1_W2.pdf
mjhiludo16
 
Lesson 1.1 Career-Opportunities-in-Ict.pptx
lizelgumadlas1
 
The Convergence of Threat Behaviors Across Intrusions
Joe Slowik
 
Class_4_Limbgvchgchgchgchgchgcjhgchgcnked_Lists.pptx
test123n
 
AI security AI security AI security AI security
elite44
 
The Hidden Benefits of Outsourcing IT Hardware Procurement for Small Businesses
Carley Cramer
 
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
Meloniusk_Communication_Template_best.pptx
howesix147
 
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
google promotion services in Delhi, India
Digital Web Future
 
web application development company in bangalore.pdf
https://dkpractice.co.in/seo.html tech
 
Metaphysics_Presentation_With_Visuals.pptx
erikjohnsales1
 
Ad

What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.