fix(typespec-vscode): prevent shell injection in tsp compile task - #11275
Merged
timotheeguerin merged 2 commits intoJul 16, 2026
Conversation
Contributor
|
No changes needing a change description found. |
timotheeguerin
force-pushed
the
fix/vscode-task-shell-injection
branch
from
July 16, 2026 16:56
263b4ba to
1627b7d
Compare
timotheeguerin
force-pushed
the
fix/vscode-task-shell-injection
branch
from
July 16, 2026 17:01
1627b7d to
8bb7167
Compare
|
You can try these changes here
|
Use vscode.ProcessExecution with an argument array instead of vscode.ShellExecution so workspace file paths and task arguments are never interpreted by the OS shell.
timotheeguerin
force-pushed
the
fix/vscode-task-shell-injection
branch
from
July 16, 2026 17:03
8bb7167 to
74839fe
Compare
timotheeguerin
marked this pull request as ready for review
July 16, 2026 17:12
timotheeguerin
requested review from
RodgeFu,
bterlson,
catalinaperalta,
iscai-msft,
lirenhe,
markcowl and
witemple-msft
as code owners
July 16, 2026 17:12
timotheeguerin
enabled auto-merge (squash)
July 16, 2026 21:56
…spec into fix/vscode-task-shell-injection
timotheeguerin
disabled auto-merge
July 16, 2026 22:03
commit: |
catalinaperalta
approved these changes
Jul 16, 2026
jorgerangel-msft
pushed a commit
to jorgerangel-msft/typespec
that referenced
this pull request
Jul 17, 2026
Backmerges `release/july-2026` into `main` to bring hotfix commits back to the development branch. ## Changes from release/july-2026 - **fix(typespec-vscode):** prevent shell injection in tsp compile task (microsoft#11275) - **fix(spector):** prevent unauthenticated remote server stop (microsoft#11274) - **chore:** version bumps for hotfixes (microsoft#11281) --------- Co-authored-by: Timothee Guerin <tiguerin@microsoft.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.
Summary
Fixes a shell command injection vulnerability in the TypeSpec VS Code task provider.
Data flow (source → sink)
extension.tsregisterscreateTaskProvider()on activation (default-on).task-provider.ts—vscode.workspace.findFiles('**/main.tsp', ...)collects workspace paths, including attacker-controllable directory names;task.definition.path/argsalso come from user-authoredtasks.json.new vscode.ShellExecution(cmd, ...), which executes it via the OS shell → command injection.Fix
Replace
vscode.ShellExecutionwithvscode.ProcessExecution, passing arguments as an array so no shell is involved and no escaping is required.src/task-command.tswith pure, testable helpers:splitArgs— quote-aware tokenizer (respects single/double quotes) so legitimatetasks.jsonargs with spaces keep working; performs no shell expansion.resolveTaskCommand— builds{ command, args[] }as[...cli.args, "compile", absoluteTargetPath, ...splitArgs(args)], resolving${...}variables per element.createTaskInternalnow uses these helpers +vscode.ProcessExecution(bothcwdand no-cwdbranches).Logic was extracted into a separate module because the unit-test environment has no real
vscodemodule.Behavior note
Shell features (
$VAR,&&, globbing) intasks.jsonargs are no longer shell-interpreted — the intended hardening. Quoting to group tokens with spaces still works.Tests
test/unit/task-command.test.ts(9 tests): empty/--watchargs, quoted args with spaces,${workspaceFolder}resolution, and an injection path ($(rm -rf ~)...) verified to remain a single literal argument.