upatch.dev

CVE-2026-84374

Laravel Excel writes exports outside the configured filesystem disk when given a caller-controlled path

Refuses the Laravel Excel Disk::copy rb+ file open to mitigate CVE-2026-84374.

High 7.5Vetted

EPSS 0.8%: the estimated chance this CVE is exploited in the next 30 days, as of 24 Nov 2026.

At a glance

CVE-2026-84374 is a high (CVSS 7.5) vulnerability in Laravel-Excel, published 1 September 2026. A vetted upatch, cve-2026-84374-excel-block, blocks it on running Linux machines with shirudo until Laravel-Excel is upgraded.

Severity
High 7.5 CVSS 3.1
Chance of exploitation
0.8% in the next 30 days (EPSS, 24 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-22, CWE-73
Affected software
Laravel-Excel (SpartnerNL)
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

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.

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.

Sources

More references from NVD (3)

Mitigation

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.

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.

The policy

112 lines of BPF C, attached at lsm/file_open.

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>

#define EPERM		1
#define FMODE_READ	0x1
#define FMODE_WRITE	0x2
#define FMODE_RDWR	(FMODE_READ | FMODE_WRITE)
#define O_CREAT		00000100
#define O_TRUNC		00001000
#define S_IFMT		00170000
#define S_IFREG		00100000

char _license[] SEC("license") = "Dual BSD/GPL";

struct {
	__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
	__uint(max_entries, 1);
	__type(key, __u32);
	__type(value, __u64);
} refused SEC(".maps");

static __always_inline void count_refused(void)
{
	__u32 key = 0;
	__u64 *value = bpf_map_lookup_elem(&refused, &key);

	if (value)
		__sync_fetch_and_add(value, 1);
}

static __always_inline int earlier_verdict(int ret)
{
	return ret >= -4095 && ret < 0 ? ret : -EPERM;
}

static __always_inline bool is_laravel_excel_temp(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	__u32 len = BPF_CORE_READ(dentry, d_name.len);
	char buf[16] = {};

	if (len < 14 || !name)
		return false;
	if (bpf_probe_read_kernel(buf, 14, name))
		return false;
	return buf[0] == 'l' && buf[1] == 'a' && buf[2] == 'r' &&
	       buf[3] == 'a' && buf[4] == 'v' && buf[5] == 'e' &&
	       buf[6] == 'l' && buf[7] == '-' && buf[8] == 'e' &&
	       buf[9] == 'x' && buf[10] == 'c' && buf[11] == 'e' &&
	       buf[12] == 'l' && buf[13] == '-';
}

static __always_inline bool is_php_name(const char *s)
{
	if (s[0] != 'p' || s[1] != 'h' || s[2] != 'p')
		return false;
	if (s[3] == 0)
		return true;
	if (s[3] == '-' && s[4] == 'f' && s[5] == 'p' && s[6] == 'm')
		return true;
	if (s[3] >= '0' && s[3] <= '9')
		return true;
	return false;
}

static __always_inline bool current_is_php(void)
{
	char comm[16] = {};

	if (bpf_get_current_comm(&comm, sizeof(comm)) == 0 && is_php_name(comm))
		return true;

	struct task_struct *task = bpf_get_current_task_btf();
	const unsigned char *name = BPF_CORE_READ(task, mm, exe_file, f_path.dentry, d_name.name);
	char exe[16] = {};

	if (!name || bpf_probe_read_kernel_str(exe, sizeof(exe), name) < 0)
		return false;
	return is_php_name(exe);
}

SEC("lsm/file_open")
int BPF_PROG(cve_2026_84374_open, struct file *file, int ret)
{
	if (ret)
		return earlier_verdict(ret);

	if ((file->f_mode & FMODE_RDWR) != FMODE_RDWR)
		return 0;

	if (file->f_flags & (O_CREAT | O_TRUNC))
		return 0;

	struct inode *inode = file->f_inode;
	if (!inode || (BPF_CORE_READ(inode, i_mode) & S_IFMT) != S_IFREG)
		return 0;

	const struct dentry *dentry = file->f_path.dentry;
	if (!dentry || is_laravel_excel_temp(dentry))
		return 0;

	if (!current_is_php())
		return 0;

	count_refused();
	return -EPERM;
}

Process

How this upatch was written, checked and reviewed, from the registry’s history.

  1. 1 Sept 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #36 openedAdd CVE-2026-84374: Refuses the Laravel Excel Disk::copy rb+ file openromanlab
  3. 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)
  4. 25 Nov 2026MergeMerged #36romanlab

No human review is recorded on GitHub for this upatch yet.

Evidence

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
StateDisk::copy rb+ overwrite of existing file outside disk blockedNormal export into configured disk
Before loadingno (HTTP 200)yes (HTTP 200)
Upatch loadedyes (HTTP 500)yes (HTTP 200)
After unloadingno (HTTP 200)yes (HTTP 200)
tools-test.log Output of tools/test --setup showing the probe reached before, blocked while the upatch was loaded, and reached again after unload.
tools/test --setup, 2026-11-25T11:48:57Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-84374
  setup   done         EXCEL_URL=http://127.0.0.1:18080 EXCEL_OUTSIDE_DIR=/opt/upatch-payload/cve-2026-84374/outside EXCEL_DISK_DIR=/opt/upatch-payload/cve-2026-84374/disk
  before  reached      Disk::copy opened probe-fbed79c48ad6.csv in rb+ mode and overwrote it outside the disk (HTTP 200)
  loaded  blocked      Disk::copy rb+ open of the existing file outside the disk was refused with HTTP 500 and normal export succeeded
  after   reached      Disk::copy opened probe-7378636daf55.csv in rb+ mode and overwrote it outside the disk (HTTP 200)
  PASS: reached before, blocked while loaded, reached again after

Use it

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
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
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>