Skip to content

Enforce workspace directory boundaries for system tools#26

Merged
lxowalle merged 2 commits intosipeed:mainfrom
RinZ27:fix-path-traversal-and-unrestricted-exec
Feb 12, 2026
Merged

Enforce workspace directory boundaries for system tools#26
lxowalle merged 2 commits intosipeed:mainfrom
RinZ27:fix-path-traversal-and-unrestricted-exec

Conversation

@RinZ27
Copy link
Contributor

@RinZ27 RinZ27 commented Feb 11, 2026

Integrated a restrict_to_workspace option into the configuration to allow tools to access external files when necessary, particularly in containerized environments. While the default remains true for security, flipping this toggle lets tools reach any system path. Updated the validatePath helper and all filesystem/shell tools to respect this new setting. Both modes are now fully covered by the expanded test suite.

Technical highlights:

  • Added restrict_to_workspace toggle in config.json and AgentDefaults.
  • Updated validatePath to skip prefix checks when restriction is disabled.
  • Modified read_file, write_file, list_dir, append_file, edit_file, and exec to support the toggle.
  • Included comprehensive test cases for restricted and unrestricted access.

@RinZ27 RinZ27 changed the title Security: Enforce workspace restrictions for file and shell tools Enforce workspace directory boundaries for system tools Feb 11, 2026
@lxowalle
Copy link
Collaborator

Hi, this is a feature worth supporting. However, it also needs to allow picoclaw to operate on files outside the workspace, such as modifying certain third-party configurations within a container where there's no concern about damaging the system. So this needs to be improved by making this feature an option that can be disabled via config.json.

@yinwm
Copy link
Collaborator

yinwm commented Feb 12, 2026

picoclaw should support restrict_to_workspace / restrict option in config.json.

If true, only works in workspace; otherwise can use tools in anywhere.

Could you please support this option ? @RinZ27

Implemented a unified path validation helper to ensure filesystem operations stay within the designated workspace. This now supports a 'restrict_to_workspace' option in config.json (enabled by default) to allow flexibility for specific environments while maintaining a secure default posture. I've updated read_file, write_file, list_dir, append_file, edit_file, and exec tools to respect this setting and included tests for both restricted and unrestricted modes.
@RinZ27 RinZ27 force-pushed the fix-path-traversal-and-unrestricted-exec branch from 15c2e57 to 792639d Compare February 12, 2026 05:46
@RinZ27
Copy link
Contributor Author

RinZ27 commented Feb 12, 2026

Added the restrict_to_workspace toggle in config.json per the feedback. Default is still true for safety, but flipping it to false lets tools reach anywhere now—which I noticed was a requirement for containerized setups. Updated the tests too so they cover both modes properly. @yinwm @lxowalle

@lxowalle
Copy link
Collaborator

Thank you for this PR, I've tested it and it works well. However, I noticed the filesystem_test.go file, which seems irrelevant to the functionality and appears to be AI-generated. I removed this file after merging the code.

@lxowalle lxowalle merged commit 8d15598 into sipeed:main Feb 12, 2026
@RinZ27
Copy link
Contributor Author

RinZ27 commented Feb 12, 2026

@lxowalle I included the tests to verify the workspace restriction logic during development, but I understand if they don't fit the project's current scope. Glad the core feature is working as expected!

@RinZ27 RinZ27 deleted the fix-path-traversal-and-unrestricted-exec branch February 12, 2026 14:19
@Zepan
Copy link
Contributor

Zepan commented Feb 13, 2026

Thanks for your contribution! We are forming the PicoClaw Dev Group to accelerate the evolution of the project. Any developer with more than one merged PR is invited to join.

Would you like to join the PicoClaw Dev Group? If so, please send an email to support@sipeed.com with the subject line: [Join PicoClaw Dev Group] + Your GitHub account. We will send the Discord invite link to your inbox.

emadomedher pushed a commit to emadomedher/picoclaw that referenced this pull request Feb 17, 2026
…tricted-exec

Enforce workspace directory boundaries for system tools
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.

4 participants