picoclaw/pkg/tools
sky5454 cb5d33124c
fix(powershell): windows security enhancement, sec deny powershell encoding bypass via iex inje… (#2836)
* fix(powershell):  sec deny  powershell encoding bypass   via iex injection.

* fix(exec): security guard bypass fixes for PowerShell/CMD encoding and path traversal

- Split deny patterns into defaultDenyPatterns (all platforms) and
  windowsDenyPatterns (Windows-only) to avoid false positives
- Add PowerShell encoding bypass detection:
  - [Text.Encoding] and [System.Text.Encoding] variants
  - -EncodedCommand short forms (-e, -ec, -enc)
  - .GetString([byte[]] with whitespace variations
  - FromBase64String decoding
  - PowerShell variable = [byte[](...) patterns
  - Literal \uXXXX Unicode escape sequences
- Expand PowerShell ($env:VAR) and CMD (%VAR%) environment variables
  before workspace path checking to prevent $env:USERPROFILE bypass
- Expand ~ to home directory on Windows
- Add .../.../ path traversal variant detection (blocks .../.../, ..../..../)
- Add symlink/junction resolution before workspace check
- Add Windows path normalization for ADS (file.txt:stream) and
  extended-length paths (\?\)
- Add comprehensive tests for all new patterns

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(exec): fix -EncodedCommand regex and rename Windows tests with expanded payloads

- Fix -EncodedCommand regex to match all short forms: -e, -ec, -enc, -en
- Rename Windows-specific tests with TestWindows_ prefix for clarity:
  - TestWindows_TildeBypassPrevented
  - TestWindows_SymlinkBypassPrevented
  - TestWindows_PowerShellEncodingBypass
- Expand test payloads:
  - [Text.Encoding]: add UTF8 and Unicode variants
  - -EncodedCommand: add -enc and -en forms
  - Unicode escape: add multiple \uXXXX forms

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* ci: retest

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 10:28:03 +08:00
..
fs fix test 2026-05-12 23:23:26 +02:00
hardware fix(serial_windows): remove unused import (#2697) 2026-04-28 16:19:59 +08:00
integration feat(providers): add gemini web search provider (#2763) 2026-05-14 09:50:47 +08:00
shared fix(tools) limit edit diff preview size for user and model 2026-05-12 23:12:37 +02:00
cron.go fix(cron): propagate sessionKey to prevent duplicate tool responses 2026-04-27 13:17:25 +02:00
cron_test.go fix(cron): propagate sessionKey to prevent duplicate tool responses 2026-04-27 13:17:25 +02:00
delegate.go fix(tools): normalize agent_id before self-check and delegation 2026-04-15 22:23:17 +08:00
delegate_test.go test(tools): verify normalization prevents self-delegation bypass 2026-04-15 22:23:47 +08:00
facade_compat_test.go feat(tools): add cross-platform serial hardware tool 2026-04-28 12:54:28 +08:00
fs_facade.go fix(providers,tools): address linter issues after reorg 2026-04-17 14:16:18 +08:00
fs_registry_compat_test.go refactor(tools): reorganize tool packages and facades 2026-04-17 13:44:31 +08:00
hardware_facade.go feat(tools): add cross-platform serial hardware tool 2026-04-28 12:54:28 +08:00
identifier_compat.go refactor(tools): reorganize tool packages and facades 2026-04-17 13:44:31 +08:00
integration_facade.go feat(providers): add gemini web search provider (#2763) 2026-05-14 09:50:47 +08:00
load_image_compat_test.go refactor(tools): reorganize tool packages and facades 2026-04-17 13:44:31 +08:00
normalization.go chore: revert unrelated golines formatting 2026-03-29 14:06:19 +02:00
path_compat.go refactor(tools): reorganize tool packages and facades 2026-04-17 13:44:31 +08:00
registry.go fix(tools): exempt MCP discovery tools from agent allowlists 2026-05-08 09:18:14 +02:00
registry_test.go fix(tools): exempt MCP discovery tools from agent allowlists 2026-05-08 09:18:14 +02:00
result_test.go fix(tools) limit edit diff preview size for user and model 2026-05-12 23:12:37 +02:00
search_tool.go fix(tools): exempt MCP discovery tools from agent allowlists 2026-05-08 09:18:14 +02:00
search_tools_test.go chore: revert unrelated golines formatting 2026-03-29 14:06:19 +02:00
session.go refactor(tools): reorganize tool packages and facades 2026-04-17 13:44:31 +08:00
session_process_unix.go feat(tools): add exec tool enhancement with background execution and PTY support (#1752) 2026-03-25 21:02:49 +08:00
session_process_windows.go feat(tools): add exec tool enhancement with background execution and PTY support (#1752) 2026-03-25 21:02:49 +08:00
session_test.go feat(tools): add exec tool enhancement with background execution and PTY support (#1752) 2026-03-25 21:02:49 +08:00
shared_facade.go feat(tools): show unified diff for edit_file edits 2026-05-12 18:06:47 +02:00
shell.go fix(powershell): windows security enhancement, sec deny powershell encoding bypass via iex inje… (#2836) 2026-05-18 10:28:03 +08:00
shell_process_unix.go fix(exec): terminate process tree on timeout 2026-02-18 02:01:29 +08:00
shell_process_windows.go fix(exec): terminate process tree on timeout 2026-02-18 02:01:29 +08:00
shell_test.go fix(powershell): windows security enhancement, sec deny powershell encoding bypass via iex inje… (#2836) 2026-05-18 10:28:03 +08:00
shell_timeout_unix_test.go feat(tools): add exec tool enhancement with background execution and PTY support (#1752) 2026-03-25 21:02:49 +08:00
spawn.go Merge upstream/main into feat/agent-discovery-prompt 2026-05-07 13:16:30 +02:00
spawn_status.go chore: revert unrelated golines formatting 2026-03-29 14:06:19 +02:00
spawn_status_test.go chore: revert unrelated golines formatting 2026-03-29 14:06:19 +02:00
spawn_test.go Merge upstream/main into feat/agent-discovery-prompt 2026-05-07 13:16:30 +02:00
subagent.go feat(agent): add TargetAgentID to SubTurnConfig for cross-agent delegation 2026-04-15 21:27:13 +08:00
subagent_tool_test.go chore: revert unrelated golines formatting 2026-03-29 14:06:19 +02:00
sysproc_unix.go feat(tools): add exec tool enhancement with background execution and PTY support (#1752) 2026-03-25 21:02:49 +08:00
sysproc_windows.go feat(tools): add exec tool enhancement with background execution and PTY support (#1752) 2026-03-25 21:02:49 +08:00
toolloop.go feat: add load_image tool for local file vision (#2116) 2026-04-01 21:32:10 +08:00
validate.go feat(tools): add tool argument schema validation before execution (#1877) 2026-03-24 18:35:56 +08:00
validate_test.go chore: revert unrelated golines formatting 2026-03-29 14:06:19 +02:00