llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Go · github.com/siyuan-note/siyuan/kernel

GHSA-9G6V-R3XF-673Q

Incomplete fix for GHSA-c8r8-95hg-mp34: recursive MCP file operations bypass the sensitive-path guard

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
6.5
Media
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición70 dDesde la divulgación, 11 sept 2026, 3:12 a. m.
Detección70 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Modificada
Explotación
Remediación
Monitoreo
Detectada +1
11 sept 26
7 oct 26
20 nov 26
11 sept 26
28 sept 26
16 oct 26
3 nov 26
20 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-9G6V-R3XF-673Q divulgada · CVSS 6.5 (GitHub)
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Private advisory report

Proposed title

Incomplete fix for GHSA-c8r8-95hg-mp34: recursive MCP file operations bypass the sensitive-path guard

Suggested metadata

| Field | Value |
|---|---|
| Ecosystem | Go |
| Package | `github.com/siyuan-note/siyuan/kernel` |
| Confirmed affected versions | `>= 3.8.0, <= 3.8.3` |
| Patched versions | None observed as of `origin/dev` commit `2ecc048a5cd84a205cc56fc54cba58a29f3e7be5` |
| Severity | Moderate |
| CVSS v3.1 | `CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:N` — 6.5 |
| Primary CWE | CWE-863: Incorrect Authorization |
| Secondary CWE | CWE-200: Exposure of Sensitive Information to an Unauthorized Actor |

The vector combines the confirmed read and overwrite consequences. It retains the parent advisory's network, complexity, privilege, interaction, and scope metrics, while changing integrity from none to high for the confirmed archive-member overwrite. The confidentiality-only variant is the parent's 4.9 vector: `CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N`.

The 6.5 score is anchored to the parent advisory for comparability. Because the same administrator credential has broader raw-file HTTP APIs, the maintainer may reasonably score the external-MCP path lower; the primary residual risk is the in-app Agent path where protected grep results reach the model without a default per-call confirmation.

Summary

The fix for `GHSA-c8r8-95hg-mp34` centralized SiYuan's protected-workspace-file denylist in `util.IsForbiddenAbsPath()` and called it from the MCP file tool's `resolvePath()`. A direct MCP file operation against `conf/conf.json`, TLS keys, `data/snippets/conf.json`, `data/templates/`, `data/.siyuan/publishAccess.json`, notebook `.siyuan` internals, or the kernel log is rejected.

Three recursive operations validate only an allowed root and then access descendants without applying the guard to each final path:

  • `file.grep` can return matching lines from non-hidden protected descendants.
  • `file.copy` can copy protected descendants to an ordinary path, after which `file.read` permits them.
  • `unzip` can overwrite protected descendants using ordinary, lexically contained ZIP member names.

The exact v3.8.3 handlers reproduced all three behaviors with synthetic data under `t.TempDir()`. Direct protected access failed, safe operations succeeded, and a modeled per-member authorization check prevented the archive overwrite, providing negative and causal controls.

Security boundary and reachability

This report concerns SiYuan's explicit native MCP/Agent capability boundary, not an elevation from administrator to operating-system privilege.

There are two relevant call paths:

  1. In-app Agent. Native tools are registered with their real model names (`file` and `unzip`) and source `native`. The live execution loop calls `capabilityConfirmRequirement()` and `needsCapabilitySnapshot()` before invoking a handler. Because `grep` is globally classified as a safe action, `file.grep` receives neither a per-call confirmation nor a local repository snapshot. `file.copy` and `unzip` do receive both, but their confirmation card contains only the allowed root arguments, not the protected descendants later opened or created.
  2. External MCP. `kernel/mcp/server.go::Serve()` registers `POST`, `GET`, and `DELETE /mcp` with `model.CheckAuth` and `model.CheckAdminRole`; mutating methods also use `model.CheckReadonly`. Unless exposure policy disables the tool, `kernel/mcp/server.go::syncGuardedTool()` validates arguments and invokes `tool.Handler(arguments)` directly. It does not pass through the in-app Agent confirmation layer.

The administrator caveat is material: the generic raw-file HTTP APIs grant broad administrator powers. In v3.8.3, `/api/file/getFile` applies `refuseToAccess()` only to non-admin contexts, and `/api/file/putFile` does not apply `IsForbiddenAbsPath()`. Therefore this report does not claim that the external MCP path provides more privilege than the same administrator credential could exercise through all other APIs. The claimed boundary is narrower: SiYuan intentionally denies these paths to the MCP/Agent file capability, and the published parent advisory treats bypass of that denylist as a vulnerability. For the in-app path, the consequence includes returning protected configuration content to the Agent/model despite the direct tool denial and without a per-call prompt.

Sink scope and evidence matrix

