Skip to content

fix(memory): reject path-escaping memory rel_path values - #129

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-8078
Draft

fix(memory): reject path-escaping memory rel_path values#129
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-8078

Conversation

@cursor

@cursor cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • Fixes a critical path escape where executor/stdio memory_write joined caller-controlled rel_path under <chat_root>/memory/ after only checking contains("..") / starts_with('/'). On Windows, drive-absolute and backslash-rooted values (e.g. C:/Temp/pwn.md, \Windows\Temp\pwn.md) replace the memory root via Path::join and write outside the chat tree.
  • Adds shared validate_memory_rel_path / memory_file_under_dir in skilllite-core, wires them into executor RPC write + markdown reindex, and keeps nested / relatives like notes/day.md working.
  • Adds regression tests for drive / backslash / absolute / traversal reject paths and nested accept path.

Bug Impact

  • Arbitrary file create/overwrite outside <chat_root>/memory/ under process permissions on Windows hosts.
  • Concrete trigger: stdio RPC memory_write with rel_path: "C:/Temp/pwn.md" (or \\Windows\\Temp\\pwn.md) and any content.

Task Linkage

  • Task ID: TASK-2026-077
  • Task folder: tasks/TASK-2026-077-memory-rel-path-safety/

Injected Specs

  • spec/verification-integrity.md
  • spec/task-artifact-language.md
  • spec/security-nonnegotiables.md
  • spec/rust-conventions.md
  • spec/testing-policy.md
  • spec/docs-sync.md (N/A: fail-closed validation only; no user-facing path grammar docs)
  • spec/architecture-boundaries.md (reviewed; no boundary changes)

Validation Evidence

  • Commands executed:
    • cargo fmt --all -- --check → clean
    • cargo test -p skilllite-core path_validation → 3 passed
    • cargo test -p skilllite-executor --lib → 6 passed
    • cargo clippy -p skilllite-core -p skilllite-executor --all-targets -- -D warnings → clean
    • python3 scripts/validate_tasks.py → passed (71 task directories)
  • Key results:
    • C:/Temp/pwn.md, \Windows\Temp\pwn.md, /tmp/pwn.md, ../escape.md rejected before write
    • Nested notes/day.md still written under chat/memory/

Regression Scope

Docs Sync (EN/ZH)

  • Not needed
  • Updated EN + ZH docs
    Files:
    • N/A

Security Review Notes

  • What security policy changed, and why is it needed? Memory note relative paths must stay under memory/ even when Windows join semantics replace roots.
  • Is default behavior more permissive? No — fail-closed.
  • Does this affect SKILLLITE_* config semantics? No.
  • Were tests and EN/ZH docs updated? Tests yes; docs N/A as above.

Review Checklist

  • Acceptance criteria in tasks/TASK-2026-077-memory-rel-path-safety/TASK.md satisfied
  • tasks/TASK-2026-077-memory-rel-path-safety/STATUS.md updated with latest progress
  • tasks/TASK-2026-077-memory-rel-path-safety/REVIEW.md includes merge readiness decision
  • tasks/board.md status is up to date
Open in Web View Automation 

cursoragent and others added 2 commits August 1, 2026 11:08
Executor memory_write only blocked ".." and leading "/", so Windows
drive-absolute and backslash-rooted paths could replace the memory root
via Path::join. Validate nested relatives centrally and fail closed
before any filesystem mutation.

Co-authored-by: EXboy <EXboys@users.noreply.github.com>
Capture scope, validation evidence, and board status for the executor
memory rel_path path-escape fix.

Co-authored-by: EXboy <EXboys@users.noreply.github.com>
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