GitHub Copilot for VS Code Information Disclosure via Insecure Temporary File Handling
Overview
A medium-severity information disclosure vulnerability was found in the GitHub Copilot extension for Visual Studio Code. The extension works by sending code snippets and context from the active editor to the GitHub Copilot service to generate suggestions. During this process, the extension created temporary files on the local filesystem containing the full prompt sent to the service, which included verbatim code from the user's project. The vulnerability was that these temporary files were created with insecure, overly permissive file permissions (`644`), making them world-readable on multi-user systems. A local attacker or a malicious process running under a different user account on the same machine could read these files to access potentially sensitive information, such as source code, API keys, or other secrets that were present in the editor's context window. While the files were typically short-lived, a monitoring script could capture their contents before they were deleted. The issue did not allow for remote exploitation but posed a significant risk in shared development environments, university lab machines, or any system where multiple users have shell access. The vulnerability highlighted the importance of secure temporary file creation practices, even for extensions in sandboxed environments like VS Code.
Affected Systems
Testing Guide
1. Install an affected version of the GitHub Copilot extension (e.g., 1.95.0) in VS Code on a Linux-based system. 2. While the extension is active, monitor the system's temporary directory (e.g., `/tmp`). 3. Use a command like `watch -n 0.1 'ls -la /tmp'` to observe file creation. 4. Look for files created by the Copilot extension and inspect their permissions. On a vulnerable version, they will be world-readable (e.g., `-rw-r--r--`). 5. After updating the extension, repeat the test and verify that new temporary files are created with restricted permissions (e.g., `-rw-------`).
Mitigation Steps
1. Update the GitHub Copilot extension for Visual Studio Code to version 1.96.0 or later. 2. Ensure that the underlying operating system and user account configurations follow the principle of least privilege. 3. Avoid running untrusted software on development machines where sensitive source code is handled. 4. Periodically check the system's temporary file directory for any insecurely created files by development tools.
Patch Details
The vulnerability was patched in version 1.96.0 of the GitHub Copilot VS Code extension by ensuring temporary files are created with restricted permissions (600).