Unrar Path Traversal Vulnerability affects Zimbra Mail
A path traversal flaw in the unrar utility allowed a crafted RAR archive to write files outside the intended extraction directory. In Zimbra, an unauthenticated attacker could send such an archive as an email attachment, leading to remote code execution.
Published on blog.sonarsource.com
At Sonar, we are studying real-world vulnerabilities to improve our code analyzers, and to help the open-source community to secure their projects. To uncover and understand complex vulnerabilities in high-profile applications, our researchers need to take the perspective of real-world attackers.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The symbolic link target was validated before backslashes were converted to forward slashes, so a path traversal sequence using backslashes bypassed the check.
Impact
An unauthenticated attacker could execute arbitrary code on the Zimbra server, potentially accessing all emails and escalating privileges, though on distributed installations some exploitation paths may not work.
What the attacker needed
Unrar installed on the server; ability to send email to a Zimbra mailbox
The fix
RarLab patched unrar to ensure the validated path matches the path used to create the symlink, and Zimbra mitigated by configuring Amavis to use 7z instead of unrar.
How it was found
- Craft a RAR archive containing a symbolic link of type FSREDIR_WINSYMLINK with a target that uses backslashes to attempt path traversal.
- Send the archive as an email attachment to a Zimbra mailbox.
- Zimbra's Amavis service automatically extracts the archive using unrar.
- The symbolic link is created outside the extraction directory, allowing file write to arbitrary locations.
- Use the file write to place a malicious file (e.g., a JSP shell) in a web-accessible directory to achieve code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
The unrar tool, used to unpack RAR archives, failed to properly check symbolic links inside archives. A malicious archive could trick it into writing files to any location on the server. In Zimbra, this meant an attacker could email a specially crafted RAR file and gain control of the server without needing any login.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.