upatch.dev

CVE-2026-85714

Stirling-PDF: Remote Code Execution via H2

Refuses the Stirling-PDF database import SQL file write and open to mitigate CVE-2026-85714.

Critical 9.1Vetted

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

At a glance

CVE-2026-85714 is a critical (CVSS 9.1) vulnerability in Stirling-PDF, published 14 October 2026. A vetted upatch, cve-2026-85714-import-block, blocks it on running Linux machines with shirudo until Stirling-PDF is upgraded.

Severity
Critical 9.1 CVSS 3.1
Chance of exploitation
3.4% in the next 30 days (EPSS, 24 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-94
Affected software
Stirling-PDF (Stirling-Tools)
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

CVE-2026-85714 (GHSA-mrr8-934j-4g8m), published on 14 October 2026, is a remote code execution vulnerability in Stirling-PDF prior to 2.13.2 when running with the default H2 database and security mode enabled. An authenticated administrator can upload a crafted .sql file to POST /api/v1/database/import-database (DatabaseController.importDatabase), which writes the upload to Files.createTempFile("backup_", ".sql") and passes it to DatabaseService.importDatabaseFromUI(). In DatabaseService.validateSqlContent(), statements split on ; are accepted whenever they match any pattern in ALLOWED_PATTERNS (CREATE, INSERT INTO, VALUES, NULL, and others). Dangerous H2 functions and statements such as FILE_READ, CSVWRITE, and CREATE ALIAS embedded inside allowed statements pass validation and execute when verifyBackup() and executeDatabaseScript() run RUNSCRIPT FROM ?. An existing backup_*.sql file in backup/db/ can also be imported through GET /api/v1/database/import-database-file/{fileName}.

Official description

Stirling-PDF is a locally hosted web application that facilitates various operations on PDF files. Prior to 2.13.2, an authenticated administrator using the default H2 database and security mode can upload a crafted SQL file to POST /api/v1/database/import-database. DatabaseService.validateSqlContent() splits normalized input on semicolons and accepts a statement when it contains any allowed keyword, allowing dangerous H2 functions such as FILE_READ and CSVWRITE, plus CREATE ALIAS, to bypass the insufficient whitelist and execute side effects when RUNSCRIPT processes the file. This permits arbitrary file access. The demonstrated operating-system command execution chain writes attacker-controlled startup files to a user-site location and then triggers an application Python interpreter configured to load those startup files, resulting in command execution as the JVM service account. This issue is fixed in version 2.13.2.

Affected versions

Stirling-PDF versions prior to 2.13.2 are affected; version 2.13.2 (commit d06d3cabaf5b8a7dcd0dbfc584828d8e687e5dd5) fixes the issue by stripping string literals and rejecting DENIED_PATTERNS (CREATE ALIAS, CREATE TRIGGER, CREATE AGGREGATE, CREATE LINKED TABLE, FILE_WRITE, FILE_READ, CSVWRITE, CSVREAD, LINK_SCHEMA, RUNSCRIPT, and SCRIPT TO).

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

Sources

More references from NVD (4)

Mitigation

Two BPF LSM programs return -EPERM to processes whose executable is named java when acting on a file whose name starts with backup_ and ends with .sql inside either Stirling-PDF's stirling-tmp temporary directory or its backup/db backup directory:

Hook Refused
lsm/inode_create Creating a backup_*.sql file in stirling-tmp/ or backup/db/
lsm/file_open Opening a backup_*.sql file in stirling-tmp/ or backup/db/

Refusing backup_*.sql creation and open in stirling-tmp/ stops DatabaseController.importDatabase at Files.createTempFile("backup_", ".sql") before DatabaseService.importDatabaseFromUI() or H2 RUNSCRIPT can read the uploaded SQL. Refusing backup_*.sql in backup/db/ also stops DatabaseController.importDatabaseFromBackupUI and DatabaseService.importDatabase() from executing an existing backup script. Each program tests the first byte of the file name (b) first and returns immediately for other files.

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

Side effects

  • Uploading a database backup to POST /api/v1/database/import-database fails with HTTP 500 because the backup_*.sql temporary file cannot be created.
  • Importing, exporting, or downloading backup_*.sql files in backup/db/ fails while the upatch is loaded.
  • Normal PDF operations and user authentication in Stirling-PDF continue to work, because PDF uploads and conversions use other temporary file prefixes in stirling-tmp/.
  • Not covered: a JVM started with java.io.tmpdir outside a directory named stirling-tmp for the temporary file creation check (though backup/db/ still matches the backup directory layout), or a JVM launcher whose executable is not named java.

Preemption model and cost

The programs keep no state beyond the refused per-CPU counter map, which is updated with an atomic fetch-and-add (__sync_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 start with b, a run costs a single byte read of the dentry name.

The policy

146 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 char first_char(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	char c = 0;

	if (!name || bpf_probe_read_kernel(&c, sizeof(c), name))
		return 0;
	return c;
}

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 current_is_java(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 name_is(exe, "java", 4);
}

static __always_inline bool is_backup_sql(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 head[7] = {};
	char tail[4] = {};

	if (!name || len < 12 || len > 255)
		return false;
	if (bpf_probe_read_kernel(head, sizeof(head), name))
		return false;
	if (head[0] != 'b' || head[1] != 'a' || head[2] != 'c' ||
	    head[3] != 'k' || head[4] != 'u' || head[5] != 'p' ||
	    head[6] != '_')
		return false;
	if (bpf_probe_read_kernel(tail, sizeof(tail), name + len - 4))
		return false;
	return tail[0] == '.' && tail[1] == 's' &&
	       tail[2] == 'q' && tail[3] == 'l';
}

static __always_inline bool in_stirling_tmp(const struct dentry *dentry)
{
	const struct dentry *parent = BPF_CORE_READ(dentry, d_parent);

	return name_is(parent, "stirling-tmp", 12);
}

static __always_inline bool in_db_backup_dir(const struct dentry *dentry)
{
	const struct dentry *dir = BPF_CORE_READ(dentry, d_parent);
	const struct dentry *parent = BPF_CORE_READ(dir, d_parent);

	return name_is(dir, "db", 2) && name_is(parent, "backup", 6);
}

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

SEC("lsm/inode_create")
int BPF_PROG(cve_2026_85714_create, const struct mnt_idmap *idmap,
	     struct inode *dir, struct dentry *dentry, umode_t mode, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (first_char(dentry) != 'b')
		return 0;
	if (!is_backup_sql(dentry))
		return 0;
	if ((!in_stirling_tmp(dentry) && !in_db_backup_dir(dentry)) ||
	    !current_is_java())
		return 0;
	count(REFUSED_CREATE);
	return -EPERM;
}

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

	if (ret)
		return earlier_verdict(ret);
	if (first_char(dentry) != 'b')
		return 0;
	if (!is_backup_sql(dentry))
		return 0;
	if ((!in_stirling_tmp(dentry) && !in_db_backup_dir(dentry)) ||
	    !current_is_java())
		return 0;
	count(REFUSED_OPEN);
	return -EPERM;
}

Process

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

  1. 14 Oct 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #8 openedAdd CVE-2026-85714: Refuses the Stirling-PDF database import SQL file write and openromanlab
  3. 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)
  4. 25 Nov 2026MergeMerged #8romanlab

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

