RCE in VS Code Copilot Chat via applyPatchTool TOCTOU#2234
Open
carlospolop wants to merge 1 commit into
Open
Conversation
Collaborator
Author
🔗 Additional ContextOriginal Blog Post: https://www.hacktron.ai/blog/rce-in-vscode-copilot Content Categories: Based on the analysis, this content was categorized under "AI Security / AI Agent Abuse Local AI CLI Tools and MCP, with a cross-reference from Generic Hacking or Web/AI sections for arbitrary file write to RCE via .git/config poisoning". Repository Maintenance:
Review Notes:
Bot Version: HackTricks News Bot v1.0 |
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.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
The post describes a VS Code Copilot Chat Agent Mode prompt-injection vulnerability that bypasses the user-confirmation protections added after earlier prompt-injection-to-RCE issues. No CVE is mentioned. The vulnerable component is
applyPatchTool, used by Copilot to apply model-generated patches. The bug is a Time-of-check to time-of-use, TOCTOU, mismatch: the confirmation phase checks only the files listed in*** Update File:and*** Add File:, while t...🔧 Technical Details
Prompt-injection-driven agent tool abuse: If an AI coding agent consumes untrusted text from a GitHub issue, ticket, README, comment, or chat message, that text can become executable workflow instructions for the agent. When the agent has access to file-editing tools, an attacker can embed instructions that make the model call those tools with attacker-controlled content. In this case, the issue body instructs Copilot Agent Mode to call
apply_patchwith a malicious patch after a maintainer clicks Code with Agent Mode.TOCTOU in patch confirmation systems: A confirmation mechanism is unsafe when the paths checked before execution differ from the paths used during execution. The vulnerable pattern is a parser/checker that approves only source paths such as
*** Update File: harmless_file, while the executor also supports a secondary directive such as*** Move to: sensitive_target. The e...🤖 Agent Actions
Done: updated
src/AI/AI-Prompts.md.What I added:
applyPatchTOCTOU arbitrary write*** Move to:→ arbitrary overwrite primitive.git/configpoisoning +.vscode/settings.json(git.autofetch) → RCE/token exfiltration chainValidation:
## Referencessection remainsModified file:
src/AI/AI-Prompts.mdThis PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.