1. OWASP/WebGoat ๐Ÿ‘ฉโ€๐Ÿ’ป

Open Web Application Security Project ๋Š” ์›น ๋ณด์•ˆ ์ทจ์•ฝ์ ์„ ์ฃผ๋กœ ๋‹ค๋ฃจ๋Š” ๋น„์˜๋ฆฌ ์˜คํ”ˆ ์ปค๋ฎค๋‹ˆํ‹ฐ๋กœ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์•ฑ๊ณผ API ๋ฅผ ๊ฐœ๋ฐœํ•˜๋„๋ก ๋•๋Š”๋‹ค. ๊พธ์ค€ํžˆ ์ด๊ณณ์—์„œ ๊ณต๊ฐœํ•˜๋Š” ์›น ๋ณด์•ˆ ์ทจ์•ฝ์  TOP10 ๋งŒ ์ œ๋Œ€๋กœ ์ฒ˜๋ฆฌํ•ด๋„ ์ƒ๋‹นํ•œ ํšจ๊ณผ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์„ ๊ฒƒ์ด๋ผ ์ƒ๊ฐํ•œ๋‹ค. ์ฐธ๊ณ ๋กœ OWASP GitHub ๋Š” ์ด๊ณณ์—์„œ ์šด์˜ํ•˜๋Š” ๊นƒํ—ˆ๋ธŒ์ด๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์›น ์ทจ์•ฝ์ ์— ๋Œ€ํ•œ ๊ธฐ๋ณธ ํ•™์Šต ๋ฐ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด OWASP WebGoat ๋ฅผ ์ด์šฉํ•˜๋ฉด ํŽธ๋ฆฌํ•˜๋‹ค. OWASP ์—์„œ๋„ ์†Œ๊ฐœํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ WebGoat ๋Š” ํ…Œ์ŠคํŠธ ํ•  ์ˆ˜ ์žˆ๋Š” ์›น ์„œ๋ฒ„๋กœ Docker ๋˜๋Š” jar๋กœ ๋ฐฐํฌ๋œ๋‹ค.


2. SQL Injection ๐Ÿ‘ฉโ€๐Ÿ’ป

  • ๊ณต๊ฒฉ ๋Œ€์ƒ : Database
  • ๋งค๊ฐœ์ฒด : ์—†์Œ
  • ๋ฐฉ์‹ : SQL ์— ์˜ˆ์ƒ๋˜๋Š” ๊ฐ’์ด ์•„๋‹Œ ๊ณต๊ฒฉ ๋ชฉ์ ์˜ ๊ฐ’์„ ๋ณด๋‚ด ๋ฐ์ดํ„ฐ๋ฅผ ํƒˆ์ทจ/์‚ญ์ œ/๋ณ€์กฐํ•œ๋‹ค. SQL ๋ฌธ์žฅ์ด ์ปดํŒŒ์ผ ๋˜๊ธฐ ์ „ String ์ƒํƒœ์ผ ๋•Œ ์ž…๋ ฅ๋˜๋Š” ๋ฐ์ดํ„ฐ์— ์ทจ์•ฝํ•œ ์ ์„ ์ด์šฉํ•œ ๊ณต๊ฒฉ์ด๋‹ค.

1. String SQL Injection

SELECT * FROM user_data WHERE first_name = 'John' AND last_name = '" + lastName + "';

์œ„ ์ฟผ๋ฆฌ์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ณต๊ฒฉ์„ ํ•˜๋ฉด ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ํƒˆ์ทจํ•  ์ˆ˜ ์žˆ๋‹ค.

String SQL Injection 1

SELECT * FROM user_data WHERE first_name = 'John' and last_name = '' or '1' = '1'

String SQL Injection 2


๋น„์Šทํ•˜๊ฒŒ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ณต๊ฒฉ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

String SQL Injection 3

String SQL Injection 4

2. Numeric SQL Injection

Numeric SQL Injection

3. How to prevent?

์š”์ฆ˜์€ ๋Œ€๊ฒŒ ์œ„์— ์†Œ๊ฐœ๋œ ๋ฐฉ์‹์œผ๋กœ๋Š” SQL Injection ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. SQL ์‹คํ–‰์„ ์œ„ํ•ด ORM ๊ฐ™์€ ๊ฒƒ์„ ์ด์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋Œ€๋ถ€๋ถ„์˜ ์‰ฌ์šด ๊ณต๊ฒฉ์€ ์‹คํ–‰ ์ด์ „์— ์ฐจ๋‹จ๋œ๋‹ค. ํ•˜์ง€๋งŒ ์–ด๋–ค ์‹์œผ๋กœ ๊ณต๊ฒฉ์ด ์ด๋ฃจ์–ด์ง€๋Š”์ง€ ์•Œ์•„์•ผ ๋Œ€์‘์„ ํ•  ์ˆ˜ ์žˆ์œผ๋‹ˆ ๋ฐ˜๋“œ์‹œ ๊ธฐ๋ณธ๋ถ€ํ„ฐ ์•Œ์•„์•ผํ•œ๋‹ค. ๋ฌผ๋ก  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‹ ์šฉํ•˜๋Š” ๊ฒƒ ๋งŒ์œผ๋กœ ์ถฉ๋ถ„ํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ, ๋†’์€ ๋ณด์•ˆ์ด ์š”๊ตฌ๋˜๋Š” ๊ฒฝ์šฐ ์ถ”๊ฐ€์ ์ธ ์žฅ์น˜๊ฐ€ ํ•„์š”ํ•  ๊ฒƒ์ด๋‹ค.


3. CSRF(XSRF, Cross-site request forgery) ๐Ÿ‘ฉโ€๐Ÿ’ป

  • ๊ณต๊ฒฉ ๋Œ€์ƒ : WAS, Database
  • ๋งค๊ฐœ์ฒด : Browser
  • ๋ฐฉ์‹ : ์„œ๋ฒ„๊ฐ€ ์ด๋ฏธ ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž ๋ธŒ๋ผ์šฐ์ €์˜ ์š”์ฒญ์„ ์‹ ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ด์šฉํ•œ ๊ณต๊ฒฉ์ด๋‹ค.

