# CVE-2026-81730: Dolibarr 9.0.0 through 23.0.4 Path Traversal via EmailCollector Attachment Filename

The Markdown version of <https://upatch.dev/cve/CVE-2026-81730>. Last updated 27 Aug 2026.

## At a glance

CVE-2026-81730 is rated High 8.8 (CVSS 4.0, CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X). It affects Dolibarr and was published on 27 Aug 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 0.6%: the estimated chance it is exploited in the next 30 days, as of 25 Nov 2026. The upatch `cve-2026-81730-dolibarr-block` mitigates it, and is vetted (merged into the registry).

A upatch is a signed BPF program that shirudo loads into a running Linux kernel to block the code path this CVE's exploit takes. It holds the line until the fix ships; it does not replace patching.

## The vulnerability

Dolibarr's EmailCollector (`htdocs/emailcollector/class/emailcollector.class.php` and `htdocs/emailcollector/lib/emailcollector.lib.php`) saves inbound email attachments during the `recordjoinpiece`, `project` and `ticket` operations using the raw filename from the message's MIME headers (`$attachment->getName()`, `$attachment->getFilename()`, or `getAttachments()`).

1. In `htdocs/emailcollector/lib/emailcollector.lib.php`, the global `saveAttachment($target, $name, $content)` splits `$name` on its last dot into `$filename` and `$ext`, builds `$filepath = $path . $filename . '.' . $ext`, and passes `$filepath` directly to `file_put_contents($filepath, $content)`.
2. In `htdocs/emailcollector/class/emailcollector.class.php`, the private `EmailCollector::saveAttachment($destdir, $filename, $content)` calls `file_put_contents($destdir.'/'.$filename, $content)` directly.

Because neither function strips directory traversal sequences (`..`) before calling `file_put_contents()`, an inbound email attachment whose MIME filename contains `../` escapes the per-object directory (`documents/<module>/<ref>/`) and writes attacker-controlled content into higher directories of `documents` or into `htdocs`.

Upstream commit `264a44defb5e438689c75679617f6edc4c038abc` fixes this by replacing the duplicate attachment helpers with `EmailCollector::saveEmailCollectorAttachmentsToDir()`, which sanitizes the destination directory with `dol_sanitizePathName()` and reduces each attachment name to a safe basename with `dol_sanitizeFileName()`.

### Official description

Dolibarr 9.0.0 through 23.0.4 saves inbound email attachments under the name supplied in the message's MIME headers without reducing it to a safe basename. The global saveAttachment() in htdocs/emailcollector/lib/emailcollector.lib.php builds $filepath = $path . $filename . '.' . $ext and hands it to file_put_contents(), and the private saveAttachment() in htdocs/emailcollector/class/emailcollector.class.php writes to $destdir.'/'.$filename; the name reaches both from the attachment's own getName() or getFilename() value by way of the record-join, create-ticket and create-project operations. A traversal sequence in the filename therefore survives intact, so any sender who can email a mailbox that an EmailCollector monitors, which is the module's ordinary use for a support or ticket inbox, can place attacker-controlled content outside the per-object attachment directory without holding a Dolibarr account. Under the hardened layout Dolibarr's SECURITY.md requires, with htdocs read-only, the write is confined to the documents tree and corrupts or forges other objects' documents; where htdocs is writable the same primitive reaches a web-executable path. Version 24.0.0 applies dol_sanitizePathName() and dol_sanitizeFileName() before the write.

## What the upatch does

A legitimate EmailCollector attachment is written inside a per-object directory at depth two or deeper below `documents` (`documents/<module>/<ref>/<file>`, or `documents/<module>/<ref>/thumbs/<file>` for image thumbnails) and never inside `htdocs` or with a PHP script extension.

| Hook               | Refuses when                                                                                                                                                                                                                                        | Effect                                                                                                       |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `lsm/inode_create` | Current process executable is `php*`, `apache2` or `httpd`, and the target dentry is under `htdocs`, directly inside `documents/` or `documents/<module>/`, or under `documents` with a `.php`, `.phtml`, `.phar`, `.php3`-`.php8` or `.inc` suffix | `openat(..., O_CREAT, ...)` from `file_put_contents()` fails with `EPERM`; no traversed file is created      |
| `lsm/file_open`    | Current process executable is `php*`, `apache2` or `httpd`, `file->f_mode & FMODE_WRITE` is set, and the target dentry matches the same path or extension check                                                                                     | Opening an existing file for overwrite outside the per-object directory or under `htdocs` fails with `EPERM` |

