Security: Broaden terminal sendText sanitization + Fix CSRF on /delay-shutdown#234
Merged
Security: Broaden terminal sendText sanitization + Fix CSRF on /delay-shutdown#234
Conversation
…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.
sachinh-amazon
approved these changes
Apr 20, 2026
azmkercso
approved these changes
Apr 20, 2026
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.
…en gate" This reverts commit 4b5a66c.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Two security fixes for Code Editor:
1. Broaden terminal sendText sanitization (aligns with PR #200)
Expands the
sanitize-terminal-sendtext-pathspatch from cd-only to all path-like tokens:sanitizeCdPathsInCommand→sanitizePathsInCommand$(),${}, backticks inside double-quoted paths/Testing
sh ./scripts/install.shvscode/andpatched-vscode/