Cross-site Request Forgery ๋กœ ์‚ฌ์šฉ์ž์˜ ์˜์ง€์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ์„œ๋ฒ„๊ฐ€ ์ด๋ฏธ ์ธ์ฆ๋œ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์‹ ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ด์šฉํ•ด ๊ณต๊ฒฉํ•œ๋‹ค. ์ฃผ๋ฌธํ•˜์ง€ ์•Š์€ ๋ฌผ๊ฑด์„ ๊ตฌ๋งคํ•˜๋„๋ก ํ•  ์ˆ˜๋„ ์žˆ๊ณ , ๊ณ„์ •์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜ ๊ธฐ๋ก์„ ์‚ญ์ œํ•˜๊ฑฐ๋‚˜ ์‚ฌ์šฉ์ž๊ฐ€ ํ•˜์ง€ ์•Š์€ ์†ก๊ธˆ์„ ํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

How to prevent?

1 ) Referer ๊ฒ€์ฆ

HTTP Request Header ์— ํฌํ•จ๋œ Referer (์š”์ฒญ์ž์˜ ์ ˆ๋Œ€ ์ฃผ์†Œ ๋˜๋Š” ์ผ๋ถ€ ์ฃผ์†Œ๋กœ document.referrer๋ฅผ ํ†ตํ•ด ์‰ฝ๊ฒŒ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค) ์ •๋ณด๋ฅผ ๊ฒ€์ฆํ•œ๋‹ค

ํ•˜์ง€๋งŒ ์ด๊ฒƒ์€ ์‰ฝ๊ฒŒ ์กฐ์ž‘์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํฌ๊ฒŒ ๋„์›€ ๋˜๋Š” ๋ฐฉ์‹์€ ์•„๋‹ˆ๋‹ค.


2 ) CSRF Token

์†ก๊ธˆ์ด๋‚˜ ์ •๋ณด ๋ณ€๊ฒฝ๊ณผ ๊ฐ™์€ ๋ฏผ๊ฐํ•œ ์ •๋ณด๋ฅผ ๋‹ค๋ฃฐ ๋•Œ ์—„์ฒญ๋‚œ ํฌ๊ธฐ์˜ ๋‚œ์ˆ˜ ํ† ํฐ์„ ๋ฐœํ–‰ํ•ด ํ™”๋ฉด์„ ์‘๋‹ตํ•  ๋•Œ form ์— hidden ์œผ๋กœ ๋„ฃ์–ด๋‘๊ฑฐ๋‚˜ POST ์š”์ฒญ ์‹œ ํ•จ๊ป˜ ์‘๋‹ตํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ทฐ ํŽ˜์ด์ง€๋ฅผ ๋ณด๋‚ด์ค€๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด Cookie ๋‚˜ Local Stroage ๋“ฑ์— ์ €์žฅํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ XSS ์— ์˜ํ•œ ํƒˆ์ทจ๊ฐ€ ์–ด๋ ค์›Œ์ง„๋‹ค. ํด๋ผ์ด์–ธํŠธ๋Š” ๋งค ์š”์ฒญ๋งˆ๋‹ค ์ด๋ฅผ ํ•จ๊ป˜ ๋ณด๋‚ด์•ผํ•˜๊ณ , ์„œ๋ฒ„๋Š” ์ด๋ฅผ ๊ฒ€์ฆํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋Ÿฌํ•œ ํ† ํฐ์€ ๊ฐ ๋ทฐ ํŽ˜์ด์ง€๋งˆ๋‹ค ๋ฐœํ–‰๋œ ํ›„ ํ•„์š”๊ฐ€ ์—†์–ด์ง€๋ฉด ์ฆ‰์‹œ ์‚ญ์ œ๋œ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ JWT ํ† ํฐ ๋˜๋Š” OAuth 2.0 ์ธ์ฆ ํ† ํฐ ๋“ฑ์„ Local Storage ์— ์ €์žฅํ•˜๋Š”๋ฐ ์ด๋Š” XSS ์— ์˜ํ•ด ํƒˆ์ทจ๋˜๊ธฐ ์‰ฝ๊ธฐ ๋•Œ๋ฌธ์— CSRF Token ์œผ๋กœ ์ถ”๊ฐ€์ ์ธ ๋ณด์•ˆ ์กฐ์น˜๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ๋”ฐ๋ผ์„œ ์ด ํ† ํฐ์€ ์˜ˆ์ธกํ•  ์ˆ˜ ์—†์–ด์•ผํ•œ๋‹ค.

CSRF Token ๊ด€๋ จํ•ด์„œ๋Š” PortSwigger - CSRF ์™€ PortSwigger - CSRF Token Validation ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค.


4. DDoS(Distributed Denial of Service) ๐Ÿ‘ฉโ€๐Ÿ’ป

  • ๊ณต๊ฒฉ ๋Œ€์ƒ : WAS
  • ๋งค๊ฐœ์ฒด : Client PC
  • ๋ฐฉ์‹ : ๋งŽ์€ ์ปดํ“จํ„ฐ๋ฅผ ๊ฐ์—ผ์‹œ์ผœ ์งง์€ ping ์œผ๋กœ ๋™์‹œ ๋‹ค๋ฐœ์ ์œผ๋กœ ์š”์ฒญํ•ด ์„œ๋ฒ„์— ๊ณผ๋ถ€ํ•˜๋ฅผ ์ผ์œผ์ผœ ์žฅ์• ๋ฅผ ์œ ๋ฐœํ•˜๋Š” ๊ณต๊ฒฉ์ด๋‹ค.

