Kimaya Kelbaikar • CVE-2018-16858 • LibreOffice < 6.0.7 / 6.1.3 • University of Chester
Most people assume that opening a document is a passive act. You're the reader. The file is inert. Nothing happens unless you click something, enable something, or agree to something. CVE-2018-16858 proves all of that wrong.
This vulnerability in LibreOffice allows an attacker to craft a document that, the moment it is opened, silently traverses the filesystem, locates a Python script in an unexpected path, and executes it — with no warnings, no prompts, and no user interaction beyond double-clicking the file.
For my Software Exploitation assessment at the University of Chester, I built a live proof-of-concept demonstrating exactly this — crafting a malicious ODT file from scratch and watching it execute arbitrary code on a victim machine the instant it was opened.
⚠️ Educational DisclaimerAll demonstrations were conducted in a sandboxed VM environment under academic supervision. The techniques here are shared strictly for educational and defensive security purposes.
LibreOffice documents (ODT, ODP, ODS, etc.) are ZIP archives containing XML files. One of those XML files — content.xml — defines the document body, including hyperlinks.
The flaw lies in how LibreOffice handles hyperlink URLs that reference LibreLogo scripts. When the application processes an event-driven macro URL, it fails to properly validate the file path. An attacker can supply a directory traversal sequence — using ../ patterns — to point the macro loader at any Python file on the filesystem, outside the document's expected scope.
The critical detail: this can be bound to the document's open event. No hover required. No click. Just open the file.
<text:a xlink:type="simple"
xlink:href="macro:///LibreLogo.Logo.run(
../../../../../path/to/payload.py)"
office:macro-name="...">
Click here
</text:a>
The traversal sequence escapes LibreOffice's expected script directory and reaches any readable Python file on disk. In a real attack, the payload could be pre-staged or fetched remotely. In my demonstration, I used a simple script that made the compromise undeniable to the audience.
Unlike the macro-based CVE-2019-9848, this attack requires manually crafting the document's internal XML — going under the hood of the file format itself.
content.xml of the ODT document, open in Notepad. The malicious xlink:href containing the directory traversal path is visible at the bottom — pointing to http://test/ as the traversal entry point.malicious_dontclick.odt, malicious_dontclick_doc.docx — showing the iterative process of crafting and testing the exploit.demo, dontclick, mal_final, malicious_file — the forensic trail of an exploit in development.malicious_file.odt selected. 35.4 KB — a completely normal-looking document with a hidden payload inside.The Python payload in this demonstration was intentionally benign — designed to make the compromise impossible to miss without causing any actual harm. It opens Notepad via a system call and writes a message. In a real attack, this would be a reverse shell, credential harvester, or ransomware dropper.
# The Python payload — staged at the traversal target path
import os
# Opens Notepad with a custom message on the victim machine
os.system('notepad C:\path\to\message.txt')
open malicious_file.odt
Loading document... traversing path... executing macro...
YOU'VE BEEN HACKED!!!!!!!! by Kimaya
malicious_file.odt was opened in LibreOffice, Notepad launched automatically — a process the user never invoked — displaying the proof-of-compromise message. cmd.exe is visible in the background taskbar, confirming the system call chain.In a Real AttackThe Notepad popup would be replaced with a silent reverse shell, data exfiltration script, or ransomware payload. The victim would see nothing — just a document that appeared to open normally.
Unlike phishing attacks that require victims to click links or enable macros, CVE-2018-16858 fires on document open. There is no security prompt to dismiss, no “enable content” button to click. The attack surface is the act of reading a document.
Documents arrive via email, shared drives, and messaging apps constantly. They are inherently trusted artifacts — we open them to read information. This vulnerability weaponises that trust. An ODT file sent from a compromised colleague, or attached to a convincing email, is all it takes.
The traversal component means the attacker doesn't need to smuggle the full payload inside the document. They only need to reference a Python file that already exists on the target — or stage one via a separate channel. This splits the attack and makes detection harder: the document itself may appear clean to static analysis.
Comparison: CVE-2019-9848 vs CVE-2018-16858CVE-2019-9848 (LibreLogo) requires a mouse hover — user must interact with the document. CVE-2018-16858 requires only opening the file. In terms of attack friction, this one is strictly worse.
The patch landed in LibreOffice 6.0.7 and 6.1.3, released in late 2018. Any installation older than this remains vulnerable. Beyond patching, organisations should disable LibreLogo entirely if not needed, and enforce application whitelisting to prevent unexpected script execution.
✅ Mitigation ChecklistUpdate LibreOffice to 6.0.7+ or 6.1.3+ · Disable LibreLogo if unused (Tools → Options → LibreOffice Basic) · Block ODT execution in untrusted mail environments · Monitor for unexpected script execution processes (python.exe, cmd.exe) spawned by soffice.exe