Skip to content

fix(security): block shell escape bypasses, symlink TOCTOU, and working_dir escape#1

Merged
AlexanderGalkin95 merged 4 commits intomainfrom
fix/security-escape-symlink-workdir
Feb 16, 2026
Merged

fix(security): block shell escape bypasses, symlink TOCTOU, and working_dir escape#1
AlexanderGalkin95 merged 4 commits intomainfrom
fix/security-escape-symlink-workdir

Conversation

@AlexanderGalkin95
Copy link
Owner

Summary

  • Block shell escape sequences (ANSI-C/locale quoting, hex/octal escapes, escaped metacharacters) that bypassed regex denylist in restricted mode
  • Add safeReadFile/safeWriteFile/safeOpenFile wrappers to re-verify symlink targets right before I/O, closing TOCTOU race window
  • Validate working_dir parameter stays within workspace when restrict_to_workspace=true
  • Document all three protections in README security section

Test plan

  • go vet ./pkg/tools/... passes
  • go test ./pkg/tools/... -count=1 — all tests pass
  • TestShellTool_EscapeSequenceBlocking — 5 escape patterns blocked
  • TestShellTool_WorkingDirRestriction — outside blocked, inside allowed
  • TestFilesystemTool_{Write,Edit,Append}File_RejectsSymlinkEscape — symlink escape blocked

🤖 Generated with Claude Code

AlexanderGalkin95 and others added 4 commits February 16, 2026 16:47
…-default ACL

Close critical attack chain: empty allow_from → any user → prompt injection →
exec denylist bypass → full system access.

- Expand shell denylist with 10 new patterns (rm long flags, base64→shell,
  python/perl/ruby -c/-e, eval, curl/wget→shell, find -exec rm, xargs rm,
  fdisk/parted/wipefs)
- Block shell metacharacters ($(), ${}, backticks), $VAR expansion and
  cd /absolute in workspace-restricted mode
- Change empty allow_from from allow-all to deny-all (deny-by-default)
- Add logger.WarnCF at all block points and rejected messages
- Add tests for 18 bypass techniques, 6 metacharacter escapes, and
  5 safe-command allowance checks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… HTTP in provider

Block requests to internal/private networks (loopback, link-local, RFC1918, IPv6 ULA)
in WebFetchTool to prevent SSRF attacks targeting cloud metadata and internal services.
Log a warning when HTTPProvider is configured with plain http:// API base, as API keys
may be transmitted without encryption.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ng_dir escape

- Add 5 regex patterns to block ANSI-C/locale quoting, hex/octal escapes,
  and escaped metacharacters that bypassed shell denylist in restricted mode
- Add safeReadFile/safeWriteFile/safeOpenFile wrappers that re-verify
  symlink targets right before I/O to close TOCTOU race window
- Validate working_dir parameter stays within workspace when restricted
- Document all three protections in README security section

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AlexanderGalkin95 AlexanderGalkin95 merged commit 0d51516 into main Feb 16, 2026
@AlexanderGalkin95 AlexanderGalkin95 deleted the fix/security-escape-symlink-workdir branch February 16, 2026 20:24
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