DDos ๊ณต๊ฒฉ์€ ๋„คํŠธ์›Œํฌ(๊ณ„์ธต 3), ์ „์†ก(๊ณ„์ธต 4), ํ‘œํ˜„(๊ณ„์ธต 6) ๋ฐ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜(๊ณ„์ธต 7) ๊ณ„์ธต์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ๋‚˜ํƒ€๋‚˜๋ฉฐ ์„œ๋น„์Šค์˜ ์žฅ์• ๋ฅผ ์ผ์œผํ‚ค๋Š” ๊ฒƒ์ด ๋ชฉ์ ์ด๋‹ค.

How to prevent?

์‚ฌ์‹ค์ƒ DDoS ๊ณต๊ฒฉ์€ ๊ณต๊ฒฉ ๋‹นํ•˜๋Š” ์„œ๋ฒ„๋ฅผ ๊ฐ์—ผ์‹œํ‚ค๋Š” ๊ฒƒ์ด ์•„๋‹Œ ๋‹ค์ˆ˜์˜ ํด๋ผ์ด์–ธํŠธ๋ฅผ ๊ฐ์—ผ์‹œํ‚ค๋Š” ๊ฒƒ์ด๋ผ ์„œ๋ฒ„ ์ธก์—์„œ ์˜ˆ๋ฐฉ์„ ํ•  ์ˆ˜๋Š” ์—†๊ณ  ๋ฐฉ์–ด๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.

1 ) DDoS ํŒจํ„ด ํƒ์ง€

์ •์ƒ ํŠธ๋ž˜ํ”ฝ๊ณผ ๋น„์ •์ƒ ํŠธ๋ž˜ํ”ฝ์„ ๋ถ„์„ํ•˜๊ณ  ๋น ๋ฅด๊ฒŒ ํƒ์ง€ํ•ด ์ •์ƒ์ ์ธ ํŠธ๋ž˜ํ”ฝ๋งŒ ์ˆ˜์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด ์ˆ˜์šฉ ๊ฐ€๋Šฅํ•œ ํŠธ๋ž˜ํ”ฝ์„ ์ œํ•œํ•œ๋‹ค.


2 ) CDN ๋“ฑ์„ ์ด์šฉํ•œ ๋ถ„์‚ฐ

Content Delivery Network ์˜ ๋ณธ๋ž˜ ๋ชฉ์ ์€ ์„ธ๊ณ„ ์—ฌ๋Ÿฌ ๊ณณ์— ๋ถ„์‚ฐ์‹œํ‚ด์œผ๋กœ์จ ํŽ˜์ด์ง€ ๋กœ๋“œ ์‹œ๊ฐ„์„ ๋‹จ์ถ•์‹œํ‚ค๊ณ , ๋Œ€์—ญํญ ๋น„์šฉ์„ ์ ˆ๊ฐํ•˜๋ฉฐ, ๊ฐ€์šฉ์„ฑ์„ ๋†’์ด๋Š” ๊ฒƒ์ด๋‹ค. ์ฆ‰, CDN ์„ ๊ตฌ์ถ•ํ•œ๋‹ค๋Š” ๊ฒƒ์€ ๊ณต๊ฒฉ์˜ ๋Œ€์ƒ์„ ํ•œ ๊ณณ์— ์ง‘์ค‘ํ•  ์ˆ˜ ์—†๋„๋ก ํ•ด DDoS ๊ณต๊ฒฉ์— ์˜ํ•ด ์ „์ฒด ์„œ๋น„์Šค๊ฐ€ ์ •์ง€๋˜๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•œ๋‹ค.


5. XSS(Cross-site scripting) ๐Ÿ‘ฉโ€๐Ÿ’ป

  • ๊ณต๊ฒฉ ๋Œ€์ƒ : Client
  • ๋งค๊ฐœ์ฒด : Browser
  • ๋ฐฉ์‹ : ์‚ฌ์šฉ์ž๊ฐ€ ํŠน์ • ์›น ์‚ฌ์ดํŠธ๋ฅผ ์‹ ์šฉํ•˜๋Š” ๊ฒƒ์„ ์ด์šฉํ•œ ๊ณต๊ฒฉ์œผ๋กœ ๋ธŒ๋ผ์šฐ์ €์— ์‚ฌ์šฉ์ž์˜ ์˜๋„์™€ ๋‹ค๋ฅธ ํ–‰์œ„๋ฅผ ์‹คํ–‰์‹œํ‚ค๋Š” ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” ๋ชจ๋“  ๊ณต๊ฒฉ์„ ์˜๋ฏธํ•œ๋‹ค.

Cross-site scripting ์˜ ์ถ•์•ฝํ˜•์ด XSS ์ธ ์ด์œ ๋Š” CSS๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ Cascading Style Sheets ๋ฅผ ์˜๋ฏธํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

1. Difference between XSS and CSRF

