upatch.dev

CVE-2026-93712

Dancer2 versions from 2.1.0 before 2.2.0 for Perl serve files from outside public_dir via relative path segments in the File route handler

Refuses Perl path traversal through a public directory to mitigate CVE-2026-93712 in Dancer2.

High 7.5Vetted

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

At a glance

CVE-2026-93712 is a high (CVSS 7.5) vulnerability in Dancer2, published 22 September 2026. A vetted upatch, cve-2026-93712-dancer2-block, blocks it on running Linux machines with shirudo until Dancer2 is upgraded.

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

Overview

CVE-2026-93712, published on 22 September 2026, is a path traversal vulnerability in Dancer2::Handler::File (lib/Dancer2/Handler/File.pm) in Dancer2 versions from 2.1.0 before 2.2.0 for Perl. The handler joins public_dir with the request's path_info using Path::Tiny::path without collapsing relative .. segments or checking that the resolved path stays within public_dir. Because its 403 guard tested Path::Tiny::stringify for undef, which is never returned, the handler checked only -f and -r and then served the file with slurp_raw. When an application enables the File route handler in route_handlers and disables the default static middleware with static_handler: 0 (which otherwise wraps the app in Plack::App::File and rejects .. segments), an unauthenticated GET or HEAD request such as /../secret.txt or percent-encoded /%2e%2e/secret.txt can read any regular file on the filesystem that the worker process can read.

Official description

Dancer2 versions from 2.1.0 before 2.2.0 for Perl serve files from outside public_dir via relative path segments in the File route handler. The handler joins the request path onto public_dir without collapsing relative segments, and checks only that the result is a readable regular file. A request for `/../outside.txt` escapes public_dir, and percent-encoding the dots reaches the same file. The handler is off by default. An application is affected once it names File in route_handlers and sets static_handler to 0, which otherwise refuses a dot segment before the route runs. Any file the worker process can read is served to an unauthenticated request, including the application's config.yml above public_dir.

Affected versions

Application versions:

Package Affected Fixed in
Dancer2 (CPAN) 2.1.0 to before 2.2.0 2.2.0

Kernels: any Linux kernel supported by shirudo with BPF LSM and BTF enabled where task_struct->nameidata points to the active struct nameidata during path walks.

Sources

More references from NVD (4)

Mitigation

Two BPF LSM programs return -EPERM when a Perl worker process (perl, plackup, or starman by command name or perl* executable) performs a filesystem lookup whose active task->nameidata pathname enters public/ (at the start of a relative path or after /) and subsequently contains a /.. segment:

Hook Refused
lsm/inode_getattr stat (-f check) on a pathname with a .. segment after public/
lsm/file_open Opening a file along a pathname with a .. segment after public/

Refusing lsm/inode_getattr and lsm/file_open stops Dancer2::Handler::File from reading files reached via .. segments out of public/ (slurp_raw fails with EPERM, returning HTTP 500) without disclosing the target file's contents.

The refused per-CPU array counts refusals at key 0 for inode_getattr and key 1 for file_open.

Side effects

  • Any stat or open by a Perl process using an uncollapsed pathname that contains public/ followed by a .. path component fails with EPERM.
  • Requests to a vulnerable Dancer2::Handler::File route that traverse .. out of public/ fail with HTTP 404 or HTTP 500 (whereas Dancer2 2.2.0 answers HTTP 403 after resolving realpath).
  • Serving files inside public/ without .. segments, and application routes that access files outside public/ directly without walking through public/.., continue to work normally.
  • Not covered: an application whose public_dir directory is named something other than public, or a path where public/ lies deeper than the first 246 bytes of the lookup pathname.

Preemption model and cost

The programs are written for preemptible RCU (PREEMPT_LAZY, PREEMPT_DYNAMIC, and PREEMPT_RT). They keep no shared state beyond the refused per-CPU counter map, which is updated with an atomic fetch-and-add. On every inode_getattr and file_open call, non-Perl tasks and calls outside a nameidata lookup return immediately after checking task->nameidata, the 16-byte task->comm, and the executable dentry name. Only Perl path lookups read up to 256 bytes of the kernel filename buffer.

The policy

163 lines of BPF C, attached at lsm/inode_getattr 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
#define PATH_BUF 256
#define SCAN_MAX 246

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

enum {
	REFUSED_GETATTR,
	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 int earlier_verdict(int ret)
{
	return ret >= -4095 && ret < 0 ? ret : -EPERM;
}

static __always_inline bool is_perl_comm(const struct task_struct *task)
{
	char comm[8] = {};

	if (bpf_probe_read_kernel(comm, sizeof(comm), &task->comm))
		return false;
	if (comm[0] == 'p' && comm[1] == 'e' && comm[2] == 'r' && comm[3] == 'l')
		return true;
	if (comm[0] == 'p' && comm[1] == 'l' && comm[2] == 'a' &&
	    comm[3] == 'c' && comm[4] == 'k' && comm[5] == 'u' &&
	    comm[6] == 'p')
		return true;
	if (comm[0] == 's' && comm[1] == 't' && comm[2] == 'a' &&
	    comm[3] == 'r' && comm[4] == 'm' && comm[5] == 'a' &&
	    comm[6] == 'n')
		return true;
	return false;
}

static __always_inline bool is_perl_exe(const struct task_struct *task)
{
	const struct dentry *exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);
	const unsigned char *name = BPF_CORE_READ(exe, d_name.name);
	__u32 len = BPF_CORE_READ(exe, d_name.len);
	char buf[5] = {};

