CVE-2026-87815
SiYuan before v3.8.2 Path Traversal via removeRiffDeck
Refuses unlinking .deck and .cards files outside the storage/riff directory by SiYuan to mitigate CVE-2026-87815.
High 8.4Vetted
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-87815 is a high (CVSS 8.4) vulnerability in SiYuan, published 9 September 2026. A vetted upatch, cve-2026-87815-siyuan-block, blocks it on running Linux machines with shirudo until SiYuan is upgraded.
- Severity
- High 8.4 CVSS 4.0
- 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-73
- Affected software
- SiYuan (siyuan-note)
- Upatch status
- Vetted, merged into the registry
- How to apply
- Build, sign and roll out with shirudo
Overview
CVE-2026-87815 (GHSA-94vh-rpgr-rpwc), published on 9 September 2026, is a path traversal vulnerability in SiYuan versions before v3.8.2. In kernel/api/riff.go, the removeRiffDeck handler reads deckID from the JSON request body and passes it directly to model.RemoveDeck in kernel/model/flashcard.go without validating that deckID matches a node ID pattern. RemoveDeck joins the workspace's data/storage/riff directory with deckID + ".deck" and deckID + ".cards" and calls filelock.Remove on each existing file. An authenticated administrator can pass ../ traversal sequences in deckID to delete arbitrary .deck and .cards files outside the data/storage/riff directory, including flashcard data belonging to other workspaces on a shared host.
Official description
SiYuan versions before v3.8.2 contain a path traversal vulnerability in the /api/riff/removeRiffDeck endpoint that fails to validate the deckID parameter. An authenticated administrator can supply path traversal sequences to delete arbitrary .deck and .cards files outside the workspace directory.
Affected versions
Affected software: SiYuan versions before v3.8.2 (fixed in v3.8.2 by commit 69de518f6d751a3bb0434dc399681ec70153f851).
Kernels: Linux kernels with BPF LSM and BTF enabled (lsm/inode_unlink).
Sources
More references from NVD (2)
Mitigation
The BPF LSM program cve_2026_87815_unlink attaches to lsm/inode_unlink and returns -EPERM when all of the following hold:
- The target
dentryname ends in.deckor.cards. - The target
dentry's parent directory is notstorage/riff(d_parentnamedriffunder a parent namedstorage). - The current task's executable (
task->mm->exe_file->f_path.dentry) is the SiYuan kernel binary (kernel,SiYuan*, orsiyuan*).
Legitimate flashcard deck deletions in data/storage/riff/<deckID>.deck and data/storage/riff/<deckID>.cards have parent directory storage/riff and are allowed. Every other process on the system is untouched. Refusals are counted in the refused per-CPU array map at key 0.
Side effects
- A SiYuan kernel process cannot unlink any
.deckor.cardsfile whose immediate parent directory is notstorage/riff. When/api/riff/removeRiffDeckis called with a path traversal sequence that resolves to an existing.deckor.cardsfile outsidestorage/riff,os.RemoveAllinsidefilelock.RemovereceivesEPERM(os.ErrPermission), which causesfilelock.Removeto abort the process vialogging.LogFatalfbefore any file is deleted. - Normal flashcard deck creation and removal inside
data/storage/riffcontinue to work.
Preemption model and cost
The program keeps no shared state beyond the refused per-CPU counter, updated with __sync_fetch_and_add, making it safe under every preemption model including preemptible RCU and PREEMPT_RT. On every inode_unlink call, the program checks the length and last 5 or 6 bytes of dentry->d_name first and returns immediately for any file that does not end in .deck or .cards.
The policy
139 lines of BPF C, attached at lsm/inode_unlink.
// 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";
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
__type(value, __u64);
} refused SEC(".maps");
static __always_inline void count_refused(void)
{
__u32 key = 0;
__u64 *value = bpf_map_lookup_elem(&refused, &key);
if (value)
__sync_fetch_and_add(value, 1);
}
static __always_inline bool is_deck_or_cards(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[6] = {};
if (!name || len < 6 || len > 255)
return false;
if (bpf_probe_read_kernel(tail, 5, name + len - 5) == 0) {
if (tail[0] == '.' && tail[1] == 'd' && tail[2] == 'e' &&
tail[3] == 'c' && tail[4] == 'k')
return true;
}
if (len < 7)
return false;
if (bpf_probe_read_kernel(tail, 6, name + len - 6) == 0) {
if (tail[0] == '.' && tail[1] == 'c' && tail[2] == 'a' &&
tail[3] == 'r' && tail[4] == 'd' && tail[5] == 's')
return true;
}
return false;
}
static __always_inline bool name_eq4(const struct dentry *dentry,
char c0, char c1, char c2, char c3)
{
const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
char buf[4] = {};
if (!dentry || !name || BPF_CORE_READ(dentry, d_name.len) != 4)
return false;
if (bpf_probe_read_kernel(buf, 4, name))
return false;
return buf[0] == c0 && buf[1] == c1 && buf[2] == c2 && buf[3] == c3;
}
static __always_inline bool name_eq7(const struct dentry *dentry,
char c0, char c1, char c2, char c3,
char c4, char c5, char c6)
{
const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
char buf[7] = {};
if (!dentry || !name || BPF_CORE_READ(dentry, d_name.len) != 7)
return false;
if (bpf_probe_read_kernel(buf, 7, name))
return false;
return buf[0] == c0 && buf[1] == c1 && buf[2] == c2 && buf[3] == c3 &&
buf[4] == c4 && buf[5] == c5 && buf[6] == c6;
}
static __always_inline bool is_riff_storage_dir(const struct dentry *dir)
{
const struct dentry *parent;
if (!name_eq4(dir, 'r', 'i', 'f', 'f'))
return false;
parent = BPF_CORE_READ(dir, d_parent);
return name_eq7(parent, 's', 't', 'o', 'r', 'a', 'g', 'e');
}
static __always_inline bool is_siyuan_exe(const struct dentry *exe)
{
const unsigned char *name = BPF_CORE_READ(exe, d_name.name);
__u32 len = BPF_CORE_READ(exe, d_name.len);
char buf[6] = {};
if (!exe || !name || len < 6)
return false;
if (bpf_probe_read_kernel(buf, 6, name))
return false;
if (len == 6 && buf[0] == 'k' && buf[1] == 'e' && buf[2] == 'r' &&
buf[3] == 'n' && buf[4] == 'e' && buf[5] == 'l')
return true;
if (buf[0] == 'S' && buf[1] == 'i' && buf[2] == 'Y' &&
buf[3] == 'u' && buf[4] == 'a' && buf[5] == 'n')
return true;
if (buf[0] == 's' && buf[1] == 'i' && buf[2] == 'y' &&
buf[3] == 'u' && buf[4] == 'a' && buf[5] == 'n')
return true;
return false;
}
static __always_inline bool current_is_siyuan(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 is_siyuan_exe(exe);
}
static __always_inline int earlier_verdict(int ret)
{
return ret >= -4095 && ret < 0 ? ret : -EPERM;
}
SEC("lsm/inode_unlink")
int BPF_PROG(cve_2026_87815_unlink, struct inode *dir, struct dentry *dentry,
int ret)
{
if (ret)
return earlier_verdict(ret);
if (!is_deck_or_cards(dentry))
return 0;
if (is_riff_storage_dir(BPF_CORE_READ(dentry, d_parent)))
return 0;
if (!current_is_siyuan())
return 0;
count_refused();
return -EPERM;
}
The package: name, license, the program and the CVE it fixes.
[package]
name = "cve-2026-87815"
description = "Refuses unlinking .deck and .cards files outside the storage/riff directory by SiYuan to mitigate CVE-2026-87815"
license = "GPL-2.0 OR BSD-2-Clause"
[[upatches]]
source = "cve-2026-87815-siyuan-block.bpf.c"
[upatches.tree]
id = "cve-2026-87815-siyuan-block"
fixes = ["CVE-2026-87815"]
Process
How this upatch was written, checked and reviewed, from the registry’s history.
- 9 Sept 2026CVECVE published
- 25 Nov 2026Pull requestPull request #100 openedAdd CVE-2026-87815: Refuses unlinking .deck and .cards files outside the storage/riff directory byromanlab
- 25 Nov 2026CICheck entriespassed
- 25 Nov 2026CIingestpassed
- 25 Nov 2026CICompile with clang 23passed
- 25 Nov 2026MergeMerged #100romanlab
No human review is recorded on GitHub for this upatch yet.
Evidence
On a vulnerable SiYuan 3.8.1 kernel server, the loaded upatch refused path traversal deletion of a .deck file outside storage/riff via /api/riff/removeRiffDeck, while before loading and after unloading the traversal request deleted the file.
- Tested
- 25 Nov 2026
- Target
- SiYuan 3.8.1 kernel server listening on 127.0.0.1:6806
- Kernel
- 7.4-shirudo-ci-20261123
- Architecture
- x86_64
- Distribution
- Ubuntu 26.04
| State | Traversal removeRiffDeck deletes .deck outside storage/riff |
|---|---|
| Before loading | yes (HTTP 200) |
| Upatch loaded | no (blocked with EPERM) |
| After unloading | yes (HTTP 200) |
tools-test.log Output of tools/test --setup showing the payload reached before, blocked while the upatch was loaded, and reached again after unloading.
tools/test --setup, 2026-11-25T16:19:55Z Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm cve-2026-87815 setup done SIYUAN_URL=http://127.0.0.1:6806 SIYUAN_WORKSPACE=/opt/upatch-payload/cve-2026-87815/workspace before reached removeRiffDeck deleted upatch-probe-4a91c272da95.deck outside storage/riff (HTTP 200) loaded blocked the upatch refused unlinking upatch-probe-4cda40d51430.deck with EPERM and left it intact after reached removeRiffDeck deleted upatch-probe-09d7cbe56e6d.deck outside storage/riff (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.
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-87815shirudo bpm push build/packages/cve-2026-87815-1.0.0.bee oci://<registry>/<namespace>/cve-2026-87815 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-87815-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>