XSS ์™€ CSRF ๋Š” ๋ชจ๋‘ ์‚ฌ์šฉ์ž์˜ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ๋งค๊ฐœ์ฒด๋กœ ํ•œ๋‹ค๋Š” ์ ์€ ๋™์ผํ•˜๋‹ค. ํ•˜์ง€๋งŒ CSRF ๋Š” ์‚ฌ์šฉ์ž์˜ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ด์šฉํ•ด ์‹ ๋ขฐํ•˜๋Š” ์„œ๋ฒ„๋ฅผ ๋Œ€์ƒ์œผ๋กœ ๊ณต๊ฒฉํ•˜๋ฏ€๋กœ ์‚ฌ์šฉ์ž์˜ ์ธ์ฆ๋œ ์„ธ์…˜์„ ์•…์šฉํ•œ๋‹ค. ๋ฐ˜๋ฉด XSS ๋Š” ๋ธŒ๋ผ์šฐ์ € ์ž์ฒด์— ๋Œ€ํ•ด ๊ณต๊ฒฉํ•œ๋‹ค. ์ฆ‰, ์‚ฌ์šฉ์ž๊ฐ€ ์˜๋„ํ•˜์ง€ ์•Š์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ชจ๋“  ๊ณต๊ฒฉ์„ ์˜๋ฏธํ•œ๋‹ค.

  • CSRF ๊ณต๊ฒฉ : ๋ฌผํ’ˆ ๊ตฌ๋งค๋‚˜ ์†ก๊ธˆ๊ณผ ๊ฐ™์€ ์š”์ฒญ์„ ์„œ๋ฒ„๋กœ ๋ณด๋‚ธ๋‹ค. ๋˜๋Š” ๊ณต๊ฒฉ์ž๊ฐ€ ์ง์ ‘ CSRF ๋ฅผ ์ด์šฉํ•ด ์ •๋ณด๋ฅผ ๋นผ์™€ ํƒˆ์ทจํ•œ๋‹ค.
  • CSRF & XSS ๊ณต๊ฒฉ : XSS ๋ฅผ ์ด์šฉํ•ด ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ์ธ์ฆ๋œ ํ† ํฐ์„ ๋ฐ›๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ ธ๋‹ค ์†ก๊ธˆ์„ ๋ช…๋ นํ•˜๋Š” ๋“ฑ์˜ CSRF ๊ณต๊ฒฉ์„ ํ•˜๊ฑฐ๋‚˜ ์„œ๋ฒ„์˜ ์‹ ๋ขฐ๋ฅผ ํš๋“ํ•˜๊ธธ ๊ธฐ๋‹ค๋ ธ๋‹ค CSRF ์ƒํƒœ๊ฐ€ ๋˜๋ฉด ์ •๋ณด๋ฅผ ํƒˆ์ทจํ•ด XSS ๋ฅผ ์ด์šฉํ•ด ๊ณต๊ฒฉ์ž์—๊ฒŒ ์ „์†กํ•˜๋Š” ๋“ฑ ๋ณตํ•จ์ ์ธ ๊ณต๊ฒฉ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • XSS ๊ณต๊ฒฉ : ๋ธŒ๋ผ์šฐ์ €์— ์ €์žฅ๋œ ๊ณ„์ • ์ •๋ณด๋‚˜ ์„ธ์…˜ ์ •๋ณด ๋“ฑ์„ ๊ณต๊ฒฉ์ž์—๊ฒŒ ์ „์†กํ•ด ํƒˆ์ทจํ•œ๋‹ค. ์ฃผ๋กœ CSRF ๊ณต๊ฒฉ์„ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ์•„ ํ˜ผ๋™ํ•˜๊ธฐ ์‰ฝ์ง€๋งŒ CSRF ๊ณต๊ฒฉ์€ ์„œ๋ฒ„์— ํŠน์ • ๊ณต๊ฒฉ ํ–‰์œ„๋ฅผ ํ•˜๋Š” ๊ฒƒ์ด๊ณ , XSS ๊ณต๊ฒฉ์€ ์ˆœ์ˆ˜ํ•˜๊ฒŒ ์˜๋„์น˜ ์•Š์€ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰์‹œํ‚ค๋Š” ๊ณต๊ฒฉ ํ–‰์œ„ ์ž์ฒด๋ฅผ ์˜๋ฏธํ•œ๋‹ค.

2. XSS Attack Types

XSS ๊ณต๊ฒฉ ์œ ํ˜•์€ ํฌ๊ฒŒ 3๊ฐ€์ง€๋กœ ๋‚˜๋‰œ๋‹ค.

1 ) Reflected XSS

HTTP Request/Response ๋ฅผ ์ด์šฉํ•œ ๊ณต๊ฒฉ์œผ๋กœ Request ๋ฅผ ๋ณด๋‚ธ ํ›„ ๋Œ์•„์˜จ Response ๊ฐ€ ํ•„ํ„ฐ๋ง ๊ฐ™์€ ๊ฒ€์ฆ ์—†์ด ์•ˆ์ „ํ•˜์ง€ ๋ชปํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ”๋กœ ํฌํ•จํ•˜๋Š” ๊ฒฝ์šฐ ์ด์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ๋‹ค์Œ ์š”์ฒญ์„ ๋ณด๋ƒˆ์„ ๋•Œ

https://insecure-website.com/status?message=All+is+well.

์‘๋‹ต ๊ฒฐ๊ณผ๋ฅผ ๋ณ„๋„์˜ ํ•„ํ„ฐ ์—†์ด ๋ฐ”๋กœ ๋ฐ˜์˜ํ•œ๋‹ค๊ณ  ํ•ด๋ณด์ž.

<template>
  <p>Status: {{ data }} </p>
</template>

๊ฐœ๋ฐœ์ž๋Š” ๋‹จ์ˆœํ•˜๊ฒŒ ์ด๋Ÿฌํ•œ ๊ฒฐ๊ณผ๋ฅผ ์˜๋„ํ–ˆ์„ ๊ฒƒ์ด๋‹ค.

<p>Status: All is well.</p>

ํ•˜์ง€๋งŒ ๊ณต๊ฒฉ์ž๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค.

https://insecure-website.com/status?message=<script>/*+Bad+stuff+here...+*/</script>

๊ทธ ๊ฒฐ๊ณผ XSS ๊ณต๊ฒฉ์— ์„ฑ๊ณตํ•œ๋‹ค.

<p>Status: <script>/* Bad stuff here... */</script></p>


2 ) Stored XSS(Persistent XSS)

Persistent XSS ๋˜๋Š” Second-order XSS ๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋ฉฐ, ์„œ๋ฒ„๊ฐ€ ์‹ ๋ขฐํ•  ์ˆ˜ ์—†๋Š” ์†Œ์Šค์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์‹ ํ•˜๊ณ , ์ดํ›„ HTTP ์š”์ฒญ์— ์ด ๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•ด ์‘๋‹ตํ•  ๊ฒฝ์šฐ ์ด์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

