upatch.dev

CVE-2026-90774

rustypaste before 0.18.1 Path Traversal via filename header

Refuses rustypaste file writes outside its upload directories to mitigate CVE-2026-90774.

High 8.7Vetted

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

At a glance

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

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

Overview

CVE-2026-90774 is a path traversal vulnerability in rustypaste versions before 0.18.1, published on 13 September 2026. In Paste::store_file (src/paste.rs), rustypaste validates the initial upload filename against the upload directory with util::safe_path_join, and then applies the optional custom filename HTTP request header with path.set_file_name(file_name) without re-running util::safe_path_join. An attacker who sends a POST / multipart upload with ../ traversal sequences in the filename header escapes the upload directory and causes File::create(&path) (and, for protected pastes, password::store_password_hash) to create or truncate and overwrite arbitrary files that the rustypaste process can write.

Official description

rustypaste before 0.18.1 validates the destination path before applying the optional custom filename HTTP header, allowing attackers to bypass directory-escape checks. Attackers can supply path traversal sequences in the filename header to write files outside the configured upload directory to arbitrary locations.

Affected versions

rustypaste:

Versions Status
< 0.18.1 (including 0.18.0) Affected
>= 0.18.1 Fixed

Kernels: the inode_create and inode_setattr LSM hooks use the const struct mnt_idmap * first parameter present in mainline Linux kernels with idmapped mounts.

Sources

More references from NVD (5)

Mitigation

Three BPF LSM programs return -EPERM to processes whose executable is named rustypaste when the target dentry is not directly inside a directory named upload or one of its four paste-type subdirectories (upload/url, upload/oneshot, upload/oneshot_url, upload/protected):

Hook Refused
lsm/inode_create Creating a new regular file outside upload/ and its four paste subdirectories
lsm/file_open Opening an existing file with FMODE_WRITE outside upload/ and its four paste subdirectories
lsm/inode_setattr Truncating (ATTR_SIZE) an existing file outside upload/ and its four paste subdirectories

Together, these three hooks cover both new files (inode_create) and existing files opened with O_CREAT | O_WRONLY | O_TRUNC by std::fs::File::create (file_open and inode_setattr). Each program checks the cheapest condition first (FMODE_WRITE on file_open, ATTR_SIZE on inode_setattr, then the executable name rustypaste) and returns 0 for all other processes. Any negative return value from an earlier BPF LSM program on the same hook is preserved.

The refused per-CPU array counts refusals: key 0 for inode_create, key 1 for file_open, and key 2 for inode_setattr.

Side effects

  • Any upload whose filename header resolves outside upload/ (or its url, oneshot, oneshot_url, protected subdirectories) fails with HTTP 403 (Forbidden, from ErrorKind::PermissionDenied when the kernel returns -EPERM) instead of writing the file.
  • Normal file uploads (file, oneshot, remote, protected), URL shortener pastes (url, oneshot_url), custom filename headers that stay inside upload/, file serving, oneshot file renames, and file deletions continue to work when upload_path is named upload (the default ./upload).
  • Not covered or restricted: a deployment that renames upload_path to a directory whose final component is not upload will have its uploads refused while the upatch is loaded, and a binary renamed away from rustypaste is not matched.

Preemption model and cost

The programs keep no shared state beyond the per-CPU refused counter, which is updated with __sync_fetch_and_add, so they are safe under every preemption model including PREEMPT_LAZY, PREEMPT_DYNAMIC and PREEMPT_RT. On file_open and inode_setattr, read-only opens and non-size attribute changes return after a single bit test on the hook's arguments; on inode_create and write paths, non-rustypaste processes return after comparing the current task's executable dentry length and name.

The policy

126 lines of BPF C, attached at lsm/inode_create and lsm/file_open and lsm/inode_setattr.

// 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 FMODE_WRITE	0x2
#define ATTR_SIZE	0x8

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

enum {
	REFUSED_CREATE,
	REFUSED_OPEN,
	REFUSED_SETATTR,
	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[16] = {};

	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_rustypaste(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, "rustypaste", 10);
}

static __always_inline bool is_paste_subdir(const struct dentry *dir)
{
	return name_is(dir, "url", 3) ||
	       name_is(dir, "oneshot", 7) ||
	       name_is(dir, "protected", 9) ||
	       name_is(dir, "oneshot_url", 11);
}

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

	if (name_is(parent, "upload", 6))
		return true;
	if (!is_paste_subdir(parent))
		return false;
	return name_is(BPF_CORE_READ(parent, d_parent), "upload", 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_90774_create, const struct mnt_idmap *idmap,
	     struct inode *dir, struct dentry *dentry, umode_t mode, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (!current_is_rustypaste() || in_upload_dir(dentry))
		return 0;
	count(REFUSED_CREATE);
	return -EPERM;
}

SEC("lsm/file_open")
int BPF_PROG(cve_2026_90774_open, struct file *file, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (!(file->f_mode & FMODE_WRITE))
		return 0;
	if (!current_is_rustypaste() || in_upload_dir(file->f_path.dentry))
		return 0;
	count(REFUSED_OPEN);
	return -EPERM;
}

SEC("lsm/inode_setattr")
int BPF_PROG(cve_2026_90774_setattr, const struct mnt_idmap *idmap,
	     struct dentry *dentry, struct iattr *attr, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (!(attr->ia_valid & ATTR_SIZE))
		return 0;
	if (!current_is_rustypaste() || in_upload_dir(dentry))
		return 0;
	count(REFUSED_SETATTR);
	return -EPERM;
}

Process

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

  1. 13 Sept 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #18 openedAdd CVE-2026-90774: Refuses rustypaste file writes outside its upload directoriesromanlab
  3. 25 Nov 2026MergeMerged #18romanlab
  4. 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)

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

Evidence

On rustypaste 0.18.0, the loaded upatch refused a multipart upload whose filename header traversed out of the upload directory (HTTP 403), while normal uploads into the upload directory continued to succeed (HTTP 200).

Tested
25 Nov 2026
Target
rustypaste 0.18.0 with upload_path=./upload, listening on 127.0.0.1:8000
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Distribution
Ubuntu 26.04
Results
StatePath traversal via filename header writes outside upload/Normal upload into upload/
Before loadingyes (HTTP 200)200
Upatch loadedno (HTTP 403)200
After unloadingyes (HTTP 200)200
tools-test.log Output of tools/test --setup before, while and after the upatch was loaded.
tools/test --setup, 2026-11-25T10:42:31Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-90774
  setup   done         RUSTYPASTE_URL=http://127.0.0.1:8000 RUSTYPASTE_UPLOAD_DIR=/opt/upatch-payload/cve-2026-90774/upload
  before  reached      filename header ../ wrote upatch-probe-8d2a4c0f493d.txt outside upload directory (HTTP 200); removed it
  loaded  blocked      traversal upload failed with HTTP 403 and wrote no file while normal upload succeeded
  after   reached      filename header ../ wrote upatch-probe-92a507e53683.txt outside upload directory (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-90774
Publish and roll out
shirudo bpm push build/packages/cve-2026-90774-1.0.0.bee oci://<registry>/<namespace>/cve-2026-90774 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-90774-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>