CVE-2026-82450
BookStack before 26.05.4 Remote Code Execution via Book Cover
Refuses creating and opening .php files in BookStack image upload directories to mitigate CVE-2026-82450.
High 8.7Vetted
EPSS 1%: the estimated chance this CVE is exploited in the next 30 days, as of 24 Nov 2026.
At a glance
CVE-2026-82450 is a high (CVSS 8.7) vulnerability in BookStack, published 29 August 2026. A vetted upatch, cve-2026-82450-php-block, blocks it on running Linux machines with shirudo until BookStack is upgraded.
- Severity
- High 8.7 CVSS 4.0
- Chance of exploitation
- 1% in the next 30 days (EPSS, 24 Nov 2026)
- Known exploited
- No, not on CISA’s KEV list
- Weakness
- CWE-434
- Affected software
- BookStack (bookstackapp)
- Upatch status
- Vetted, merged into the registry
- How to apply
- Build, sign and roll out with shirudo
Overview
CVE-2026-82450 is a remote code execution vulnerability in BookStack before 26.05.4 (CWE-434). In the portable ZIP import feature, ZipExportBook validated the cover reference with fileReferenceRule() instead of imageFileReferenceRule(), ZipImportRunner::zipFileToUploadedFile() kept the archive entry's original filename without forcing an extension from its MIME type, and ImageStorage::cleanImageFileName() did not check ImageService::isExtensionSupported(). A user with Import Content and Create Books permissions can import a portable ZIP archive whose book cover is a valid image file named with a .php extension (or a PHP polyglot). BookStack resizes the image and writes it to public/uploads/images/cover_book/<YYYY-MM>/<name>.php inside the public web root, where unauthenticated HTTP requests can execute it.
Official description
BookStack before 26.05.4 contains a remote code execution vulnerability in the portable ZIP import functionality that allows users with Import Content and Create Books permissions to upload a PHP polyglot file as a book cover. Attackers can bypass image extension validation by embedding a PHP file with a .php filename in the ZIP archive, which is stored in the public web root and executed by unauthenticated requests.
Affected versions
BookStack: all versions before 26.05.4 are affected; 26.05.4 fixes the issue in commit e210cc32e4cbb1efeae5c5c9d0fef8e3c6a752e6.
Kernels: any Linux kernel supported by shirudo with BPF LSM enabled and the four-argument inode_create LSM hook (idmap, dir, dentry, mode), including Linux 7.4.
Sources
More references from NVD (3)
Mitigation
Two BPF LSM programs return -EPERM to PHP processes (php, php-fpm*, php-cgi*, or versioned binaries such as php8.3) when the target dentry has an ancestor directory named images within four levels (covering uploads/images/<type>/<YYYY-MM>/<file>.php and its thumbs-* or scaled-* thumbnail subdirectories):
| Hook | Refused |
|---|---|
lsm/inode_create |
Creating a file whose name ends in .php (case-insensitive) under an images directory |
lsm/file_open |
Opening a file whose name ends in .php (case-insensitive) under an images directory |
The inode_create hook causes ImageService::saveNew() to fail when writing the .php cover into public/uploads/images/cover_book/<YYYY-MM>/, so ImportRepo::runImport() rolls back the database transaction and reverts stored files. The file_open hook also prevents a PHP worker from opening a .php file that was planted in uploads/images/ before the upatch was loaded. Each program checks the 4-byte .php suffix of the filename first and returns immediately for all other files.
The refused per-CPU array counts refusals: key 0 for creates, key 1 for opens.
Side effects
- Importing a portable ZIP archive with a
.phpbook cover fails with HTTP 500 and rolls back the import. Normal portable ZIP imports with supported image extensions (.jpg,.jpeg,.png,.gif,.webp,.avif) and normal image uploads continue to work. - PHP processes cannot create or open
.phpfiles inside a directory namedimages(up to three subdirectories deep). BookStack's own PHP source code lives underapp/,bootstrap/,config/,database/,public/,resources/,routes/, andvendor/, none of which place.phpfiles inside animagesdirectory. - Not covered: alternate PHP handler extensions such as
.phtmlor.pharif the web server is configured to execute them as PHP, or animagesupload root configured under a different directory name.
Preemption model and cost
The programs keep no shared state beyond the per-CPU refused counter, which is updated with __sync_fetch_and_add, making them safe under every preemption model including PREEMPT_LAZY, preemptible RCU, and PREEMPT_RT. On every inode_create and file_open call, the fast path checks the filename length and reads the last 4 bytes of d_name.name; files not ending in .php return immediately without walking parent directories or inspecting the task.
The policy
140 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 ends_with_php(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 tail[4] = {};
if (!name || len < 5 || len > 255)
return false;
if (bpf_probe_read_kernel(tail, sizeof(tail), name + len - 4))
return false;
return tail[0] == '.' &&
(tail[1] | 0x20) == 'p' &&
(tail[2] | 0x20) == 'h' &&
(tail[3] | 0x20) == 'p';
}
static __always_inline bool name_is_images(const struct dentry *dentry)
{
const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
char buf[7] = {};
if (!dentry || BPF_CORE_READ(dentry, d_name.len) != 6)
return false;
if (!name || bpf_probe_read_kernel(buf, 6, name))
return false;
return buf[0] == 'i' && buf[1] == 'm' && buf[2] == 'a' &&
buf[3] == 'g' && buf[4] == 'e' && buf[5] == 's';
}
static __always_inline bool in_images_tree(const struct dentry *dentry)
{
const struct dentry *dir = BPF_CORE_READ(dentry, d_parent);
for (int i = 0; i < 4; i++) {
const struct dentry *parent;
if (!dir)
return false;
if (name_is_images(dir))
return true;
parent = BPF_CORE_READ(dir, d_parent);
if (parent == dir)
return false;
dir = parent;
}
return false;
}
static __always_inline bool starts_with_php(const char *s)
{
return s[0] == 'p' && s[1] == 'h' && s[2] == 'p' &&
(s[3] == 0 || s[3] == '-' ||
(s[3] >= '0' && s[3] <= '9'));
}
static __always_inline bool current_is_php(void)
{
char comm[16] = {};
struct task_struct *task;
const struct dentry *exe;
const unsigned char *name;
char buf[5] = {};
if (bpf_get_current_comm(comm, sizeof(comm)) == 0 &&
starts_with_php(comm))
return true;
task = bpf_get_current_task_btf();
exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);
name = BPF_CORE_READ(exe, d_name.name);
if (!name || bpf_probe_read_kernel(buf, 4, name))
return false;
return starts_with_php(buf);
}
static __always_inline int earlier_verdict(int ret)
{
return ret >= -4095 && ret < 0 ? ret : -EPERM;
}
SEC("lsm/inode_create")
int BPF_PROG(cve_2026_82450_create, const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry, umode_t mode, int ret)
{
if (ret)
return earlier_verdict(ret);
if (!ends_with_php(dentry))
return 0;
if (!in_images_tree(dentry) || !current_is_php())
return 0;
count(REFUSED_CREATE);
return -EPERM;
}
SEC("lsm/file_open")
int BPF_PROG(cve_2026_82450_open, struct file *file, int ret)
{
const struct dentry *dentry = file->f_path.dentry;
if (ret)
return earlier_verdict(ret);
if (!ends_with_php(dentry))
return 0;
if (!in_images_tree(dentry) || !current_is_php())
return 0;
count(REFUSED_OPEN);
return -EPERM;
}
The package: name, license, the program and the CVE it fixes.
[package]
name = "cve-2026-82450"
description = "Refuses creating and opening .php files in BookStack image upload directories to mitigate CVE-2026-82450"
license = "GPL-2.0 OR BSD-2-Clause"
[[upatches]]
source = "cve-2026-82450-php-block.bpf.c"
[upatches.tree]
id = "cve-2026-82450-php-block"
fixes = ["CVE-2026-82450"]
Process
How this upatch was written, checked and reviewed, from the registry’s history.
- 29 Aug 2026CVECVE published
- 25 Nov 2026Pull requestPull request #32 openedAdd CVE-2026-82450: Refuses creating and opening .php files in BookStack image upload directoriesromanlab
- 25 Nov 2026MergeMerged #32romanlab
- 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)
No human review is recorded on GitHub for this upatch yet.
Evidence
On a vulnerable BookStack 26.05.3 instance, the loaded upatch refused creating the .php book cover under public/uploads/images/ during a portable ZIP import (HTTP 500), while imports before loading and after unloading wrote the file (HTTP 200).
- Tested
- 25 Nov 2026
- Target
- BookStack 26.05.3 on PHP and MariaDB, STORAGE_TYPE=local, loopback only
- Kernel
- 7.4-shirudo-ci-20261123
- Architecture
- x86_64
- Distribution
- Ubuntu 26.04
| State | Portable ZIP import writes .php book cover under uploads/images |
|---|---|
| Before loading | yes (HTTP 200) |
| Upatch loaded | no (HTTP 500) |
| After unloading | yes (HTTP 200) |
tools-test.log Output of tools/test --setup showing the portable ZIP import before, while and after the upatch was loaded.
tools/test --setup, 2026-11-25T11:36:36Z Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm cve-2026-82450 setup done BOOKSTACK_URL=http://127.0.0.1:8080 BOOKSTACK_TOKEN=upatchtokenid:upatchtokensecret BOOKSTACK_IMAGES_DIR=/opt/upatch-payload/cve-2026-82450/BookStack-26.05.3/public/uploads/images before reached portable ZIP import wrote upatchprobe313d9825fcb4.php under uploads/images (HTTP 200); removed it loaded blocked portable ZIP import failed to write upatchprobe8bbda42ba8de.php (HTTP 500) after reached portable ZIP import wrote upatchprobe4dfed80dad82.php under uploads/images (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.
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-82450shirudo bpm push build/packages/cve-2026-82450-1.0.0.bee oci://<registry>/<namespace>/cve-2026-82450 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-82450-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>