๊ฒŒ์‹œํŒ ๋˜๋Š” ๋ฉ”์‹œ์ง€ ์•ฑ์˜ ๊ฒฝ์šฐ ํ•˜๋‚˜์˜ ์š”์ฒญ์ด ์„œ๋ฒ„์— ์ €์žฅ๋˜์–ด ์ดํ›„ ์ ‘๊ทผํ•˜๋Š” ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ ๋ฐฐํฌ๊ฐ€๋œ๋‹ค. ๋”ฐ๋ผ์„œ ๊ณต๊ฒฉ์ž๋Š” ๋ฉ”์‹œ์ง€์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด XSS ๊ณต๊ฒฉ์„ ๋ณด๋‚ธ๋‹ค.

<script>/* Bad stuff here... */</script>

์ด๋ฅผ ์„œ๋ฒ„๊ฐ€ ๋ณ„๋„์˜ ํ•„ํ„ฐ๋ง ์—†์ด ์ €์žฅ ํ›„, ๋‹ค์‹œ ๋‹ค์Œ ์‚ฌ์šฉ์ž๊ฐ€ ๋ณ„๋„์˜ ํ•„ํ„ฐ๋ง ์—†์ด ๊ฒฐ๊ณผ๋ฅผ ํฌํ•จํ•œ๋‹ค.

<p><script>/* Bad stuff here... */</script></p>

๊ณต๊ฒฉ์ž๋Š” ์„œ๋ฒ„์— XSS ๊ณต๊ฒฉ์„ ์ €์žฅํ•œ ํ›„ ๊ธฐ๋‹ค๋ฆฐ๋‹ค. ์ดํ›„ ์ œ3์ž๊ฐ€ ์ ‘๊ทผํ•˜๋ฉด XSS ๊ณต๊ฒฉ์— ์„ฑ๊ณตํ•œ๋‹ค.


3 ) DOM Based XSS

์ค„์—ฌ์„œ DOM XSS ๋ผ๊ณ  ๋ถ€๋ฅด๋ฉฐ JavaScript ๋กœ DOM ์„ ์—…๋ฐ์ดํŠธ ํ•˜๊ธฐ ์œ„ํ•ด ์ œ์–ดํ•  ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค. DOM XSS ์ทจ์•ฝ์ ์€ ๋‘ ๊ฐ€์ง€ ์š”์†Œ๋กœ ๋‚˜๋‰˜์–ด ์ž‘๋™ํ•œ๋‹ค. ๊ณต๊ฒฉํ•  ๋ฐ์ดํ„ฐ๊ฐ€ ์ž…๋ ฅ๋˜๋Š” Source์™€ ์ด ๊ณต๊ฒฉ์ด ์ด๋ฃจ์–ด์ง€๋Š” ๋Œ€์ƒ Sink๋‹ค.

  • Source : document.URL, document.documentURI, location.href, location.search, location.*, window.name, and document.referrer etc.
  • Sink : document.write, (element).innerHTML, eval, setTimeout, setInterval, and execScript etc.


๋‹ค์Œ๊ณผ ๊ฐ™์€ dashboard.html์ด ์žˆ๋‹ค๊ณ  ํ•˜์ž.

<html>
(...)
Dashboard for
<script>
   var pos=document.URL.indexOf("context=")+8;
   document.write(decodeURIComponent(document.URL.substring(pos)));
</script>
(...)
</html>

๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŽ˜์ด์ง€๋ฅผ ์š”์ฒญํ•˜๋ฉด

http://www.example.com/dashboard.html?context=Thomas

ํŽ˜์ด์ง€๊ฐ€ ๋กœ๋“œ๋œ ํ›„ ์‚ฌ์šฉ์ž์˜ ์ด๋ฆ„์ด ๋™์ ์œผ๋กœ ๋ Œ๋”๋ง ๋  ๊ฒƒ์ด๋‹ค.

Dashboard for Thomas

ํ•˜์ง€๋งŒ ๊ณต๊ฒฉ์ž๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŽ˜์ด์ง€๋ฅผ ์š”์ฒญํ•˜๋„๋ก ๋งํฌ๋ฅผ ๋ณด๋‚ธ๋‹ค.

http://www.example.com/dashboard.html?context=%3c%73%63%72%69%70%74%3e%61%6c%65%72%74%28%22%4c%45
%41%56%45%20%54%48%49%53%20%50%41%47%45%21%20%59%4f%55%20%41%52%45%20%42%45%49%4e%47%20%48%41%43%4b%45
%44%21%22%29%3b%3c%2f%73%63%72%69%70%74%3e

์ด๋Š” ๋””์ฝ”๋”ฉ ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

<script>alert("LEAVE THIS PAGE! YOU ARE BEING HACKED!");</script>

๋”ฐ๋ผ์„œ DOM ์— ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฝ์ž…๋  ๊ฒƒ์ด๋‹ค.

Dashboard for <script>alert("LEAVE THIS PAGE! YOU ARE BEING HACKED!");</script>

๊ณต๊ฒฉ์ž๊ฐ€ ๋งŒ๋“  ์ด ๋งํฌ๋ฅผ ๋ฐ›์€ ์‚ฌ์šฉ์ž๋Š” ์œ„ํ—˜์„ ๋Š๋ผ๊ณ  ํŽ˜์ด์ง€๋ฅผ ๋– ๋‚˜๊ณ  ์ด๊ฒƒ์€ ํ•ด๋‹น ์‚ฌ์ดํŠธ์˜ ํ‰ํŒ์— ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค.


DOM Based XSS ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ€์žฅ ์ฒซ ๋ฒˆ์งธ๋Š” eval๊ณผ execScript๋ฅผ ํ—ˆ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒƒ์ด๋‹ค.
๊ทธ๋ฆฌ๊ณ  innerHtml๊ณผ ๊ฐ™์ด ์•ˆ์ „ํ•˜์ง€ ์•Š์€ ๋ฐฉ๋ฒ•์œผ๋กœ HTML ์— ์‚ฝ์ž…ํ•˜์ง€ ์•Š๊ณ  innerText ๋˜๋Š” textContent ๊ณผ ๊ฐ™์ด ์•ˆ์ „ํ•œ Sink๋ฅผ ์‚ฌ์šฉํ•ด ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š๋„๋ก ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

