Skip to content

Conversation

@continue
Copy link
Contributor

@continue continue bot commented Oct 30, 2025

Summary

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 Vulnerability

The shell-quote library treats literal newline characters as whitespace rather than command separators. This caused multiple newline-separated commands to be evaluated as a single command, allowing dangerous commands to be hidden after safe ones.

Attack Examples

  • ls\nopen -a Calculator → Bypassed to allowedWithoutPermission (should require permission)
  • ls\nnpm install malicious → Bypassed to allowedWithoutPermission (should require permission)
  • echo hello\nopen -a Calculator → Bypassed to allowedWithoutPermission (should require permission)

The Fix

The solution splits input on line breaks (/\r?\n|\r/) before parsing with shell-quote, evaluating each line independently and returning the most restrictive policy.

Changes

  • Source Code: Modified evaluateTerminalCommandSecurity() to split on newlines before parsing
  • Tests: Added 32 comprehensive tests covering:
    • Critical commands with newline separators
    • High-risk commands with newline separators
    • All newline variations (\n, \r\n, \r)
    • Multiple commands on separate lines
    • Realistic attack scenarios
    • Edge cases (empty lines, whitespace, etc.)

Security Impact

Fixed: Newline bypass for medium/high-risk commands
Maintained: Critical commands (sudo, rm -rf /) still properly blocked
Maintained: Existing security checks for semicolons, pipes, etc.

Testing

All 224 tests pass, including:

  • 32 new tests for newline bypass scenarios
  • 192 existing security tests remain passing

This agent session was co-authored by nate and Continue.


Summary by cubic

Prevents a newline-based bypass in terminal command validation by splitting input on line breaks and evaluating each line separately. Applies the most restrictive policy across lines to stop hidden dangerous commands.

  • Bug Fixes
    • Blocks critical commands placed after safe ones via newline (e.g., sudo, rm -rf /).
    • Requires permission for high-risk commands after newline (e.g., npm install, curl, docker).
    • Supports Unix, Windows, and old Mac line endings; skips empty lines.
    • Added 32 tests for newline scenarios; all 224 tests pass.

Written for commit 28cdb4e. Summary will update automatically on new commits.

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>
@continue continue bot requested a review from a team as a code owner October 30, 2025 00:49
@continue continue bot requested review from sestinj and removed request for a team October 30, 2025 00:50
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 30, 2025
continue bot and others added 2 commits October 30, 2025 00:51
Add explicit ToolPolicy type annotation to mostRestrictivePolicy variable
to fix TypeScript compilation error in CI. TypeScript was inferring a
narrower type that didn't include 'disabled', causing type mismatch errors.

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

Co-Authored-By: Continue <nate@continue.dev>
Co-authored-by: Username <nate@continue.dev>
Fix code formatting to pass prettier checks in CI.

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

Co-Authored-By: Continue <nate@continue.dev>
Co-authored-by: Username <nate@continue.dev>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 19, 2025
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants