CVE-2019-9848
LibreOffice < 6.2.5, Arbitrary Python exec via LibreLogo
- CVSS 9.8
- CWE-94 Improper Control of Generation of Code ('Code Injection')
- Input Validation and Sanitization
- Remote
LibreOffice has a feature where documents can specify that pre-installed scripts can be executed on various document events such as mouse-over, etc. LibreOffice is typically also bundled with LibreLogo, a programmable turtle vector graphics script, which can be manipulated into executing arbitrary python commands. By using the document event feature to trigger LibreLogo to execute python contained within a document a malicious document could be constructed which would execute arbitrary python commands silently without warning. In the fixed versions, LibreLogo cannot be called from a document event handler. This issue affects: Document Foundation LibreOffice versions prior to 6.2.5.
- CVSS base score
- 9.8
- Published
- 2019-07-17
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- LibreOffice
- Fixed by upgrading
- Yes
Solution
Update LibreOffice to version 6.2.5 or higher.
Vulnerable code sample
# Example of a vulnerable implementation that allows LibreLogo to execute arbitrary Python commands
# when triggered by document events such as mouse-over.
def on_mouse_over():
# This function simulates an event handler that could be exploited
# to execute arbitrary Python commands through LibreLogo.
# Arbitrary Python command that could be executed
arbitrary_command = "os.system('echo Vulnerable!')"
# Execute the command using LibreLogo
librelogo.execute(arbitrary_command)
# Simulate the document event that triggers the mouse-over
def simulate_mouse_over_event():
print("Mouse over event triggered.")
on_mouse_over()
# Call the function to simulate the event
simulate_mouse_over_event()Patched code sample
# Example of a fix for CVE-2019-9848 in LibreOffice by disabling event handlers for LibreLogo
def disable_librelogo_event_handlers():
# This function would represent the logic to disable the execution of LibreLogo scripts
# from document event handlers to prevent arbitrary code execution.
# Pseudo-code to represent disabling event handlers
libreoffice_document = get_current_document() # Assume this gets the current document context
# Disable specific event handlers that could trigger LibreLogo scripts
libreoffice_document.disable_event_handler("onMouseOver")
libreoffice_document.disable_event_handler("onDocumentOpen")
libreoffice_document.disable_event_handler("onDocumentClose")
print("LibreLogo event handlers disabled to prevent arbitrary code execution.")
# Call the function to apply the fix
disable_librelogo_event_handlers()Cite this entry
@misc{vaitp:cve20199848,
title = {{LibreOffice < 6.2.5, Arbitrary Python exec via LibreLogo}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2019},
note = {VAITP Python Vulnerability Dataset, entry CVE-2019-9848},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-9848/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
