# CVE-2026-87815: SiYuan before v3.8.2 Path Traversal via removeRiffDeck

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

## At a glance

CVE-2026-87815 is rated High 8.4 (CVSS 4.0, CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:H/VA:H/SC:N/SI:H/SA:H/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 SiYuan (siyuan-note) and was published on 9 Sept 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 0.5%: the estimated chance it is exploited in the next 30 days, as of 25 Nov 2026. The upatch `cve-2026-87815-siyuan-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-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.

## What the upatch does

The BPF LSM program `cve_2026_87815_unlink` attaches to `lsm/inode_unlink` and returns `-EPERM` when all of the following hold:

1. The target `dentry` name ends in `.deck` or `.cards`.
2. The target `dentry`'s parent directory is not `storage/riff` (`d_parent` named `riff` under a parent named `storage`).
3. The current task's executable (`task->mm->exe_file->f_path.dentry`) is the SiYuan kernel binary (`kernel`, `SiYuan*`, or `siyuan*`).

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.

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

## Side effects

- A SiYuan kernel process cannot unlink any `.deck` or `.cards` file whose immediate parent directory is not `storage/riff`. When `/api/riff/removeRiffDeck` is called with a path traversal sequence that resolves to an existing `.deck` or `.cards` file outside `storage/riff`, `os.RemoveAll` inside `filelock.Remove` receives `EPERM` (`os.ErrPermission`), which causes `filelock.Remove` to abort the process via `logging.LogFatalf` before any file is deleted.
- Normal flashcard deck creation and removal inside `data/storage/riff` continue 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`.

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

## How it was tested

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

### Results

| State           | Traversal removeRiffDeck deletes .deck outside storage/riff |
| --------------- | ----------------------------------------------------------- |
| Before loading  | yes (HTTP 200)                                              |
| Upatch loaded   | no (blocked with EPERM)                                     |
| 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-87815
```

Publish and roll out:

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

## Review

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

## Sources and links

- [CVE-2026-87815 record (CVE API)](https://cveawg.mitre.org/api/cve/CVE-2026-87815)
- [GitHub Security Advisory GHSA-94vh-rpgr-rpwc](https://github.com/siyuan-note/siyuan/security/advisories/GHSA-94vh-rpgr-rpwc)
- [Fix commit 69de518f6d75](https://github.com/siyuan-note/siyuan/commit/69de518f6d751a3bb0434dc399681ec70153f851)
- [SiYuan v3.8.2 release](https://github.com/siyuan-note/siyuan/releases/tag/v3.8.2)
- [VulnCheck advisory](https://www.vulncheck.com/advisories/siyuan-before-3.8.2-path-traversal-via-removeriffdeck)

### Links

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

### More references from NVD (2)

- [github.com](https://github.com/siyuan-note/siyuan/security/advisories/GHSA-94vh-rpgr-rpwc)
- [vulncheck.com](https://www.vulncheck.com/advisories/siyuan-before-3.8.2-path-traversal-via-removeriffdeck)