Evidence

On a vulnerable Stirling-PDF 2.13.1 with H2 and login enabled, POST /api/v1/database/import-database wrote backup_*.sql and ran H2 RUNSCRIPT before and after the upatch was loaded (HTTP 200), and was refused with HTTP 500 while the upatch was loaded.

Tested
25 Nov 2026
Target
Stirling-PDF 2.13.1 (Stirling-PDF-with-login.jar) on OpenJDK 21, H2 database, DOCKER_ENABLE_SECURITY=true, loopback only
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Results
StatePOST /api/v1/database/import-database writes backup_*.sql and runs RUNSCRIPT
Before loadingyes (HTTP 200)
Upatch loadedno (HTTP 500)
After unloadingyes (HTTP 200)
tools-test.log Output of tools/test --setup showing the payload reached before, blocked while loaded, and reached after.
tools/test --setup, 2026-11-25T10:16:15Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-85714
  setup   done         STIRLING_URL=http://127.0.0.1:18080 STIRLING_USER=admin STIRLING_PASSWORD=stirling
  before  reached      POST /api/v1/database/import-database wrote backup_*.sql and ran H2 RUNSCRIPT (HTTP 200)
  loaded  blocked      POST /api/v1/database/import-database failed with HTTP 500 when creating backup_*.sql
  after   reached      POST /api/v1/database/import-database wrote backup_*.sql and ran H2 RUNSCRIPT (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-85714
Publish and roll out
shirudo bpm push build/packages/cve-2026-85714-1.0.0.bee oci://<registry>/<namespace>/cve-2026-85714 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-85714-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>