Skip to content

security: constrain READ_FILE to granted dirs; validate command paths before basename - #20

Closed
Baldri wants to merge 1 commit into
claude/session/fix/mingly-ispathsafe-prefixfrom
claude/session/fix/mingly-lows-fileaccess-mcp
Closed

security: constrain READ_FILE to granted dirs; validate command paths before basename#20
Baldri wants to merge 1 commit into
claude/session/fix/mingly-ispathsafe-prefixfrom
claude/session/fix/mingly-lows-fileaccess-mcp

Conversation

@Baldri

@Baldri Baldri commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Gestapelt auf #18 (nutzt den isPathSafe-Fix). Base ist der #18-Branch — nach dessen Merge zeigt der Diff nur noch diese zwei Fixes.

Was

Zwei Low-Findings zu Datei-/Command-Zugriff.

Warum & Änderungen

  • READ_FILE liest jeden Pfad (ipc/content-handlers.ts): prüfte nur validateFilePath (Länge/..) → jeder absolute Pfad ausserhalb der Grants war lesbar. Neu: isPathWithinAllowedDirs (shared/file-access-types.ts) gated den Read gegen die FileAccessManager-Grants.
  • mcp-sanitizer Basename vor Safe-Dir (utils/mcp-sanitizer.ts): ALLOWED_COMMANDS.has(basename) lief vor der Safe-Dir-Regel → /tmp/evil/python3 oder ./evil/python3 passierten, weil der Basename allowlisted war. Die Basename-Allowlist gilt jetzt nur für bare Namen; jeder Pfad wird als Pfad validiert (absolut → Safe-Dir; relativ → abgelehnt).

Tests

mcp-sanitizer.test.ts (Unsafe-Dir/Relative-Escapes) + file-access-types.test.ts (isPathWithinAllowedDirs), je rot vor Fix. Volle Suite grün, tsc -p tsconfig.main.json clean.

Dokumentation

Security-Audit (2026-08-21), Mingly Low-Findings (electron-hardening READ_FILE, command-execution mcp-sanitizer).

🤖 Generated with Claude Code

… before basename

Two low-severity file/command access gaps from the audit:

- READ_FILE IPC handler (ipc/content-handlers.ts) ran only validateFilePath
  (length / '..'), so any absolute path outside the granted directories was
  readable. Add isPathWithinAllowedDirs (shared/file-access-types.ts) and gate
  the read on the FileAccessManager's granted directories.
- validateCommand (utils/mcp-sanitizer.ts) checked ALLOWED_COMMANDS.has(basename)
  BEFORE the safe-directory rule, so /tmp/evil/python3 or ./evil/python3 passed
  just because the basename was allowlisted. The basename allowlist now applies
  ONLY to bare command names; any path is validated as a path (absolute → must
  be in a safe dir; relative → rejected).

Tests (red before fix): mcp-sanitizer.test.ts (unsafe-dir / relative-path
escapes), file-access-types.test.ts (isPathWithinAllowedDirs). Full suite green,
tsc clean.

Note: builds on the isPathSafe sibling-prefix fix (same branch family).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Baldri
Baldri deleted the branch claude/session/fix/mingly-ispathsafe-prefix August 22, 2026 15:03
@Baldri Baldri closed this Aug 22, 2026
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