Skip to content

fix(security): confine start_security_scan paths to the workspace - #4850

Open
mangeshraut712 wants to merge 8 commits into
awslabs:mainfrom
mangeshraut712:fix/security-scan-workspace-bound
Open

mangeshraut712 wants to merge 8 commits into
awslabs:mainfrom
mangeshraut712:fix/security-scan-workspace-bound

Conversation

@mangeshraut712

@mangeshraut712 mangeshraut712 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4811

Summary

Changes

start_security_scan accepted any path, so ../ or an absolute path could point a scan (and the source upload) outside the workspace. This resolves the requested path and requires it to sit inside WORKSPACE_ROOT, or the server's working directory when that isn't set. A workspace at the filesystem root is refused, since it can't constrain anything. The check runs before S3 bucket setup or the scanner is invoked. Symlinks that resolve outside the workspace are rejected the same way (realpath).

User experience

Before: a scan request could reference files anywhere on the host. After: paths outside the workspace are rejected with a clear error and nothing is uploaded.

Checklist

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented (tool description + rejection errors; regression tests cover escapes)

Tests: tool-level cases for ../ traversal, absolute paths outside the workspace, symlink escape, filesystem-root workspace refusal, and cwd-fallback escape. uv run pytest -q (86 passed in tests/test_server.py), ruff check, and pyright are clean.

Is this a breaking change? (Y/N) N, unless someone relied on scanning paths outside the workspace.

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

Quick ping — this one is green and ready for review when you have a moment. It confines start_security_scan paths to the workspace so absolute paths cannot escape it.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

Friendly bump — CI is green and this is ready for review when you have a minute. Happy to adjust anything.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

Still green — ready for merge when convenient.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

@ljainiaz @jigar-lab @jzgithub28 @awsbyron CI is green and the contributor statement check is passing. It confines start_security_scan paths to the workspace so absolute paths outside it cannot be scanned. If it looks good, could you please review and merge when you get a chance? Thanks.

@mangeshraut712

Copy link
Copy Markdown
Contributor Author

CI is green. Confines start_security_scan paths to the workspace. Please review and merge when you can.

@mangeshraut712
mangeshraut712 force-pushed the fix/security-scan-workspace-bound branch from 4455510 to a0c79f2 Compare October 27, 2026 14:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

start_security_scan uploads caller-selected directories outside the workspace

1 participant