๋”ฐ๋ผ์„œ ์œ„ ์˜ˆ์ œ๋ฅผ div element ์™€ textContent๋ฅผ ์‚ฌ์šฉํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ณ ์น  ์ˆ˜ ์žˆ๋‹ค.

<html>
(...)
Dashboard for <span id="contentholder"></span>
<script>
   var pos=document.URL.indexOf("context=")+8;
   document.getElementById("contentholder").textContent = 
       document.URL.substring(pos,document.URL.length);
</script>
(...)
</html>

XSS ๋Š” ์›น ๊ฐœ๋ฐœ์˜ ์ทจ์•ฝ์  ์ค‘ ๊ฐ€์žฅ ์น˜๋ช…์ ์ด๋ฉด์„œ๋„ ๊ฐ€์žฅ ๋‹ค์–‘ํ•œ ์œ ํ˜•์ด ์กด์žฌํ•˜๋Š” ๊ฒƒ ๊ฐ™๋‹ค. ๋”ฐ๋ผ์„œ OWASP - Cheatsheets - XSS ๋ฅผ ์ฐธ๊ณ ํ•ด ๊พธ์ค€ํ•˜๊ฒŒ ์‹ ๊ฒฝ ์จ์•ผ๋งŒ ํ•  ๊ฒƒ์ด๋‹ค.

3. Reflected vs. Stored vs. DOM

Reflected XSS ์™€ Stored XSS ๋Š” ๊ณต๊ฒฉ ์‹œ์ ๊ณผ ์„œ๋ฒ„ ์ €์žฅ ์œ ๋ฌด๊ฐ€ ๋‹ฌ๋ผ ๋ช…ํ™•ํžˆ ๊ตฌ๋ถ„๋˜์ง€๋งŒ, DOM XSS ๋Š” XSS ๊ณผ CSRF ์™€ ํ•จ๊ป˜ ๋ณตํ•ฉ์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ Reflected ๋˜๋Š” Stored XSS ์™€ ๋ณตํ•ฉ์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๊ธฐ๋„ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ˜ผ๋™๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค. ๋‹ค๋งŒ DOM XSS ์ž์ฒด๋Š” ์œ„์— ์„ค๋ช…ํ•œ ๊ฒƒ์ฒ˜๋Ÿผ ๋ธŒ๋ผ์šฐ์ € ์ž์ฒด ๋‚ด์—์„œ ๋ฐœ์ƒํ•˜๋Š” Source์™€ Sink๋ฅผ ๋‹ค๋ฃฐ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์ทจ์•ฝ์ ์„ ๋งํ•œ๋‹ค.

ย  Reflected XSS Stored XSS DOM XSS
Require HTTP O โ–ณ (์„œ๋ฒ„์— ์ง์ ‘ ์‹ฌ์„ ์ˆ˜๋„ ์žˆ๋‹ค) X (์ทจ์•ฝ์ ์„ ์‹ฌ๊ธฐ ์œ„ํ•ด Reflected ๋˜๋Š” Stored ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•˜์ง€๋งŒ DOM XSS ๊ณต๊ฒฉ ์ž์ฒด๋Š” ์„œ๋ฒ„์™€ ํ†ต์‹ ์ด ํ•„์š” ์—†๋‹ค)
Save to Server X O X
Server XSS O O X (DOM XSS ๋Š” ์„œ๋ฒ„์—์„œ ๊ฐ์ง€ํ•˜๊ฑฐ๋‚˜ ๋ง‰๋Š” ๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค)
Client XSS O O O

4. XSS Attack Examples

๋‚˜๋ฌด์œ„ํ‚ค์— ์†Œ๊ฐœ๋œ XSS ์˜ˆ์ œ๋ฅผ ์กฐ๊ธˆ ๋” ์†Œ๊ฐœํ•ด๋ณธ๋‹ค.

1 ) Inject script Tag

<script>alert('XSS');</script>

๋งค์šฐ ๊ณ ์ „์ ์ธ ๋ฐฉ๋ฒ•์œผ๋กœ ์˜ค๋Š˜๋‚ ์€ ๋Œ€๋ถ€๋ถ„ ๋ง‰ํ˜€์žˆ๋‹ค.

  • Inject javascript: Link
<a href="javascript:alert('XSS')">XSS</a>

๋งํฌ์— JavaScript ๋ฅผ ์‹คํ–‰ํ•˜๋„๋ก ๋งํฌ๋ฅผ ์‚ฝ์ž…ํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์œ„ script ์ฃผ์ž…๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋Œ€๋ถ€๋ถ„ ๋ง‰ํ˜€์žˆ๋‹ค.

2 ) Inject Event Attributes

<img src="#" alt="" onerror="alert('XSS')">

HTML ์—์„œ onclick, onload, onerror๊ณผ attributes ๋Š” ์ด๋ฒคํŠธ ์†์„ฑ์œผ๋กœ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ํƒœ๊ทธ์ธ ์ ์„ ์ด์šฉํ•œ๋‹ค.

3 ) Inject Black List Event Attributes

<ruby oncopy="alert('XSS')">XSS</ruby>

