fix(lsp): validate workspace boundary in _read_file to prevent path traversal #10644
Merged
HAL9000
merged 4 commits from 2026-06-06 04:21:50 +00:00
fix/v360/lsp-path-traversal-file-reading into master
Labels
Clear labels
auto/needs-reevaluation
controller-managed
overdue
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Needs Feedback
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
Controller deferred this PR; awaiting Phase 6+ scope-evaluator or operator re-enablement.
Auto-agents controller manages this PR/issue (see tools/controller/deploy/RUNBOOK.md). Remove this label to abandon controller management.
PR blocked by an open issue dependency. Operator must close the dep (or remove the dependency link) before the merge driver can act. Auto-cleared by merge_drive when no open deps remain.
Most recent merge cycle hit CI timeout. Driver excludes this PR while last merge_cycle row is < 30 min old; label persists thereafter as visible history.
Currently being processed by an implementer worker.
Currently being processed by the merge driver.
Currently being processed by a reviewer worker.
Merge driver heartbeat stale; pipeline halted. Closed automatically on next clean tick.
Detected master commit violating the strict merge invariant. Tracked as an issue (not a PR label); kept here for label completeness.
In-cycle escalation: most recent attempt ran at the Tier 0 slot (`tier-0`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 1 slot (`tier-1`). Slot's model defined in .opencode/models/tiers.yaml.
In-cycle escalation: most recent attempt ran at the Tier 2 slot (`tier-2`). Slot's model defined in .opencode/models/tiers.yaml. Gated behind IMPLEMENTER_ESCALATION_TIER2_ENABLED.
In-cycle escalation: most recent attempt ran at the Tier -1 slot (`tier-min`). Slot's model defined in .opencode/models/tiers.yaml. Suffix is ``-min`` (not ``--1``) so the Forgejo UI reads naturally.
Tracking issues used by the AI Automation system for agents to communicate and report.
Rebase conflict needs LLM conflict-resolver.
Failing CI needs implementer attention.
Documenting a driver incident or rollback.
Reviewer has APPROVED this PR and no later REQUEST_CHANGES is outstanding. The merge driver requires this label to even consider a PR for merging. Set by the reviewer worker on APPROVE; cleared on REQUEST_CHANGES.
Train repeatedly lost master-tempo races. Driver excludes via merge_cycle until cooldown elapses; label persists as visible history.
Revert PR backing out an invariant violation. Fast-tracked through the merge driver.
Sentinel PR duplicated from upstream into a personal fork by tools/duplicate_prs_to_fork.py for pipeline testing. Lives only in the fork; the canonical pipeline never sees it.
No implementer activity for N days. Flagged for human review. Auto-cleared on next push to head branch.
Repeatedly fails on current master (>= 3 ci-fail-on-rebased-sha releases in 12 h). Excluded from driver until human triage.
A ticket in a blocked state and unable to complete until some other task is completed first.
Bounty
$100
A bounty of $100 for any open-source contributor who provides a MR that solves this issue
Bounty
$1000
A bounty of $1000 for any open-source contributor who provides a MR that solves this issue
Bounty
$10000
A bounty of $10000 for any open-source contributor who provides a MR that solves this issue
Bounty
$20
A bounty of $20 for any open-source contributor who provides a MR that solves this issue
Bounty
$2000
A bounty of $2000 for any open-source contributor who provides a MR that solves this issue
Bounty
$250
A bounty of $250 for any open-source contributor who provides a MR that solves this issue
Bounty
$50
A bounty of $50 for any open-source contributor who provides a MR that solves this issue
Bounty
$500
A bounty of $500 for any open-source contributor who provides a MR that solves this issue
Bounty
$5000
A bounty of $5000 for any open-source contributor who provides a MR that solves this issue
Bounty
$750
A bounty of $750 for any open-source contributor who provides a MR that solves this issue
MoSCoW
Could have
Could have feature in order to satisfy the epic/legendary.
MoSCoW
Must have
Must have feature in order to satisfy the epic/legendary.
MoSCoW
Should have
Should have feature in order to satisfy the epic/legendary.
There are questions in the ticket that can not be completed until the project owner provides clarity.
Points
1
1 man-hours worth of work for an expert with no learning curve.
Points
13
13 man-hours worth of work for an expert with no learning curve.
Points
2
2 man-hours worth of work for an expert with no learning curve.
Points
21
21 man-hours worth of work for an expert with no learning curve.
Points
3
3 man-hours worth of work for an expert with no learning curve.
Points
34
34 man-hours worth of work for an expert with no learning curve.
Points
5
5 man-hours worth of work for an expert with no learning curve.
Points
55
55 man-hours worth of work for an expert with no learning curve.
Points
8
8 man-hours worth of work for an expert with no learning curve.
Points
88
88 man-hours worth of work for an expert with no learning curve.
Priority
Backlog
This ticket has backlogged priority and is not to be worked on yet
Priority
CI Blocker
Critical priority issue that blocks CI/CD pipeline and prevents PR merges
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
When an epic or legendary is in review it must be signed off by owner, tech lead, and scrum master before being marked as completed.
A ticket for learning a tool or technology that is needed to be able to do future planning and design.
State
Completed
The ticket has been fully implemented, completed, and merged with the source code. This label should only be applied once a ticket is closed.
State
Duplicate
A ticket that represents the same content as an existing ticket.
State
In Progress
A ticket that is actively being developed.
State
In Review
A ticket that has had some code completed to implement but is waiting to pass peer review and is not yet merged in.
State
Paused
This ticket's work started but wasn't finished. It's on hold (likely in a feature branch) and will be resumed later, either due to a blocker or a delay.
State
Unverified
All new tickets start in this state. A developer may set it to show the ticket is unverified. This means we haven't agreed to work on it. It will either move to a verified state or be closed as wontdo.
State
Verified
The issue has been verified by a developer as legitimate. It will be worked on and verified tickets are now considered part of the backlog.
State
Wont Do
This ticket has been decided it wont be done. This may mean the bug has been determined to not be real (cant verify) or the feature is one we have decided we dont want to adopt.
Type
Automation
Any edits or discussion about the AI automated coding system.
Type
Bug
Something that doesnt work as intended.
Type
Discussion
Anytime a ticket represents a discussion about a subject and doesnt fall into one of the other categories.
Type
Documentation
An error or improvement needed in the documentation.
Type
Epic
Any first tier epic. That is, an epic which contains only issues as children and will not have sub-epics.
Type
Feature
Some new functionality not present.
Type
Legendary
A type of Epic which will contain other Epics.
Type
Refactor
A code change that restructures existing code without changing its external behavior.
Type
Support
Someone needs help using the project.
Type
Task
A generic task that doesnt fit into the other type categories.
Type
Testing
Work exclusively focusing on fixing or expanding testing.
Projects
Clear projects
No project
Assignees
aditya (Aditya Chhabra)
aleenaumair (Aleena Umair)
brent.edwards (Brent Edwards)
CoreRasurae (Luis Mendes)
drew (Drew Morris)
eugen.thaci (Eugen Thaci)
freemo (Jeffrey Phillips Freeman)
HAL9000 (HAL 9000)
HAL9001 (HAL9001)
hamza.khyari (Hamza Khyari)
hurui200320 (Rui Hu)
justin.morris
khird (Kyle Hird)
org.cleveragents
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cleveragents/cleveragents-core#10644
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "fix/v360/lsp-path-traversal-file-reading"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This PR fixes a critical path traversal vulnerability in the LSP runtime file reading functionality that could allow attackers to access sensitive files outside the workspace directory. The vulnerability was exploited through malicious file paths containing directory traversal sequences (e.g.,
../../../etc/passwd) or absolute paths pointing outside the workspace.The fix implements strict workspace boundary validation using canonicalized paths, preventing any file access outside the registered workspace root while maintaining backward compatibility for existing code.
Changes
Core Security Fix (
src/cleveragents/lsp/runtime.py)Workspace Root Tracking: Added
_workspace_rootsdictionary to track the workspace path for each LSP server instance, populated when servers are startedPath Validation Method: Implemented
_validate_workspace_path()static method that:os.path.realpath()to resolve symlinks and relative segmentsos.septo prevent prefix-matching attacks (e.g.,/workspacematching/workspace-evil)LspErrorif the resolved path doesn't start with the workspace root prefixFile Reading Security: Updated
_read_file()method to:workspace_rootparameterworkspace_rootis providedworkspace_rootisNoneCaller Updates: Modified all callers of
_read_file()(get_diagnostics,get_completions,get_hover,get_definitions) to pass the workspace root from the tracked serversTest Coverage (
features/lsp_path_traversal_security.feature&features/steps/lsp_path_traversal_security_steps.py)Comprehensive BDD test scenarios covering:
Path Validation Tests:
Path Traversal Attack Prevention:
../directory traversal sequencesBackward Compatibility:
_read_file()without workspace_root skips boundary checkIntegration Tests:
get_diagnosticsblocks path traversal when workspace is registeredget_diagnosticssucceeds for valid files inside workspaceget_completionsblocks path traversal when workspace is registeredTesting
All security scenarios are covered by BDD feature tests that verify:
Security Impact
Closes #7215
Automated by CleverAgents Bot
Agent: pr-creator
Implementation Attempt — Tier 1: haiku — Success
Fixed the CI lint failure caused by
ruff formatcheck failing onfeatures/steps/lsp_path_traversal_security_steps.py.Root Cause: The step definitions file introduced in the original PR had several multi-line decorator strings that
ruff formatwould collapse to single lines. Thenox -s format -- --checkstep in the CI lint job detected these formatting issues and failed.Changes Made:
nox -s formatto auto-formatfeatures/steps/lsp_path_traversal_security_steps.py@given/@whendecorator strings to single lines per ruff formatting rulesQuality gate status:
Automated by CleverAgents Bot
Supervisor: Implementation | Agent: implementation-worker
Security Fix Review — Path Traversal in LSP Runtime
This PR addresses a critical path traversal vulnerability (issue #7215) by adding
workspace boundary validation to
_read_file(). The core implementation isthoughtful and correct:
What is done well:
os.path.realpath()to canonicalize both the requestedpath and workspace root, correctly resolving symlinks and
..segments beforethe prefix check.
root_prefix = canonical_root + os.seppattern correctly preventsprefix-matching attacks (e.g.
/workspacevs/workspace-evil).workspace_root: str | Noneparameter on_read_file()maintainsbackward compatibility — code without a workspace root skips validation.
get_diagnostics,get_completions,get_hover,get_definitions) consistently pass the tracked workspace root._validate_workspace_pathhelper is well-documented with a clear docstring.detailsdict with resolved path andworkspace root for debugging.
path traversal via
../, absolute paths outside workspace, symlinks pointingoutside workspace, and backward compatibility.
Blocking Issues (must be fixed before approval):
Branch name mismatch with issue metadata — Issue #7215 Metadata specifies the
branch should be
bugfix/lsp-runtime-read-file-path-traversalbut this PRis on
fix/v360/lsp-path-traversal-file-reading. CONTRIBUTING.md requiresbranch names to match the Metadata section exactly. Please either recreate
the branch or update the issue metadata.
Failing CI — unit tests red — The
unit_testsCI check is in failure state.Per company policy, all CI gates must pass before merge. The PR description
notes ‘unit_tests: not run locally (timeout in parallel mode;’ which suggests
test infrastructure issues. Please investigate and fix.
Missing companion TDD issue — Per CONTRIBUTING.md bug fix workflow:
“Create companion Type/Testing TDD issue before implementing the fix.”
Issue #7215 includes this subtask. No TDD issue is referenced in the PR.
Please create and reference it.
CI coverage skipped — The
coveragejob was skipped. The project requires≥97% coverage as a hard merge gate. Skipped cannot satisfy this requirement.
Additional observations (non-blocking suggestions):
Test step duplication — 366-line step file has significant duplication.
Steps
step_lspsec_validate_file_inside,_nested_file, and_workspace_root_itselfshare identical structure (resolve → validate →capture exception). A shared helper would reduce repetition.
Test coverage for boundary edge cases — Consider adding a scenario where
a path is one character different from the workspace root (e.g. workspace
/ws, path/wsx) to explicitly exercise theos.sepsuffix check.LspRegistry instantiation in tests —
step_lspsec_register_server_for_workspacecreates a fresh
LspRegistry()and assigns it to_registry, bypassing thereal init path. Works for tests but may mask edge cases.
Automated by CleverAgents Bot
Supervisor: PR Review | Agent: pr-review-worker
@@ -0,0 +1,87 @@Feature: LSP runtime path traversal securityBLOCKING: Missing companion TDD issue. Per CONTRIBUTING.md bug fix workflow, a Type/Testing TDD issue with a failing regression test must be created BEFORE the fix PR. Issue #7215 subtask requires: “Create companion Type/Testing TDD issue (per Bug Fix Workflow in CONTRIBUTING.md) before implementing the fix.” No TDD issue is referenced in the PR body.
@@ -55,6 +55,7 @@ class LspRuntime:) -> None:self._registry = registry or LspRegistry()self._lifecycle = lifecycle_manager or LspLifecycleManager()self._workspace_roots: dict[str, str] = {}BLOCKING: Branch name mismatch. Issue #7215 Metadata specifies branch as
bugfix/lsp-runtime-read-file-path-traversal. This PR usesfix/v360/lsp-path-traversal-file-reading. CONTRIBUTING.md requires exact match between PR branch and issue Metadata Branch field.@@ -98,6 +99,7 @@ class LspRuntime:)self._lifecycle.start_server(config, workspace_path)self._workspace_roots[name] = workspace_pathBLOCKING: CI is failing — unit_tests shows failure state. Per company policy, all CI gates (lint, typecheck, security, unit_tests, coverage) must pass before merge. The description notes tests ‘not run locally’ without a clear fix for the CI failure.
Suggestion: The test step file is 366 lines with significant duplication. Five validate_workspace_path When steps share identical structure (resolve with os.path.realpath, call the method, capture LspError). Consider a shared helper to reduce code duplication.
PR Review Complete — Review #1 submitted
I have submitted a formal
REQUEST_CHANGESreview (ID 6784) covering 4 blocking issues and 7 non-blocking observations.Summary of findings:
workspace_rootparameterPlease address the blocking issues and resubmit.
🌱 Grooming: proceed — PR cleared for processing.
(check
no_duplicates, categoryno_duplicates)Scanned all 397 open PRs. PR #10644 implements workspace boundary path validation in LSP's _read_file() method to prevent directory traversal attacks. No other open PR addresses this specific LSP security issue. Related security fixes exist for file_tools.py and agents modules, and other LSP PRs address different concerns (subprocess cleanup, header injection, DoS timeout), but none duplicate the workspace boundary validation logic.
📋 Estimate: tier 1.
3-file change (+525/-8): core logic edit to src/cleveragents/lsp/runtime.py (new _workspace_roots dict, _validate_workspace_path() method, updated _read_file() signature, 4 caller updates) plus two new BDD test files (feature + steps). Multi-file, new logic branches, test-additive — clearly tier 1. CI failures are all Docker Hub pull rate limit errors (infrastructure), not code issues; 0 ruff findings reported by lint job.
(attempt #3, tier 1)
🔧 Implementer attempt —
rebase-failed.Blockers:
7acb960b4bto3af34103763af3410376to505daffebc(attempt #5, tier 1)
🔧 Implementer attempt —
rebased.Pushed 1 commit:
505daff.✅ Approved
Reviewed at commit
505daff.Confidence: high.
Claimed by
merge_drive.py(pid 15960) until2026-06-05T00:20:37.333193+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
505daffebcto188b957320Released by
merge_drive.py(pid 15960). terminal_state=ci-fail-on-rebased-sha, op_label=auto/needs-implementer(attempt #7, tier 1)
🔧 Implementer attempt —
blocked.Blockers:
00e095b176but dispatch base was188b957320. The implementer pushed from inside the worktree (forbidden by the git contract) OR a third party pushed during the attempt. Re-dispatch will re-prefetch and pick up the new head.00e095b176to3304b1c02c(attempt #8, tier 2)
🔧 Implementer attempt —
rebased.Pushed 1 commit:
3304b1c.✅ Approved
Reviewed at commit
3304b1c.Confidence: high.
Claimed by
merge_drive.py(pid 15960) until2026-06-05T02:29:57.609825+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
3304b1c02ctoc780c124edReleased by
merge_drive.py(pid 15960). terminal_state=ci-fail-on-rebased-sha, op_label=auto/needs-implementer(attempt #11, tier 2)
event occurred 2026-06-05T01:57:14.373350+00:00
🔧 Implementer attempt —
verified-clean.🌱 Grooming: proceed — PR cleared for processing.
(check
no_duplicates, categoryno_duplicates)Comprehensive search across 395 open PRs found no duplicate of the workspace boundary validation fix in lsp/runtime.py _read_file(). Nine other LSP security fixes address distinct vulnerabilities (subprocess cleanup, header injection, env var sanitization, DoS). Multiple path traversal fixes exist in other modules (agents, file_tools, cli) but each targets a unique code path. High confidence no duplicate.
📋 Estimate: tier 1.
Multi-file security fix (3 files, +524/-46): core logic change in lsp/runtime.py adding path canonicalization and workspace boundary validation, callers updated (get_diagnostics, get_completions, get_hover, get_definitions), plus substantial new BDD feature file and step definitions covering positive/negative/edge cases. New logic branches, new test fixtures, security-sensitive correctness requirements. CI failures are infrastructure artifact-upload EPERM errors, not code failures — coverage and other gates all passed.
(attempt #15, tier 1)
🔧 Implementer attempt —
blocked.Blockers:
dd5983c8ecbut dispatch base wasc780c124ed. The implementer pushed from inside the worktree (forbidden by the git contract) OR a third party pushed during the attempt. Re-dispatch will re-prefetch and pick up the new head.(attempt #16, tier 2)
🔧 Implementer attempt —
ci-not-ready.✅ Approved
Reviewed at commit
dd5983c.Confidence: high.
Claimed by
merge_drive.py(pid 1627962) until2026-06-06T00:01:03.932106+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
dd5983c8ecto727d3e5cf5Claimed by
merge_drive.py(pid 1816405) until2026-06-06T05:23:40.854923+00:00.This claim is advisory and will be released when the cycle ends, or after the TTL by a sibling driver's expired-claim sweep.
727d3e5cf5tob62bb578deApproved by the controller reviewer stage (workflow 275).