| Sink | Protected descendants reached | Evidence level | Consequence | In-app Agent control | External MCP control |
|---|---|---|---|---|---|
| `file.grep` | Non-hidden descendants only: for example `conf/conf.json`, `conf/*.key`, `data/snippets/conf.json`, and `data/templates/**`. Gulu skips directories whose names begin with `.`, so this path does not reach `.siyuan` trees. | Executed for synthetic `conf/conf.json`; other non-hidden denylisted targets follow by construction from the same walker and guard list. | Returns full matching lines, demonstrated with synthetic access-code, API-token, and cookie-key markers. | No confirmation or snapshot under the default risk policy tested; an explicit configured confirm rule can add a forced prompt. | Admin authentication; no Agent confirmation layer. |
| `file.copy` | Recursive directory children, including hidden directories such as `.siyuan`, because `os.ReadDir`/`copyPath` do not skip them. | Executed for synthetic `conf/conf.json`; hidden-target reachability follows by construction from `os.ReadDir`/`copyPath`. | Copies a protected file to an unprotected path that normal `file.read` accepts. | Confirmation and snapshot for the allowed roots, but no descendant authorization. | Admin authentication; no Agent confirmation layer. |
| `unzip` | Any protected final path lexically contained below the selected workspace destination, including hidden `.siyuan` names. | Executed for synthetic `conf/conf.json`; other protected destinations follow by construction from final member joining and the guard list. | Overwrites an existing protected file. | Confirmation and snapshot for ZIP/destination roots, but no member-level authorization. | Admin authentication; no Agent confirmation layer. |

Delete, rename, recursive listing, and find are not confirmed findings in this report. Ancestor-aware handling for them is recommended as untested hardening because they share the container-authorization pattern or expose protected names, but no destructive delete/rename probe was run.

Technical details

Intended final-path guard

`kernel/mcp/tools/file.go::resolvePath()` performs workspace containment, encrypted-notebook, symlink, and sensitive-path checks. Its final-path check is explicit:

if util.IsForbiddenAbsPath(abs) {
    return "", fmt.Errorf("access to sensitive workspace file is forbidden: %s", rel)
}

`kernel/util/path_guard.go` identifies the protected paths listed above. Direct `file.read("conf/conf.json")` reaches this guard and fails in the attached test.

Recursive grep

`fileGrep()` resolves only the caller's root and delegates traversal:

abs, err := resolvePath(p) // "conf" is allowed
// ...
results, err := gulu.File.Grep(abs, include, pattern, ctx, max)

The pinned dependency `github.com/88250/gulu v1.2.3-0.20260831011033-1a37069fad34` uses `filepath.WalkDir`, then opens each regular descendant in `grepFile`; it provides no SiYuan authorization callback. It skips hidden directories, which is reflected in the sink matrix rather than overclaimed.

Recursive copy

`fileCopy()` applies `resolvePath()` to `src` and `dst` only. `copyDir()` recursively joins child names, and `copyFile()` opens/creates those final paths without returning them to the authorization helper. Copying allowed `conf/` to an ordinary data directory therefore clones protected `conf/conf.json`, and the copy no longer matches the denylist.

Archive-member overwrite

`unzipHandler()` resolves `zipPath` and `destPath`, then delegates all members:

zipAbs, err := resolvePath(zipPath)
// ...
destAbs, err := resolvePath(destPath)
// ...
err = gulu.Zip.Unzip(zipAbs, destAbs)

The pinned Gulu implementation joins each member to the destination, verifies lexical containment, creates parents, and calls `os.Create()` on the final path. It does not invoke SiYuan's sensitive/encrypted-path guard. The proof uses member `conf.json` with destination `conf`; it needs no `..`, absolute path, symlink, race, or outside-workspace write.

This is also why `GHSA-p23f-cm6q-2qp8` is a useful novelty cross-check: that advisory cites `unzipHandler` as a safe contrast because it calls `resolvePath()`. The present finding is the missing next step—authorization of each protected member below an otherwise allowed destination.

Synthetic proof and controls

The attached Go overlay runs the real v3.8.3 package-private handlers without adding files to the release worktree. It changes SiYuan path globals only to resolved `t.TempDir()` locations and uses only `SYNTHETIC-*` content.

From the exact release worktree's `kernel/` directory:

go test -overlay=/ABSOLUTE/PATH/poc/overlay.json ./mcp/tools -run '^TestSecurityProbe' -count=1 -v
go test -overlay=/ABSOLUTE/PATH/poc/overlay.json ./agent -run '^TestSecurityProbe' -count=1 -v

