GHSA-2P94-5932-5F3P
Surfacing daemon and generated registrations run `python -m` with the project directory on sys.path
Texto original en inglés · Ver en español
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-2P94-5932-5F3P divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The surfacing daemon is started as `python -m memtomem_stm daemon run --detached` with the
hook process's working directory inherited. Under `-m`, Python puts the working directory at
`sys.path[0]`, ahead of the standard library and site-packages, so a module in the project
directory is imported instead of the installed one. Opening an untrusted checkout in a host
that has the `mms hook` PostToolUse hook installed can therefore run code from that checkout
as the user.
The 0.7.3 fix for GHSA-hqh4-75hx-xq46 hardened executable lookup (`PATH`); it does not
change `sys.path`.
Details
- `src/memtomem_stm/daemon/spawn.py:33` builds
- It is reached from `src/memtomem_stm/cli/hook_cmd.py:686-690` when no warm daemon answers.
- The console-script entry points (`mms`, `memtomem-stm`, `memtomem-stm-proxy`) are not
Same launch shape, confirmed by reading the source but not run end to end:
- `src/memtomem_stm/cli/proxy.py:978` (`_registration_command`) registers
- `src/memtomem_stm/cli/proxy.py:6549` configures the bundled demo upstream as
Reproduction (0.7.7 source at 38a605af, macOS, Python 3.13.2)
- In an empty directory create `memtomem_stm/__init__.py` (empty) and
- With a fresh `HOME` (so no daemon is running) and default configuration, run from that
- The marker file appears; the shadow `__main__` received
A directory holding only `click.py` is enough as well: `python -m memtomem_stm --help` from
there imports it. So is a `types.py`, in an environment that has not already loaded `types`
at startup (a plain `python -m venv`).
Controls, all negative: the same command from an empty directory; the `mms` console script
from the shadow directories; `python -P -m memtomem_stm` from the shadow directories.
Impact
Arbitrary code execution as the user, in a detached process, on the first eligible tool call
(`Read`, `Grep`, `Glob`, `Bash` by default) made in an untrusted project directory while no
daemon for the current configuration is alive. A project that merely has a top-level module
whose name collides with something the daemon imports also breaks daemon startup there.
Fix
Every interpreter STM starts or registers is launched with `-P` (`safe_module_argv()` in
`src/memtomem_stm/utils/exec_env.py`), so Python no longer puts the working directory first on
its import path. A `PYTHONPATH` entry that names the working directory still applies; that is
the user's own environment.
An in-process guard (removing the working directory from `sys.path` at the top of the entry
modules) was tried and dropped: Python imports from the working directory before any STM code
runs (`runpy` needs `types`, among others), so in a plain venv a project `types.py` still ran.
Remediation after upgrading
Existing registrations are kept on upgrade and still start without `-P`. STM cannot protect
such a launch from inside, so each one has to be refreshed, passing the same `--config <path>`
if the registration uses a non-default config:
- project `.mcp.json`: from that project, `mms register --client json --replace-registration`
- Claude Code user scope: `mms register --client claude --replace-registration`;
- Codex: `mms register --client codex --replace-registration`;
- a host config edited or copied by hand: insert `"-P"` before `"-m"` in the entry's `args`;
- the demo upstream: set `upstream_servers.demo.args` in `stm_proxy.json` to
Verification status
Verified locally on macOS (Python 3.12, 3.13, 3.14). Windows is unverified until the
post-merge CI matrix runs; `-P` is an interpreter flag with no platform-specific behaviour.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
PyPImemtomem-stm |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/memtomem/memtomem-stm/security/advisories/GHSA-2p94-5932-5f3pLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
