Rapid7 Vulnerability & Exploit Database

LibreOffice Macro Code Execution

Back to Search

LibreOffice Macro Code Execution



LibreOffice comes bundled with sample macros written in Python and allows the ability to bind program events to them. A macro can be tied to a program event by including the script that contains the macro and the function name to be executed. Additionally, a directory traversal vulnerability exists in the component that references the Python script to be executed. This allows a program event to execute functions from Python scripts relative to the path of the samples macros folder. The pydoc.py script included with LibreOffice contains the tempfilepager function that passes arguments to os.system, allowing RCE. This module generates an ODT file with a mouse over event that when triggered, will execute arbitrary code.


  • Alex Inführ
  • Shelby Pace




x86, x64



Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/multi/fileformat/libreoffice_macro_exec
msf exploit(libreoffice_macro_exec) > show targets
msf exploit(libreoffice_macro_exec) > set TARGET < target-id >
msf exploit(libreoffice_macro_exec) > show options
    ...show and set options...
msf exploit(libreoffice_macro_exec) > exploit

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security