Confirmed assertions:

  1. Direct `file.read` of `conf/conf.json` rejects the path.
  2. Recursive `file.grep` rooted at `conf` returns all synthetic secret markers.
  3. Directory copy from `conf` succeeds, and the copied marker is readable.
  4. Recursive grep of an ordinary data file succeeds as a negative control.
  5. Direct resolution and a modeled per-member preflight both reject the protected archive member.
  6. The unmodified `unzipHandler` nevertheless overwrites the synthetic protected file.
  7. A harmless archive extracts normally as a negative control.
  8. A production-registration test constructs the real capability set, verifies native `file`/`unzip` registrations, and passes them through `capabilityConfirmRequirement()` and `needsCapabilitySnapshot()`: grep has neither control; copy and unzip have both.

All assertions pass. The overlay content, portable mapping template, exact commands, toolchain, dependency pins, and hashes are included in the evidence package.

The Agent probe calls `buildCapabilitySet(nil, capabilityAccessContext{})` and `capabilityConfirmRequirement(..., false, nil)`: no frontend capabilities, a zero-value access context, session-wide approval disabled, and no per-tool allowlist. With a nil/unconfigured application approval policy, SiYuan returns its default `risk` decision and reaches the global safe-action classification. An explicit configured `confirm` policy can add a forced grep prompt, while session or tool allowlists can remove prompts; the no-confirmation claim is therefore for the tested default/unconfigured policy, not every possible administrator override.

Impact

The confirmed confidentiality impact is selective disclosure of protected configuration lines and complete recovery through the copy-then-read path. `conf/conf.json` may contain the workspace access credential, API token, cookie signing key, account/sync/AI settings, secrets, variables, and related configuration. The guard also explicitly covers other sensitive locations.

The confirmed integrity impact is overwrite of protected files inside the workspace. The test proves persistent replacement of synthetic protected configuration bytes. Such targets include configuration, publish-access rules, snippet configuration, templates, and notebook metadata.

No downstream JavaScript/template execution, credential activation, authentication bypass, service reload/restart, or availability consequence was tested. Code execution is not claimed. The report also does not rely on traversal, outside-workspace writes, symlink races, or real secrets.

Root cause

Authorization of a container path is incorrectly treated as authorization of every descendant later traversed, copied, or created below it. `resolvePath()` is correct for one final path; callers are unsafe when that path is only a recursive root or extraction destination.

The parent remediation commit `3542530` changed the exact-path check inside `resolvePath()` and added final-path tests. It did not add recursive-root/descendant controls or put a pre-open/pre-create authorization hook at these sinks.

Affected versions and current status

The relevant MCP operations existed before v3.8.0, but earlier releases also had the broader direct-read exposure covered by the parent advisories. This incomplete-fix report therefore conservatively claims `>= 3.8.0, <= 3.8.3`.

Confirmed release commit: `8641553a1f07374001902d3ce773285db1292b2d` (`v3.8.3`). At 2026-09-11 13:55 KST, the three relevant SiYuan files remained byte-identical at `origin/dev` commit `2ecc048a5cd84a205cc56fc54cba58a29f3e7be5`; no patch was observed there.

Suggested fix

  1. Add one operation-aware final-path authorization helper that can be called before every file open/create and that enforces workspace containment, encrypted-notebook rules, symlink policy, and `IsForbiddenAbsPath()`.
  2. Replace or wrap Gulu grep with a guarded walk. Validate each candidate before opening it; safely skip a denied child rather than returning its content.
  3. Preflight the complete copy tree, checking every source and final destination before copying anything. This avoids both protected reads/writes and partial output on rejection.
  4. Enumerate and normalize all archive members, retain lexical containment checks, reject symlink/special entries, and validate every final output before extraction. A staging directory plus all-member preflight avoids partial overwrite.
  5. Add regression tests for direct denial, allowed-parent recursive denial, hidden-directory scope, safe sibling success, directory-copy denial, malicious-member denial, and harmless-archive success.
  6. As untested defense in depth, make delete/rename ancestor-aware and review list/find behavior.
  7. Declare per-action `ToolEffects` for native file operations rather than relying only on globally shared action strings. This improves prompts/snapshots but does not replace descendant authorization.

Scope and safety

  • Confirmed locally on exact v3.8.3 source and synthetic temporary files only.
  • No kernel build, restart, listener, public scan, third-party target, customer data, real credential, or destructive delete/rename test.
  • The repository's authenticated private-report form showed no human-only/AI prohibition; this report was submitted through that private route.
  • No public issue, pull request, gist, advisory, or disclosure was created. This private advisory report is the only disclosure.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:H
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:N
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
github.com/siyuan-note/siyuan/kernel≥ 3.8.0 ≤ 3.8.3
3.8.0
3.8.3
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Gogithub.com/siyuan-note/siyuan/kernel
Sin parche — — —
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/siyuan-note/siyuan/security/advisories/GHSA-9g6v-r3xf-673q

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.