Each refusal increments its counter in the `refused` per-CPU array map (`key 0` for `inode_create`, `key 1` for `file_open`).

The policy: [`cve-2026-81730-dolibarr-block.bpf.c`](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-81730), 207 lines of BPF C attached at `lsm/inode_create` and `lsm/file_open`, licensed GPL-2.0 OR BSD-2-Clause.

## Scope and limitations

- Matches processes whose executable starts with `php` or equals `apache2` or `httpd`.
- Assumes Dolibarr's web root directory is named `htdocs` and its data root directory (`$dolibarr_main_data_root`) is named `documents`. Deployments that rename those directories are not matched.
- Normal attachments saved inside `documents/<module>/<ref>/<filename>` with non-PHP extensions continue to work while the upatch is loaded.

## How it was tested

On a vulnerable Dolibarr 23.0.4, the loaded upatch refused the EmailCollector attachment traversal write into documents/ while allowing the normal attachment write inside documents/ticket/\<ref>/.

- **Tested:** 25 Nov 2026
- **Target:** Dolibarr 23.0.4
- **Kernel:** 7.4-shirudo-ci-20261123
- **Architecture:** x86_64

### Results

| State           | EmailCollector traversal probe (../../upatch-probe-\<token>.txt)            | Normal ticket attachment (upatch-safe-\<token>.txt)              |
| --------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Before loading  | reached — wrote upatch-probe-dd9f7f92ee50.txt into documents/               | wrote into documents/ticket/\<ref>/                              |
| Upatch loaded   | blocked — writing upatch-probe-9818fd4df718.txt into documents/ was refused | wrote upatch-safe-9818fd4df718.txt into documents/ticket/\<ref>/ |
| After unloading | reached — wrote upatch-probe-96555bc3121d.txt into documents/               | wrote into documents/ticket/\<ref>/                              |

## How to apply

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign:

```sh
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-81730
```

Publish and roll out:

```sh
shirudo bpm push build/packages/cve-2026-81730-1.0.0.bee oci://<registry>/<namespace>/cve-2026-81730 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-81730-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>
```

## Review

- Contributors: none recorded.
- Reviewers: none recorded yet.

## Sources and links

- [CVE-2026-81730](https://www.cve.org/CVERecord?id=CVE-2026-81730)
- [VulnCheck advisory: Dolibarr 9.0.0 through 23.0.4 path traversal via EmailCollector attachment filename](https://www.vulncheck.com/advisories/dolibarr-9.0.0-through-23.0.4-path-traversal-via-emailcollector-attachment-filename)
- [Dolibarr vulnerable `saveAttachment()` in 23.0.4 (`htdocs/emailcollector/lib/emailcollector.lib.php#L187`)](https://github.com/Dolibarr/dolibarr/blob/23.0.4/htdocs/emailcollector/lib/emailcollector.lib.php#L187)
- [Upstream fix commit 264a44defb5e438689c75679617f6edc4c038abc](https://github.com/Dolibarr/dolibarr/commit/264a44defb5e438689c75679617f6edc4c038abc)

### Links

- [CVE-2026-81730 on upatch.dev](https://upatch.dev/cve/CVE-2026-81730) (this page, as HTML)
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-81730)
- [CVE.org](https://www.cve.org/CVERecord?id=CVE-2026-81730)
- [CWE-22](https://cwe.mitre.org/data/definitions/22.html)
- Upatch source: [upatches/cve-2026-81730](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-81730)

### More references from NVD (4)

- [github.com](https://github.com/Dolibarr/dolibarr/commit/264a44defb5e438689c75679617f6edc4c038abc) (Patch)
- [vulncheck.com](https://www.vulncheck.com/advisories/dolibarr-9.0.0-through-23.0.4-path-traversal-via-emailcollector-attachment-filename) (Patch, Product, Third Party Advisory)
- [github.com](https://github.com/Dolibarr/dolibarr) (Product)
- [github.com](https://github.com/Dolibarr/dolibarr/blob/23.0.4/htdocs/emailcollector/lib/emailcollector.lib.php#L187) (Release Notes)
