fix(lsp): validate workspace boundary in _read_file to prevent path traversal #10644

Merged
HAL9000 merged 4 commits from fix/v360/lsp-path-traversal-file-reading into master 2026-06-06 04:21:50 +00:00

4 Commits

Author SHA1 Message Date
controller-ci-rerun b62bb578de chore: re-trigger CI [controller]
CI / lint (pull_request) Successful in 55s
CI / typecheck (pull_request) Successful in 1m29s
CI / security (pull_request) Successful in 1m29s
CI / helm (pull_request) Successful in 45s
CI / build (pull_request) Successful in 47s
CI / quality (pull_request) Successful in 1m38s
CI / push-validation (pull_request) Successful in 41s
CI / unit_tests (pull_request) Successful in 5m7s
CI / docker (pull_request) Successful in 1m42s
CI / integration_tests (pull_request) Successful in 8m5s
CI / coverage (pull_request) Successful in 21m35s
CI / status-check (pull_request) Successful in 5s
2026-06-05 23:53:43 -04:00
controller-ci-rerun 9f11ede848 chore: re-trigger CI [controller] 2026-06-05 23:53:43 -04:00
HAL9000 3e8890de08 fix(lsp): apply ruff format to lsp_path_traversal_security_steps.py 2026-06-05 23:53:43 -04:00
HAL9000 2406e17d2a fix(lsp): validate workspace boundary in _read_file to prevent path traversal
Introduced strict workspace boundary checks in _read_file to ensure that any
resolved path remains within the workspace root, preventing path traversal.
The implementation resolves the requested path against the workspace root and
rejects paths that escape, returning a proper LspError to the client.

Added _validate_workspace_path() static helper that canonicalises both the
resolved path and the workspace root before comparing, ensuring symlinks and
dot-dot segments cannot bypass the check.

Added _workspace_roots dict to LspRuntime to track the workspace path per
server name, populated in start_server() and consumed by get_diagnostics(),
get_completions(), get_hover(), and get_definitions().

Added BDD scenarios in features/lsp_path_traversal_security.feature covering:
- Path traversal via dot-dot segments
- Absolute paths outside the workspace
- Symlinks pointing outside the workspace
- Valid paths within the workspace
- Backward-compatible behaviour when workspace_root is None

ISSUES CLOSED: #7215
2026-06-05 23:53:43 -04:00