# CVE-2026-82450: BookStack before 26.05.4 Remote Code Execution via Book Cover

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

## At a glance

CVE-2026-82450 is rated High 8.7 (CVSS 4.0, CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/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 BookStack (bookstackapp) and was published on 29 Aug 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 1%: the estimated chance it is exploited in the next 30 days, as of 24 Nov 2026. The upatch `cve-2026-82450-php-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-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.

## What the upatch does

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.

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

## Side effects

- Importing a portable ZIP archive with a `.php` book 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 `.php` files inside a directory named `images` (up to three subdirectories deep). BookStack's own PHP source code lives under `app/`, `bootstrap/`, `config/`, `database/`, `public/`, `resources/`, `routes/`, and `vendor/`, none of which place `.php` files inside an `images` directory.
- Not covered: alternate PHP handler extensions such as `.phtml` or `.phar` if the web server is configured to execute them as PHP, or an `images` upload 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.

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

## How it was tested

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

### Results

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

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

Publish and roll out:

```sh
shirudo 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>
```

## Review

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

## Sources and links

- [CVE-2026-82450 record (CVE API)](https://cveawg.mitre.org/api/cve/CVE-2026-82450)
- [VulnCheck advisory: BookStack before 26.05.4 Remote Code Execution via Book Cover](https://www.vulncheck.com/advisories/bookstack-before-26.05.4-remote-code-execution-via-book-cover)
- [BookStack fix commit e210cc32e4cb](https://github.com/BookStackApp/BookStack/commit/e210cc32e4cbb1efeae5c5c9d0fef8e3c6a752e6)
- [BookStack release v26.05.4](https://github.com/BookStackApp/BookStack/releases/tag/v26.05.4)

### Links

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

### More references from NVD (3)

- [github.com](https://github.com/BookStackApp/BookStack)
- [github.com](https://github.com/BookStackApp/BookStack/commit/e210cc32e4cbb1efeae5c5c9d0fef8e3c6a752e6)
- [vulncheck.com](https://www.vulncheck.com/advisories/bookstack-before-26.05.4-remote-code-execution-via-book-cover)
