# CVE-2018-16858: Path traversal in libreoffice

> Attackers can execute arbitrary Python macros via crafted documents using directory traversal, requiring users to open malicious files in LibreOffice.

- **Severity:** High 7.8 (`CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 25 Mar 2019
- **Updated:** 5 Aug 2024
- **Also known as:** DEBIAN-CVE-2018-16858, DLA-1669-1, DSA-4381-1, GHSA-v39m-j232-p3qr, MGASA-2019-0102, RHSA-2019:2130, SUSE-SU-2019:1448-1, SUSE-SU-2019:1894-1, SUSE-SU-2019:2003-1, UBUNTU-CVE-2018-16858, openSUSE-SU-2019:1929-1

## What is CVE-2018-16858?

CVE-2018-16858 is a high-severity path traversal vulnerability in Libreoffice Libreoffice, published on 25 Mar 2019. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

It was found that libreoffice before versions 6.0.7 and 6.1.3 was vulnerable to a directory traversal attack which could be used to execute arbitrary macros bundled with a document. An attacker could craft a document, which when opened by LibreOffice, would execute a Python method from a script in any arbitrary file system location, specified relative to the LibreOffice install location.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory), CWE-356 (Missing User Interaction for Potentially Unsafe Action)

## Which versions are affected by CVE-2018-16858?

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `autocorr-af` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-bg` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-ca` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-cs` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-da` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-de` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-en` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-es` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-fa` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-fi` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-fr` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-ga` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-hr` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-hu` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-is` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-it` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-ja` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-ko` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-lb` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-lt` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-mn` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-nl` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-pl` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-pt` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-ro` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-ru` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-sk` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-sl` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-sr` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-sv` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-tr` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-vi` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `autocorr-zh` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice-base` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice-bsh` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice-calc` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice-core` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice-data` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |
| `libreoffice-debuginfo` | Red Hat:enterprise_linux:7::client | All versions | 1:5.3.6.1-21.el7 |

Products: Libreoffice Libreoffice.

## How do I fix CVE-2018-16858?

Upgrade to a fixed version.

## Is CVE-2018-16858 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2018-16858 exists.

Public exploit code:

- CVE-2018-16858 exploit implementation (github_poc): https://github.com/4nimanegra/libreofficeExploit1
- https://github.com/phongld97/detect-cve-2018-16858 (github_poc): https://github.com/phongld97/detect-cve-2018-16858
- https://github.com/bantu2301/CVE-2018-16858 (github_poc): https://github.com/bantu2301/CVE-2018-16858
- Python implementation of CVE-2018-16858  (github_poc): https://github.com/Henryisnotavailable/CVE-2018-16858-Python
- LibreOffice Macro Code Execution (metasploit)
- LibreOffice < 6.0.7 / 6.1.3 - Macro Code Execution (Metasploit) (exploitdb)

## Other vulnerabilities in Libreoffice Libreoffice

- [CVE-2024-5261](https://insights.sbomify.com/CVE-2024-5261/): TLS certificate are not properly verified when utilizing LibreOfficeKit (critical 10.0)
- [CVE-2019-9855](https://insights.sbomify.com/CVE-2019-9855/): Windows 8.3 path equivalence handling flaw allows LibreLogo script execution (critical 9.8)
- [CVE-2018-14939](https://insights.sbomify.com/CVE-2018-14939/): Memory corruption in n/a (critical 9.8)
- [CVE-2017-8358](https://insights.sbomify.com/CVE-2017-8358/): Memory corruption in n/a (critical 9.8)
- [CVE-2017-7882](https://insights.sbomify.com/CVE-2017-7882/): Memory corruption in n/a (critical 9.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2018-16858 and fix it if it is affected.

What it is: CVE-2018-16858 is a high-severity path traversal vulnerability in Libreoffice Libreoffice, published on 25 Mar 2019. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2018-16858 exists.

Affected product: Libreoffice Libreoffice. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2018-16858/ (Markdown: https://insights.sbomify.com/CVE-2018-16858/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2018-16858
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2018-16858
- OSV: https://osv.dev/vulnerability/CVE-2018-16858

---
From sbomify Insights: https://insights.sbomify.com/CVE-2018-16858/
Summaries are generated and may contain mistakes; the official description above is the record.
