The feature
LibreOffice's scripting feature allowed a document to reference a local Python script via a path-traversal in the script URI, and a built-in Python function passed user-controlled arguments to a shell. An attacker could craft an ODT file that, when opened and the mouse moved over a link, executed arbitrary code without warning.
insert-script.blogspot.com
Published on insert-script.blogspot.com
I started to have a look at Libreoffice and discovered a way to achieve remote code execution as soon as a user opens a malicious ODT file and moves his mouse over the document, without triggering any warning dialog. This blogpost will describe the vulnerability I discovered.
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 script URI handler did not properly restrict the path (allowing directory traversal) and a bundled Python function passed user-supplied arguments to os.system without sanitisation.
What the attacker needed
Victim opens a malicious ODT file; victim moves mouse over a link; LibreOffice 6.1.x (for parameter passing)
The fix
The path traversal was fixed in LibreOffice [redacted] and 6.0.7; users can also disable Python scripting by removing or renaming the pythonscript.py file.
How it was found
- Create an ODT file with a hyperlink that has an onmouseover event listener pointing to a Python script.
- Modify the script URI to include path traversal sequences to reach a different local file.
- Open the ODT file in LibreOffice and move the mouse over the hyperlink to trigger the event.
- Observe that the referenced Python file is executed without any warning dialog.
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 documents can contain scripts that run when you interact with them, such as moving your mouse over a link. The author found that the document could point to a script file outside the intended folder and even pass commands to it, so opening a malicious document and hovering over a link could run the attacker's code 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.