์ด๋ฒคํŠธ ์†์„ฑ์„ ๊ฐ–์ง€๋งŒ ์ผ๋ฐ˜์ ์œผ๋กœ ์ž˜ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ์ด๋ฒคํŠธ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ์ด๋ฒคํŠธ ์†์„ฑ์„ ๋ธ”๋ž™๋ฆฌ์ŠคํŠธ๋กœ ๋ง‰์œผ๋ฉด ์ด๋Ÿฐ ์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์ด๋ฒคํŠธ ์†์„ฑ์— ๋šซ๋ฆฌ๊ฒŒ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ ํ™”์ดํŠธ๋ฆฌ์ŠคํŠธ๋กœ ๋ง‰์•„์•ผ ์ด๋Ÿฐ ์ž˜ ์•Œ๋ ค์ง€์ง€ ์•Š์€ ์†์„ฑ์œผ๋กœ ์šฐํšŒํ•œ ๊ณต๊ฒฉ์„ ๋ง‰์„ ์ˆ˜ ์žˆ๋‹ค.

4 ) ๋‚œ๋…ํ™”

๋ธŒ๋ผ์šฐ์ €๋Š” ์ฝ์„ ์ˆ˜ ์žˆ์ง€๋งŒ ์‚ฌ๋žŒ์ด ์‰ฝ๊ฒŒ ์ฝ์„ ์ˆ˜ ์—†๋„๋ก ๋‚œ๋…ํ™” ํ•œ๋‹ค. ์œ„ <a href="javascript:alert('XSS')">XSS</a>๋ฅผ ์•„์Šคํ‚ค ์ฝ”๋“œ๋กœ ๋‚œ๋…ํ™”๋ฅผ ํ•ด๋ณด์ž.

Web HTML entity encoder/decoder ์— javascript:alert('XSS') ๋ถ€๋ถ„์„ ๋„ฃ์–ด๋ณด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ์–ป๋Š”๋‹ค.

XSS Code ASCII Encode

<a href="&#x6A;&#x61;&#x76;&#x61;&#x73;&#xA;&#x63;&#x72;&#x69;&#x70;&#x74;&#xA;&#x3A;&#xA;&#x61;&#x6C;&#x65;&#x72;&#x74;&#xA;&#x28;&#x27;&#x58;&#x53;&#x53;&#x27;&#x29;">XSS</a>

๋ฌด์Šจ ์ฝ”๋“œ์ธ์ง€ ์‚ฌ๋žŒ์€ ์•Œ ์ˆ˜ ์—†์œผ๋‚˜ ๋ธŒ๋ผ์šฐ์ €๋Š” ์ด๋ฅผ ์•„๋ฌด ๋ฌธ์ œ ์—†์ด

<a href="javascript:alert('XSS')">XSS</a>

์™€ ๋™์ผํ•˜๊ฒŒ ์ฝ๋Š”๋‹ค.


์œ„ ๋‚œ๋…ํ™”์— ํ•œ ์ˆ  ๋” ๋–  ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค๊ณ  ํ•œ๋‹ค.

XSS Code Japanese Style Emoticons aaencode Encode

5. How to prevent?

1 ) OWASP ์˜ Cheatsheets ๋ฅผ ๊พธ์ค€ํžˆ ์ฐธ๊ณ ํ•œ๋‹ค

OWASP - Cheatsheets - XSS ๋ฅผ ์ฐธ๊ณ ํ•ด ์ตœ์‹  XSS ๊ณต๊ฒฉ์— ๊พธ์ค€ํžˆ ๋Œ€๋น„ํ•ด์•ผํ•œ๋‹ค.

2 ) BBCode ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค

Bulletin Board Code ๋Š” ์ „์ž ๊ฒŒ์‹œํŒ์— ๊ธ€์„ ์ž‘์„ฑํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์ง„ ๊ฐ€๋ฒผ์šด ๋งˆํฌ์—… ์–ธ์–ด๋กœ HTML ๊ณผ ๋น„์Šทํ•œ ์—ญํ• ์„ ํ•˜๋ฉฐ ๋ฌธ๋ฒ•๋„ ์œ ์‚ฌํ•˜๋‹ค. ๋‹จ, HTML ์ด๋‚˜ XML ์ด <, >๋กœ ํƒœ๊ทธ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ๊ณผ ๋น„๊ตํ•ด [, ]๋กœ ํƒœ๊ทธ๋ฅผ ํƒ€๋‚˜๋‚ธ๋‹ค.

์ฆ‰, <b> ํƒœ๊ทธ ๋Œ€์‹  [b]ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ํ•ด XSS ๊ณต๊ฒฉ์„ ์ฐจ๋‹จํ•œ๋‹ค.

BBCode Tags

3 ) Filter ๋˜๋Š” Library ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค

์ „์ฒด ์ž…์ถœ๋ ฅ ๋ฐ์ดํ„ฐ๋ฅผ Filter ๋กœ ๊ฒ€์‚ฌํ•˜๊ฑฐ๋‚˜ ํ•„์š”ํ•œ ๊ณณ์— Library ๋ฅผ ์ ์šฉํ•œ๋‹ค.

&lt;, &gt; ์ฒ˜๋Ÿผ ๋‹จ์ˆœ ๋ฌธ์ž๋กœ ์ธ์‹ํ•˜๋„๋ก ํ•„ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ฑฐ๋‚˜, ํด๋ผ์ด์–ธํŠธ์—์„œ ์ด๋ฅผ ์‹คํ–‰ํ•  ๋•Œ XSS๊ฐ€ ๋™์ž‘ํ•˜์ง€ ์•Š๋„๋ก ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ์•ˆ์ „ ์œ ๋ฌด๋ฅผ ๊ฒ€์‚ฌํ•œ๋‹ค.

4 ) CSP ์‚ฌ์šฉ

์ตœ์‹  ๋ธŒ๋ผ์šฐ์ €๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ SOP(Same-Origin Policy)๋ฅผ ์ ์šฉํ•œ๋‹ค. ํ•˜์ง€๋งŒ ๊ฒฝ์šฐ์— ๋”ฐ๋ผ CORS(Cross-Origin Resource Sharing)๋ฅผ ํ•„์š”ํ•˜๊ธฐ๋„ ํ•˜๋ฉฐ, SOP ๋ฅผ ์ ์šฉํ•œ๋‹ค ํ•˜๋”๋ผ๋„ ์ด๋ฅผ ์šฐํšŒํ•˜๋Š” ๊ณต๊ฒฉ๋ฒ•์ด ์กด์žฌํ•˜๋ฏ€๋กœ SOP ๋ผ๊ณ  ์•ˆ์‹ฌํ•˜๋Š” ๊ฒƒ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

