Skip to content

Security: Broaden terminal sendText sanitization + Fix CSRF on /delay-shutdown#234

Merged
azmkercso merged 3 commits intoaws:1.7from
aakashmandavilli96:1.7
Apr 20, 2026
Merged

Security: Broaden terminal sendText sanitization + Fix CSRF on /delay-shutdown#234
azmkercso merged 3 commits intoaws:1.7from
aakashmandavilli96:1.7

Conversation

@aakashmandavilli96
Copy link
Copy Markdown
Collaborator

@aakashmandavilli96 aakashmandavilli96 commented Apr 20, 2026

Changes

Two security fixes for Code Editor:

1. Broaden terminal sendText sanitization (aligns with PR #200)

Expands the sanitize-terminal-sendtext-paths patch from cd-only to all path-like tokens:

  • Function renamed: sanitizeCdPathsInCommandsanitizePathsInCommand
  • Newline/null byte stripping: Prevents command injection via line splitting
  • Double-quoted path handling: Escapes $(), ${}, backticks inside double-quoted paths
  • Unquoted path-like tokens: Sanitizes any token containing /
  • Narrowed escaping: Only targets command substitution patterns instead of all shell metacharacters

Testing

  • Both patches apply cleanly via sh ./scripts/install.sh
  • Verified patched source in both vscode/ and patched-vscode/

…tokens

Expands sanitizeCdPathsInCommand (now sanitizePathsInCommand) to cover
all path-like segments in terminal.sendText(), not just cd arguments.
This prevents command injection via malicious folder names in any
command (e.g., python /path/$(evil)/file.py).

Changes:
- Strip newlines and null bytes to prevent line-splitting injection
- Sanitize double-quoted paths containing '/' for $(), ${}, backticks
- Sanitize unquoted path-like tokens containing '/'
- Narrow escaping from all shell metacharacters to only command
  substitution patterns ($(), ${}, backticks)

Aligns with code-editor PR aws#200.
The /delay-shutdown endpoint was handled before the connection token
validation, allowing unauthenticated cross-origin requests to reset
the idle shutdown timer. An attacker could keep a Code Editor instance
running indefinitely via a simple GET redirect from any page.

Move the handler below the connection token check so requests without
a valid token are rejected with 403.
@aakashmandavilli96 aakashmandavilli96 changed the title Broaden terminal sendText sanitization from cd-only to all path-like tokens Security: Broaden terminal sendText sanitization + Fix CSRF on /delay-shutdown Apr 20, 2026
@azmkercso azmkercso merged commit 78742c4 into aws:1.7 Apr 20, 2026
3 checks passed
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.

4 participants