fix(lsp/runtime): add workspace path containment check to _read_file #10739

Merged
HAL9000 merged 2 commits from fix/issue-10490-lsp-path-containment into master 2026-04-23 09:38:33 +00:00

2 Commits

Author SHA1 Message Date
HAL9000 4f23ece138 style: apply ruff formatting to lsp_path_containment_steps.py
CI / lint (pull_request) Successful in 1m14s
CI / typecheck (pull_request) Successful in 1m27s
CI / security (pull_request) Successful in 1m26s
CI / helm (pull_request) Successful in 30s
CI / push-validation (pull_request) Successful in 28s
CI / build (pull_request) Successful in 52s
CI / quality (pull_request) Successful in 1m50s
CI / integration_tests (pull_request) Successful in 3m45s
CI / e2e_tests (pull_request) Successful in 4m1s
CI / unit_tests (pull_request) Successful in 11m3s
CI / docker (pull_request) Successful in 1m50s
CI / coverage (pull_request) Successful in 11m15s
CI / status-check (pull_request) Successful in 3s
CI / build (push) Failing after 0s
CI / lint (push) Successful in 56s
CI / typecheck (push) Successful in 1m23s
CI / helm (push) Successful in 41s
CI / security (push) Successful in 1m25s
CI / quality (push) Successful in 1m30s
CI / push-validation (push) Successful in 45s
CI / e2e_tests (push) Successful in 4m24s
CI / unit_tests (push) Failing after 5m51s
CI / docker (push) Has been skipped
CI / integration_tests (push) Successful in 6m4s
CI / benchmark-publish (pull_request) Has been skipped
CI / coverage (push) Successful in 11m1s
CI / status-check (push) Failing after 3s
CI / benchmark-regression (push) Has been skipped
CI / benchmark-regression (pull_request) Successful in 1h4m8s
CI / benchmark-publish (push) Successful in 1h16m50s
Fix CI lint failure by running ruff format on the step definitions file
that was missing auto-formatting before the PR was submitted.
2026-04-23 09:22:33 +00:00
HAL9000 d08084236a fix(lsp/runtime): add workspace path containment check to _read_file
LspRuntime._read_file had no check that the requested file path was contained within the workspace directory, allowing path traversal attacks to read arbitrary files on the filesystem.

Changes:
- Add _workspace_paths dict to LspRuntime to track per-server workspace roots
- start_server now stores the resolved workspace path for each server
- stop_server and stop_all clean up workspace path entries
- _read_file now accepts an optional workspace_path parameter; when
  provided, it resolves both paths and raises LspError if the file
  is outside the workspace (prevents ../../etc/passwd style attacks)
- get_diagnostics, get_completions, get_hover, get_definitions all
  pass the registered workspace path to _read_file
- Add features/lsp_path_containment.feature with 10 BDD scenarios
- Add features/steps/lsp_path_containment_steps.py step definitions

ISSUES CLOSED: #10490
2026-04-23 09:22:33 +00:00