๋”ฐ๋ผ์„œ Content Security Policy ๋ฅผ ์‚ฌ์šฉํ•ด ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰์— ๋Œ€ํ•œ ์ถœ์ฒ˜ ์กฐ๊ฑด์„ ํ™”์ดํŠธ๋ฆฌ์ŠคํŠธ๋กœ ์ œํ•œํ•˜๋„๋ก ์ถ”๊ฐ€์ ์ธ ๋ณด์•ˆ ์กฐ์น˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

5 ) Frontend Frameworks/Library ์‚ฌ์šฉ

๋ฌผ๋ก , ํ•„ํ„ฐ๋ฅผ ์ง์ ‘ ์ œ์ž‘ํ•˜๊ฑฐ๋‚˜ ๊ณต๊ฐœ๋œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์ง€๋งŒ ์šฐ์„ ์ ์œผ๋กœ Angular, React, Vue, Svelte์™€ ๊ฐ™์€ ํ”„๋ ˆ์ž„์›Œํฌ ๋˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ์— ๊ฐ€๊นŒ์šด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ๊ฐœ๋ฐœํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋“ค์€ ๋ฐฐํฌํ•œ Documents ์˜ HTML ์„ ๋ถ„์„ํ•˜๊ธฐ ์–ด๋ ต๊ฒŒ ๋งŒ๋“ค๊ณ , ๋งŽ์€ ์ •๋ณด๋ฅผ ์บก์Šํ™” ํ•˜๋ฉฐ, ๊ธฐ์กด์— ์•Œ๋ ค์ง„ ๋งŽ์€ ์ทจ์•ฝ์ ์„ ์ข€ ๋” ๊ฐ•๋ ฅํ•˜๊ณ  ์œ ์—ฐํ•˜๊ฒŒ ์ปจํŠธ๋กค ํ•˜๋Š” ๊ฒƒ์„ ๊ธฐ๋ณธ์ ์œผ๋กœ ํฌํ•จํ•˜๊ณ ์žˆ๋‹ค.

ํ•˜์ง€๋งŒ Vue ๋ฅผ ์˜ˆ๋กœ ๋“ค๋ฉด v-html ๋˜๋Š” findDOMNOde, ref ์™€ ๊ฐ™์€ ๊ฐœ๋ฐœ์„ ํŽธํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” escape hatch๊ฐ€ ์กด์žฌํ•˜๋Š”๋ฐ ์ด๋Ÿฌํ•œ ์ฝ”๋“œ๋Š” Vue ๊ฐ€ ๋‹ค์‹œ XSS ๊ณต๊ฒฉ์— ๋…ธ์ถœ๋˜๊ธฐ ์‰ฝ๊ฒŒ ๋งŒ๋“ ๋‹ค. ๋”ฐ๋ผ์„œ DOM XSS Examples ์—์„œ ์„ค๋ช…ํ•œ ๊ฒƒ์ฒ˜๋Ÿผ HTML ์ฝ”๋“œ๋ฅผ ์ง์ ‘ ์ถœ๋ ฅํ•˜๋Š” ๊ฒƒ์„ ํ”ผํ•ด์•ผํ•˜๋ฉฐ, ์ •๋ง ํ•„์š”ํ•  ๊ฒฝ์šฐ๋Š” vue-sanitize ๋˜๋Š” sanitize-html ๊ณผ ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ํ•œ๋‹ค.




Reference

  1. โ€œOWASP Top Ten.โ€ OWASP. accessed Jan. 20, 2023, OWASP Top Ten.
  2. โ€œ์‚ฌ์ดํŠธ ๊ฐ„ ์Šคํฌ๋ฆฝํŒ….โ€ Wikipedia. Aug. 26, 2022, Wikipedia - ์‚ฌ์ดํŠธ ๊ฐ„ ์Šคํฌ๋ฆฝํŒ….
  3. โ€œXSS.โ€ ๋‚˜๋ฌด์œ„ํ‚ค. Aug. 09, 2022, ๋‚˜๋ฌด์œ„ํ‚ค - XSS.
  4. โ€œWebGoat/WebGoat.โ€ GitHub. Jan. 15, 2023, https://github.com/WebGoat/WebGoat.
  5. โ€œReferer.โ€ MDN Web Docs. Oct. 28, 2022, MDN - Referer.
  6. โ€œCross-site request forgery (CSRF).โ€ PortSwigger. accessed Jan. 20, 2023, PortSwigger - CSRF.
  7. โ€œBypassing CSRF token validation.โ€ PortSwigger. accessed Jan. 20, 2023, PortSwigger - CSRF Token Validation.
  8. โ€œDDoS ๊ณต๊ฒฉ์ด๋ž€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?.โ€ AWS. accessed Jan. 20, 2023, DDoS ๊ณต๊ฒฉ์ด๋ž€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?.
  9. โ€œCDN์ด๋ž€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?.โ€ AWS. accessed Jan. 20, 2023, CDN์ด๋ž€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?.
  10. โ€œHTML entity encoder/decoder.โ€ Web developer tools. accessed Jan. 22, 2023, Web HTML entity encoder/decoder.
  11. Tomasz Andrzej Nidecki. โ€œDOM-based cross-site scripting.โ€ Invicti. accessed Jan. 22, 2023, DOM-based XSS.
  12. โ€œDOM based XSS Prevention Cheat Sheet.โ€ OSASP. accessed Ja. 22, 2023, OWASP - Cheatsheets - XSS.
  13. โ€œBBCode.โ€ Wikipedia. Dec. 11, 2022, Wikipedia - BBCode.