Skip to content

security: contain workspace path resolution - #5

Merged
harshitethic merged 1 commit into
mainfrom
security/workspace-path-containment
Sep 9, 2026
Merged

harshitethic merged 1 commit into
mainfrom
security/workspace-path-containment

Conversation

@harshitethic

Copy link
Copy Markdown
Owner

Problem

workspace_repo() joined a caller-controlled workspace_id directly under .workspaces and only checked whether the resulting path existed. A traversal such as ../outside could resolve outside the intended workspace root if a matching repo directory existed, expanding the filesystem/command-execution boundary used by /api/execute and /api/workspace.

Solution

  • resolve the workspace root and candidate repo to canonical paths
  • require the resolved repo to remain under the workspace root
  • reject escaping paths with HTTP 400
  • require the resolved target to be a directory
  • add regression coverage for traversal rejection and normal in-root resolution

Validation

  • python -m compileall app tests — passed
  • python -m unittest discover -s tests -v — 25 tests passed
  • git diff --check — passed
  • reviewed the focused 2-file diff before push; no credentials or environment secrets introduced

Scope

This PR only hardens workspace path resolution and tests that boundary. It does not change command allowlisting, repository cloning behavior, or product features.

AI assistance disclosure: AI assistance was used to identify the path-containment issue, implement the focused fix, add regression tests, and inspect the resulting diff.

@harshitethic
harshitethic merged commit f19f8fd into main Sep 9, 2026
2 checks passed
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