---
title: "qwed-mcp: execute_python_code puts the shared temp…"
description: "GHSA-qj7c-h9rh-qppc: qwed-mcp: execute_python_code puts the shared temp directory first on the child's import path. Affected and fixed versions of qwed-mcp."
url: https://qwedai.tech/security/advisories/ghsa-qj7c-h9rh-qppc
---

[Security](https://qwedai.tech/security) · [Advisories](https://qwedai.tech/security/advisories) · GHSA-qj7c-h9rh-qppc

# qwed-mcp: execute\_python\_code puts the shared temp directory first on the child's import path

medium Fixed in 0.3.0 GHSA-qj7c-h9rh-qppc · Published 13 November 2026

## Summary

`execute_python_code` writes the submitted code to `tempfile.gettempdir()/qwed_exec_<uuid>.py` and runs it as `sys.executable <file>`. Python puts the script's directory first on `sys.path`, so the child imports modules from the system temp directory before the standard library and site-packages. On a host where another user can write to that directory (for example `/tmp` on a shared Linux machine), a file such as `/tmp/json.py` runs with the MCP server's privileges the next time admitted code imports `json`. The code check passes, because the planted code is not in the checked code at all.

## Details

Place `qwedprobe_mod.py` containing `print('PLANTED-MODULE-RAN')` in `tempfile.gettempdir()`. With `QWED_MCP_TRUSTED_CODE_EXECUTION=true`, run `execute_python_code` with the code `import qwedprobe_mod` followed by `print('user code')`. The output is `PLANTED-MODULE-RAN`, then `user code`. A planted file named after a standard-library module (other than a builtin or frozen one) is imported the same way, in place of the real module.

The tool runs only when the server administrator sets `QWED_MCP_TRUSTED_CODE_EXECUTION=true`.

## Impact

Local code execution as the server user, for anyone who can write to the shared temp directory, triggered by ordinary admitted code. The Docker image is less exposed when `/tmp` is private to the container.

## Affected versions

`qwed-mcp` 0.2.3 and earlier.

## Fix

Fixed in 0.3.0 (PR #75): the child runs in isolated mode (`python -I`), so the script's directory is not on `sys.path`, and `PYTHON*` environment variables and the user site-packages directory are ignored.

## Workarounds

Leave `QWED_MCP_TRUSTED_CODE_EXECUTION` unset (the default) until you upgrade, or run the server where the temp directory is private to it (for example `TMPDIR` set to a directory only the server user can write).

## Disclosure

Found during maintainer review. Automated review comments on PR #75 described the issue publicly before this advisory was published.

[All advisories](https://qwedai.tech/security/advisories)

Affected and fixed

qwed-mcp

Affected <= 0.2.3 Fixed in 0.3.0

Weakness

CWE-427 Uncontrolled Search Path Element

[View on GitHub](https://github.com/QWED-AI/qwed-mcp/security/advisories/GHSA-qj7c-h9rh-qppc)
