continue-custom/packages/terminal-security/test
continue[bot] bbb72d13b8 fix(terminal-security): prevent newline bypass in command validation
Fixes a security vulnerability where an attacker could bypass the terminal
command allow-list by using newline characters (\n, \r\n, \r) as command
separators.

The issue occurred because shell-quote treats literal newlines as whitespace,
causing multiple newline-separated commands to be evaluated as a single
command. This allowed dangerous commands to be hidden after safe commands.

Changes:
- Split input on line breaks before parsing with shell-quote
- Evaluate each line independently and return the most restrictive policy
- Added comprehensive tests for newline bypass scenarios
- Tests cover Unix (\n), Windows (\r\n), and old Mac (\r) line endings

Security Impact:
- Prevents bypass of allow-list using 'ls\nopen -a Calculator'
- Prevents bypass of allow-list using 'echo hello\nnpm install malicious'
- Critical commands (sudo, rm -rf /) are still properly blocked
- High-risk commands now correctly require permission

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <nate@continue.dev>
Co-authored-by: Username <nate@continue.dev>
2025-10-30 00:49:31 +00:00
..
terminalCommandSecurity.test.ts fix(terminal-security): prevent newline bypass in command validation 2025-10-30 00:49:31 +00:00