---
title: "qwed-mcp: a PEP 263 coding declaration makes…"
description: "GHSA-425c-p25c-qxwh: qwed-mcp: a PEP 263 coding declaration makes execute_python_code run code other than the code it… Affected and fixed versions of qwed-mcp."
url: https://qwedai.tech/security/advisories/ghsa-425c-p25c-qxwh
---

[Security](https://qwedai.tech/security) · [Advisories](https://qwedai.tech/security/advisories) · GHSA-425c-p25c-qxwh

# qwed-mcp: a PEP 263 coding declaration makes execute\_python\_code run code other than the code it checked

high Fixed in 0.3.0 GHSA-425c-p25c-qxwh · Published 13 November 2026

## Summary

`execute_python_code` checks the submitted code as text, then writes it to a script file and runs it with `sys.executable`. The interpreter decodes that file by its PEP 263 coding declaration (`# coding: ...` on the first two lines). Under a codec other than UTF-8 the text the interpreter reads is not the text that was checked. With `# coding: utf-7`, the sequence `+AAo-` decodes to a newline, so code written inside a comment becomes a statement that runs, and the code check never sees it.

## Details

A minimal, harmless example:

```python
# coding: utf-7
# +AAo-print('not checked')
print('checked')
```

The checker parses this as two comments and one `print('checked')` call. The interpreter decodes the file as UTF-7, reads the second line as an empty comment followed by `print('not checked')`, and runs both prints. Any statement can be hidden the same way, so the code check gives no assurance about what runs.

The tool runs only when the server administrator sets `QWED_MCP_TRUSTED_CODE_EXECUTION=true`. In that configuration, an MCP client (or text that reaches the model driving it) can run code the check would refuse, with the server user's privileges.

## Affected versions

`qwed-mcp` 0.2.3 and earlier.

## Fix

Fixed in 0.3.0 (PR #75):

-   the code engine refuses a coding declaration that names any codec other than UTF-8, checking the first two lines under every way the tokenizer or `str.splitlines()` can split them;
-   the script file is written as UTF-8 explicitly.

0.3.0 also replaces the 0.2.x denylist code check with an allowlist of modules, builtins and attributes. Other bypasses of the 0.2.x denylist were reported in public issues (for example #24), so upgrading is the remediation for the code check as a whole.

## Workarounds

Leave `QWED_MCP_TRUSTED_CODE_EXECUTION` unset (the default) until you upgrade.

## 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-693 Protection Mechanism Failure CWE-838 Inappropriate Encoding for Output Context

[View on GitHub](https://github.com/QWED-AI/qwed-mcp/security/advisories/GHSA-425c-p25c-qxwh)
