Skip to content

fix(permissions): deny safe-read auto-approval for shell redirections - #85

Open
SeashoreShi wants to merge 1 commit into
cosmicstack-labs:mainfrom
SeashoreShi:fix/safe-read-redirection-bypass
Open

fix(permissions): deny safe-read auto-approval for shell redirections#85
SeashoreShi wants to merge 1 commit into
cosmicstack-labs:mainfrom
SeashoreShi:fix/safe-read-redirection-bypass

Conversation

@SeashoreShi

Copy link
Copy Markdown

Summary

  • deny safe-read auto-approval for shell segments that contain shell redirection operators
  • keep the existing safe-read allowlist intact for true read-only commands
  • add regression tests covering >, >>, and heredoc redirections while preserving quoted / escaped literals

Why

checkShellCommand() currently auto-approves commands when every parsed segment matches a safe-read pattern like cat *. That still treats commands such as cat README.md > variant.txt as read-only even though the execution path later runs the original command with shell: true, letting the shell perform a write redirection.

This change keeps the current permission model but prevents safe-read auto-approval whenever a segment contains unquoted redirection syntax.

Testing

  • npm test -- src/capabilities/permissions.test.ts
  • npm run typecheck

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