CVE 2018-16858 Write up – or the joy of macros
LibreOffice versions before 6.0.7/6.1.3 contain a path traversal flaw that allows a crafted ODT document to call internal Python scripts with attacker-controlled arguments, leading to command execution when the user hovers over a hyperlink. An attacker could achieve remote code execution by tricking a victim into opening a malicious document and mousing over a link.
testofpen.wordpress.com
Published on testofpen.wordpress.com
I recently read this article about the vulnerability discovered in Libre office < 6.0.7/6.1.3 and thought I would have a play around with it. As the article mentioned focused on Windows I will have a look at Linux.
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
Likely the application fails to properly validate the script path in event listeners, allowing directory traversal to reach internal Python scripts that pass arguments to os.system.
Impact
An attacker could execute arbitrary commands on the victim's machine, potentially leading to a reverse shell, when the victim opens the document and hovers over the hyperlink.
What the attacker needed
Victim opens malicious ODT; victim hovers over hyperlink; LibreOffice version < 6.0.7/6.1.3
The fix
The vulnerability was fixed in LibreOffice versions 6.0.7 and 6.1.3.
How it was found
- Create a new LibreOffice document and insert a hyperlink.
- Assign a mouseover event to the hyperlink that calls a Python sample script.
- Save the document and unzip it to access content.xml.
- Modify the script path in content.xml to traverse to a vulnerable Python script and inject a command.
- Re-zip the file as an ODT and open it in LibreOffice.
- Hover over the hyperlink to trigger the command 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.
LibreOffice is an office suite like Microsoft Office. A feature that lets documents run small scripts (macros) could be tricked into running a script from outside the document's folder, and that script passed user input to a system command. So opening a malicious document and hovering over a link could let an attacker run commands on your computer.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.