	if (!name || len < 4)
		return false;
	if (bpf_probe_read_kernel(buf, sizeof(buf), name))
		return false;
	if (buf[0] != 'p' || buf[1] != 'e' || buf[2] != 'r' || buf[3] != 'l')
		return false;
	return len == 4 || (buf[4] >= '0' && buf[4] <= '9');
}

static __always_inline bool task_is_perl(const struct task_struct *task)
{
	return is_perl_comm(task) || is_perl_exe(task);
}

static __always_inline const char *lookup_pathname(const struct task_struct *task)
{
	const char *pathname = BPF_CORE_READ(task, nameidata, pathname);
	const struct __filename_head *fn;

	if (pathname)
		return pathname;
	fn = (const struct __filename_head *)BPF_CORE_READ(task, nameidata, name);
	if (!fn)
		return NULL;
	return BPF_CORE_READ(fn, name);
}

static __always_inline bool has_public_dotdot(const struct task_struct *task)
{
	const char *pathname = lookup_pathname(task);
	char buf[PATH_BUF] = {};
	bool seen_public = false;
	int n;

	if (!pathname)
		return false;
	n = bpf_probe_read_kernel_str(buf, sizeof(buf), pathname);
	if (n < 10)
		return false;
	if (buf[0] == 'p' && buf[1] == 'u' && buf[2] == 'b' &&
	    buf[3] == 'l' && buf[4] == 'i' && buf[5] == 'c' &&
	    buf[6] == '/')
		seen_public = true;
	for (__u32 i = 0; i < SCAN_MAX; i++) {
		char c = buf[i];

		if (!c)
			break;
		if (c != '/')
			continue;
		if (!seen_public &&
		    buf[i + 1] == 'p' && buf[i + 2] == 'u' &&
		    buf[i + 3] == 'b' && buf[i + 4] == 'l' &&
		    buf[i + 5] == 'i' && buf[i + 6] == 'c' &&
		    buf[i + 7] == '/') {
			seen_public = true;
			continue;
		}
		if (seen_public &&
		    buf[i + 1] == '.' && buf[i + 2] == '.' &&
		    (buf[i + 3] == '/' || buf[i + 3] == '\0'))
			return true;
	}
	return false;
}

SEC("lsm/inode_getattr")
int BPF_PROG(cve_2026_93712_getattr, const struct path *path, int ret)
{
	struct task_struct *task;

	if (ret)
		return earlier_verdict(ret);
	task = bpf_get_current_task_btf();
	if (!task->nameidata || !task_is_perl(task))
		return 0;
	if (!has_public_dotdot(task))
		return 0;
	count(REFUSED_GETATTR);
	return -EPERM;
}

SEC("lsm/file_open")
int BPF_PROG(cve_2026_93712_open, struct file *file, int ret)
{
	struct task_struct *task;

	if (ret)
		return earlier_verdict(ret);
	task = bpf_get_current_task_btf();
	if (!task->nameidata || !task_is_perl(task))
		return 0;
	if (!has_public_dotdot(task))
		return 0;
	count(REFUSED_OPEN);
	return -EPERM;
}

Process

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

  1. 22 Sept 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #83 openedAdd CVE-2026-93712: Refuses Perl path traversal through a public directory to mitigateromanlab
  3. 25 Nov 2026CIUpdate upatch.devpassed
  4. 25 Nov 2026CICIpassed
  5. 25 Nov 2026MergeMerged #83romanlab

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

Evidence

On a vulnerable Dancer2 2.1.0 application with the File route handler enabled and static_handler set to 0, the loaded upatch refused ../outside.txt traversal out of public/ (HTTP 500) while normal static requests for /hello.txt under public/ kept returning HTTP 200.

Tested
25 Nov 2026
Target
Dancer2 2.1.0 on Perl with route_handlers File and static_handler=0, listening on 127.0.0.1:5000
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Distribution
Ubuntu 26.04
Results
StateTraversal outside public_dir blockedNormal public file /hello.txt served
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 reaching ../outside.txt before and after loading and being blocked while loaded.
tools/test --setup, 2026-11-25T14:37:27Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-93712
  setup   done         DANCER2_URL=http://127.0.0.1:5000
  before  reached      Dancer2::Handler::File served ../outside.txt outside public_dir (HTTP 200)
  loaded  blocked      traversal to ../outside.txt was refused (HTTP 500) while /hello.txt returned HTTP 200
  after   reached      Dancer2::Handler::File served ../outside.txt outside public_dir (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-93712
Publish and roll out
shirudo bpm push build/packages/cve-2026-93712-1.0.0.bee oci://<registry>/<namespace>/cve-2026-93712 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-93712-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>