upatch.dev

CVE-2026-94104

NivoCart through 2.4.0 Arbitrary File Upload RCE via filemanager

Refuses creating or opening PHP scripts in NivoCart's image/data upload directory to mitigate CVE-2026-94104.

High 8.7Vetted

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

At a glance

CVE-2026-94104 is a high (CVSS 8.7) vulnerability in NivoCart, published 20 September 2026. A vetted upatch, cve-2026-94104-upload-block, blocks it on running Linux machines with shirudo until NivoCart is upgraded.

Severity
High 8.7 CVSS 4.0
Chance of exploitation
0.7% in the next 30 days (EPSS, 24 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-434
Affected software
NivoCart
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

CVE-2026-94104 was published on 20 September 2026. In NivoCart through 2.4.0, the multi() method in upload/admin/controller/common/filemanager.php and upload/admin/controller/common/filemanager_full.php handles chunked file uploads into image/data/ without checking hasPermission('modify', 'common/filemanager'), and gates its file extension whitelist check behind if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)). Any filename that does not already exist in the target directory, or any upload request with chunks set to 2 or higher, bypasses the extension filter and is written directly with fopen(..., $chunk === 0 ? "wb" : "ab"). An authenticated back-office user with view-only access to the file manager can therefore upload a .php file into the web-accessible image/data/ directory and request it over HTTP to execute arbitrary PHP code.

Official description

NivoCart through 2.4.0 contains an arbitrary file upload vulnerability in the File Manager multi() endpoint that fails to validate file extensions for new filenames or when chunks parameter is 2 or higher. Attackers with view-only back-office access can upload PHP files to the web-accessible image/data/ directory and execute them for remote code execution.

Affected versions

Application vulnerability: NivoCart through 2.4.0 is affected, and NivoCart 2.5.0 fixes the issue.

Kernels: the program uses the inode_create and file_open LSM hooks on kernels with BPF LSM and BTF enabled, including Linux 7.4.

Sources

More references from NVD (5)

Mitigation

Two BPF LSM programs return -EPERM to processes whose executable name starts with php (such as php, php8.3, php8.4, php-fpm8.4 or php-cgi) or is apache2 or httpd, when the target file is in image/data/ (or up to three subdirectory levels beneath it) and its name ends with .php, .php[0-9], .pht, .phtml, .phar or .phps (case-insensitive):

Hook Refused
lsm/inode_create Creating a PHP script file in image/data/
lsm/file_open Opening a PHP script file in image/data/, whether to overwrite or append chunks or to execute a script planted before the upatch was loaded

Each program checks the file extension first and returns 0 immediately when the name does not carry a PHP extension, before walking up to four parent dentries for image/data and checking the current task's executable. A refusal from an earlier BPF LSM program on the same hook is passed on.

The refused per-CPU array counts refusals: key 0 for creates, key 1 for opens.

Side effects

  • Uploading a file with a .php, .php[0-9], .pht, .phtml, .phar or .phps extension into image/data/ through NivoCart's file manager fails in fopen() and returns JSON-RPC error 102 (Failed to open output stream.).
  • Any PHP script placed in image/data/ before the upatch was loaded can no longer be opened or executed by PHP or Apache.
  • Uploading and serving allowed static media files (.jpg, .jpeg, .png, .gif, .mp3, .mp4, .pdf, .zip and the rest of NivoCart's whitelist) in image/data/ continues to work, as does executing NivoCart's own PHP files in admin/, catalog/, system/ and install/.
  • Not covered: files uploaded into a subdirectory nested more than three levels below image/data/, or served by a web server binary whose executable name does not start with php and is neither apache2 nor httpd.

Preemption model and cost

The programs keep no state beyond the per-CPU refusal counter, which they update with an atomic fetch-and-add, so they are safe under every preemption model, including PREEMPT_LAZY, preemptible RCU and PREEMPT_RT. On every file create or open whose name does not end with a PHP extension, a run costs a length check and one 4-byte kernel read of the suffix.

The policy

163 lines of BPF C, attached at lsm/inode_create and 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

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

enum {
	REFUSED_CREATE,
	REFUSED_OPEN,
	NR_COUNTERS,
};

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

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

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

static __always_inline bool name_is(const struct dentry *dentry,
				    const char *want, __u32 want_len)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	char buf[8] = {};

	if (!dentry || BPF_CORE_READ(dentry, d_name.len) != want_len ||
	    want_len > sizeof(buf) - 1)
		return false;
	if (bpf_probe_read_kernel_str(buf, sizeof(buf), name) < 0)
		return false;
	for (__u32 i = 0; i < sizeof(buf) - 1; i++) {
		if (i == want_len)
			return true;
		if (buf[i] != want[i])
			return false;
	}
	return false;
}

