Skip to content

security: isPathSafe must not allow sibling-prefix directory escapes - #18

Merged
Baldri merged 1 commit into
mainfrom
claude/session/fix/mingly-ispathsafe-prefix
Aug 22, 2026
Merged

security: isPathSafe must not allow sibling-prefix directory escapes#18
Baldri merged 1 commit into
mainfrom
claude/session/fix/mingly-ispathsafe-prefix

Conversation

@Baldri

@Baldri Baldri commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Was

isPathSafe() — die Prüfung hinter dem Granted-Directory-Modell — erlaubte Sibling-Prefix-Escapes.

Warum

resolved.startsWith(allowed) ist der klassische Prefix-Bug: ein Geschwisterverzeichnis mit gleichem Namenspräfix (z.B. /a/photos-evil bei einem Grant auf /a/photos) bestand die Prüfung. file-access-manager (Read/Write/List) gatet an allen drei Stellen darauf → Zugriff ausserhalb des gewährten Bereichs.

Änderungen

  • isPathSafe: Pfad muss das Grant-Verzeichnis sein oder mit ihm plus Separator beginnen.
  • Test (rot vor Fix): tests/unit/file-access-types.test.ts — Sibling-Prefix-Escape, In-Grant-Zugriff, Traversal-nach-aussen.

Tests

vitest run tests/unit/file-access-types.test.ts: 5/5. tsc -p tsconfig.main.json clean.

Review-Punkte / Follow-up

  • Der READ_FILE-IPC-Handler prüft nur Länge/..-Muster (validateFilePath), nicht gegen die Granted-Dirs — kann jeden absoluten Pfad lesen. Das ist ein separater, verhaltensändernder Fix (READ_FILE durch das Granted-Dir-Modell routen).

Dokumentation

Security-Audit-Bericht (2026-08-21), Mingly Low-Finding (path-traversal).

🤖 Generated with Claude Code

isPathSafe() — the check behind the granted-directory permission model
(file-access-manager reads/writes/lists all gate on it) — used a bare
resolved.startsWith(allowed). A sibling directory that shares the name prefix,
e.g. /a/photos-evil for a grant on /a/photos, passed the check and could be
read or written outside the granted scope.

Require the path to equal the granted directory or start with it plus a path
separator. Test (red before fix): tests/unit/file-access-types.test.ts covers
the sibling-prefix escape, in-grant access, and a traversal that resolves out.

Follow-up: the READ_FILE IPC handler validates only length / '..' patterns
(input-validator.validateFilePath) and does not constrain to a granted
directory — it should route through the granted-dir model too (separate change,
behaviour-affecting).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Baldri
Baldri merged commit 241cc5f into main Aug 22, 2026
10 checks passed
@Baldri
Baldri deleted the claude/session/fix/mingly-ispathsafe-prefix branch August 22, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant