# CVE-2026-84374: Laravel Excel writes exports outside the configured filesystem disk when given a caller-controlled path

The Markdown version of <https://upatch.dev/cve/CVE-2026-84374>. Last updated 25 Nov 2026.

## At a glance

CVE-2026-84374 is rated High 7.5 (CVSS 3.1, CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H). It affects Laravel-Excel (SpartnerNL) and was published on 1 Sept 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 0.8%: the estimated chance it is exploited in the next 30 days, as of 24 Nov 2026. The upatch `cve-2026-84374-excel-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

CVE-2026-84374 (GHSA-c7r6-vx3h-w5g2), published on 1 September 2026, affects `maatwebsite/excel` (`SpartnerNL/Laravel-Excel`) from 3.1.8 until 3.1.70. In `src/Files/Disk.php`, `Maatwebsite\Excel\Files\Disk::copy()` resolves the `$destination` path passed to `Excel::store()`, `$export->store()`, or `storeExcel()` against the process working directory with `realpath()` instead of resolving it through the configured Flysystem disk. When `realpath($destination)` matches an existing writable file on the local filesystem, `Disk::copy()` opens that path directly with `fopen($destination, 'rb+')` and copies the export stream into it with `stream_copy_to_stream()`, bypassing Flysystem's root directory confinement and overwriting arbitrary existing files with export content.

### Official description

Laravel Excel provides supercharged Excel exports and imports in Laravel. From 3.1.8 until 3.1.70, in src/Files/Disk.php the Maatwebsite\Excel\Files\Disk::copy() method resolves the caller-controlled $destination supplied through Excel::store(), $export->store(), or storeExcel() against the process working directory with realpath() instead of the configured filesystem disk. If the path names an existing writable file, Disk::copy() opens it with fopen() in rb+ mode and uses stream_copy_to_stream(), bypassing Flysystem path confinement and allowing an attacker whose application input controls the export path to overwrite arbitrary existing files with export content. The rb+ behavior creates a non-truncating overwrite and trailing bytes when the new export is shorter, and overwriting an executable PHP file can lead to remote code execution. This issue is fixed in version 3.1.70.

## What the upatch does

One BPF LSM program at `lsm/file_open` returns `-EPERM` when a PHP process (`php`, `php-fpm`, or `php<version>`) opens an existing regular file for both reading and writing without creating or truncating it (`(f_mode & (FMODE_READ | FMODE_WRITE)) == (FMODE_READ | FMODE_WRITE)` and `(f_flags & (O_CREAT | O_TRUNC)) == 0`), unless the file name starts with `laravel-excel-`.

| Hook            | Refused                                                                                                                                                                                     |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `lsm/file_open` | Opening an existing regular file in `r+` / `rb+` mode (`FMODE_READ \| FMODE_WRITE` without `O_CREAT` or `O_TRUNC`) by a PHP process when the file name does not start with `laravel-excel-` |

During an export, `LocalTemporaryFile::readStream()` opens the temporary export file (named `laravel-excel-<random>`) in `rb+` mode to read its stream, which the prefix check permits. Normal Flysystem disk writes (`Disk::put()`) and `file_put_contents()` open destination files with `wb` (`O_WRONLY | O_CREAT | O_TRUNC`), which only sets `FMODE_WRITE` and includes `O_CREAT | O_TRUNC`, so normal exports to new or existing paths inside the configured disk continue to work. Only the vulnerable `fopen($destination, 'rb+')` branch in `Disk::copy()` opens a non-temporary regular file with `FMODE_READ | FMODE_WRITE` and without `O_CREAT` or `O_TRUNC`.

The `refused` per-CPU array counts refused opens at key 0.

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

## Side effects

- Calling `Excel::store()` with a `$destination` that resolves via `realpath()` to an existing file on a vulnerable Laravel Excel (< 3.1.70) fails because `fopen($destination, 'rb+')` is denied with `EPERM`.
- Any other PHP code on the same machine that opens an existing regular file in `r+` or `rb+` mode (`O_RDWR` without `O_CREAT` or `O_TRUNC`) whose name does not start with `laravel-excel-` is also refused with `EPERM`. Standard file reads (`r`), writes (`w`, `file_put_contents`), appends (`a`), and SQLite WAL/database opens with `O_CREAT` are unaffected.
- Upgraded Laravel Excel (3.1.70 and later) removes the `realpath()` / `fopen($destination, 'rb+')` branch and always writes through `$this->put($destination, $readStream)`, which uses `wb` (`O_WRONLY | O_CREAT | O_TRUNC`) and is unaffected.

## Preemption model and cost

The program keeps no state beyond the per-CPU refusal counter updated with `__sync_fetch_and_add`, so it is safe under all preemption models including preemptible RCU, `PREEMPT_LAZY`, and `PREEMPT_RT`. On every `file_open` call, the first check inspects `file->f_mode` and `file->f_flags` directly from the hook argument and returns immediately for all read-only, write-only, create, or truncate opens before inspecting the dentry or current task.

## Affected versions

Application vulnerability: `maatwebsite/excel` (`SpartnerNL/Laravel-Excel`) from 3.1.8 to 3.1.69, fixed in 3.1.70.

Kernels: any Linux kernel supported by shirudo with BPF LSM (`lsm/file_open`) and BTF enabled.

## How it was tested

On Laravel Excel 3.1.69, the loaded upatch refused the Disk::copy() rb+ open of an existing file outside the configured local disk while normal exports into the disk succeeded.

- **Tested:** 25 Nov 2026
- **Target:** Laravel Excel 3.1.69 (Maatwebsite\Excel\Files\Disk::copy) on PHP CLI built-in HTTP server, loopback only
- **Kernel:** 7.4-shirudo-ci-20261123
- **Architecture:** x86_64
- **Distribution:** Ubuntu 26.04

### Results

| State           | Disk::copy rb+ overwrite of existing file outside disk blocked | Normal export into configured disk |
| --------------- | -------------------------------------------------------------- | ---------------------------------- |
| Before loading  | no (HTTP 200)                                                  | yes (HTTP 200)                     |
| Upatch loaded   | yes (HTTP 500)                                                 | yes (HTTP 200)                     |
| After unloading | no (HTTP 200)                                                  | yes (HTTP 200)                     |

## 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-84374
```

Publish and roll out:

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

## Review

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

## Sources and links

- [CVE-2026-84374 record (CVE API)](https://cveawg.mitre.org/api/cve/CVE-2026-84374)
- [GitHub Security Advisory GHSA-c7r6-vx3h-w5g2](https://github.com/SpartnerNL/Laravel-Excel/security/advisories/GHSA-c7r6-vx3h-w5g2)
- [Fix commit b5cafdfcf7ec](https://github.com/SpartnerNL/Laravel-Excel/commit/b5cafdfcf7ec63924e83303763be8fcae340f70b)
- [Laravel Excel 3.1.70 release](https://github.com/SpartnerNL/Laravel-Excel/releases/tag/3.1.70)

### Links

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

### More references from NVD (3)

- [github.com](https://github.com/SpartnerNL/Laravel-Excel/commit/b5cafdfcf7ec63924e83303763be8fcae340f70b)
- [github.com](https://github.com/SpartnerNL/Laravel-Excel/releases/tag/3.1.70)
- [github.com](https://github.com/SpartnerNL/Laravel-Excel/security/advisories/GHSA-c7r6-vx3h-w5g2)