static __always_inline bool has_php_ext(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 s[6] = {};

	if (!dentry || !name || len < 5 || len > 255)
		return false;
	if (bpf_probe_read_kernel(s, 4, name + len - 4))
		return false;
	if (s[0] == '.' && (s[1] | 0x20) == 'p' && (s[2] | 0x20) == 'h' &&
	    ((s[3] | 0x20) == 'p' || (s[3] | 0x20) == 't'))
		return true;
	if (len < 6 || bpf_probe_read_kernel(s, 5, name + len - 5))
		return false;
	if (s[0] == '.' && (s[1] | 0x20) == 'p' && (s[2] | 0x20) == 'h') {
		if ((s[3] | 0x20) == 'a' && (s[4] | 0x20) == 'r')
			return true;
		if ((s[3] | 0x20) == 'p' &&
		    ((s[4] >= '0' && s[4] <= '9') || (s[4] | 0x20) == 's'))
			return true;
	}
	if (len < 7 || bpf_probe_read_kernel(s, 6, name + len - 6))
		return false;
	return s[0] == '.' && (s[1] | 0x20) == 'p' && (s[2] | 0x20) == 'h' &&
	       (s[3] | 0x20) == 't' && (s[4] | 0x20) == 'm' &&
	       (s[5] | 0x20) == 'l';
}

static __always_inline bool in_image_data_dir(const struct dentry *dir)
{
	const struct dentry *cur = dir;

	for (int i = 0; i < 4; i++) {
		const struct dentry *parent;

		if (!cur)
			return false;
		parent = BPF_CORE_READ(cur, d_parent);
		if (name_is(cur, "data", 4) && name_is(parent, "image", 5))
			return true;
		if (parent == cur)
			return false;
		cur = parent;
	}
	return false;
}

static __always_inline bool is_php_name(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[8] = {};

	if (!dentry || !name || len < 3)
		return false;
	if (bpf_probe_read_kernel(buf, sizeof(buf), name))
		return false;
	if (buf[0] == 'p' && buf[1] == 'h' && buf[2] == 'p')
		return true;
	if (len == 7 && buf[0] == 'a' && buf[1] == 'p' && buf[2] == 'a' &&
	    buf[3] == 'c' && buf[4] == 'h' && buf[5] == 'e' && buf[6] == '2')
		return true;
	if (len == 5 && buf[0] == 'h' && buf[1] == 't' && buf[2] == 't' &&
	    buf[3] == 'p' && buf[4] == 'd')
		return true;
	return false;
}

static __always_inline bool current_is_php(void)
{
	struct task_struct *task = bpf_get_current_task_btf();
	const struct dentry *exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);

	return is_php_name(exe);
}

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

SEC("lsm/inode_create")
int BPF_PROG(cve_2026_94104_create, const struct mnt_idmap *idmap,
	     struct inode *dir, struct dentry *dentry, umode_t mode, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (!has_php_ext(dentry))
		return 0;
	if (!in_image_data_dir(BPF_CORE_READ(dentry, d_parent)) || !current_is_php())
		return 0;
	count(REFUSED_CREATE);
	return -EPERM;
}

SEC("lsm/file_open")
int BPF_PROG(cve_2026_94104_open, struct file *file, int ret)
{
	const struct dentry *dentry = file->f_path.dentry;

	if (ret)
		return earlier_verdict(ret);
	if (!has_php_ext(dentry))
		return 0;
	if (!in_image_data_dir(BPF_CORE_READ(dentry, d_parent)) || !current_is_php())
		return 0;
	count(REFUSED_OPEN);
	return -EPERM;
}

Process

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

  1. 20 Sept 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #54 openedAdd CVE-2026-94104: Refuses creating or opening PHP scripts in NivoCart's image/data uploadromanlab
  3. 25 Nov 2026MergeMerged #54romanlab

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

Evidence

On a vulnerable NivoCart 2.4.0 instance, a view-only user uploaded a .php file into image/data/ through common/filemanager/multi before and after the upatch was loaded, while the loaded upatch refused the file creation (JSON-RPC error 102) and wrote no file.

Tested
25 Nov 2026
Target
NivoCart 2.4.0 on PHP and MariaDB, view-only back-office user with access on common/filemanager, loopback only
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Machine
shirudo test VM
Distribution
Ubuntu 26.04
Results
Statecommon/filemanager/multi .php upload in image/data/
Before loadingreached (wrote .php file, HTTP 200)
Upatch loadedblocked (error 102, no file written)
After unloadingreached (wrote .php file, HTTP 200)
tools-test.log Output of tools/test --setup showing the probe reached before and after and was blocked while the upatch was loaded.
tools/test --setup, 2026-11-25T13:10:15Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-94104
  setup   done         NIVOCART_URL=http://127.0.0.1:8080 NIVOCART_IMAGE_DATA=/opt/upatch-payload/cve-2026-94104/app/image/data NIVOCART_USER=viewer NIVOCART_PASS=viewerpass123
  before  reached      multi() wrote upatch-probe-df3de81b212d.php in image/data/ (HTTP 200); removed it
  loaded  blocked      multi() could not open the output stream in image/data/ (error 102) and wrote no file
  after   reached      multi() wrote upatch-probe-bf0045325e5d.php in image/data/ (HTTP 200); removed it
  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-94104
Publish and roll out
shirudo bpm push build/packages/cve-2026-94104-1.0.0.bee oci://<registry>/<namespace>/cve-2026-94104 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-94104-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>