# GHSA-Q32H-G32V-C59G: Local code execution via a predictable, unchecked generated-templates directory in the shared temp dir (SSTI/RCE on multi-user hosts)

- Database: GitHub
- Severity: low (stated by ghsa, no CVSS score)
- Published: 2026-11-04
- Modified: 2026-11-04

## Affected versions

- potato-annotation (PyPI): through 2.13.1

## Description

### Summary

When potato is installed read-only (an ordinary non-root pip install, or a container — the project's own comment states this is the normal case), generated Jinja templates are written to a predictably named directory in the shared temp dir, created with no owner/permission check. A co-located local user can pre-create that directory (or swap files in it) and plant a Jinja template; potato renders it with render_template, giving server-side template injection → code execution as the potato user

### Details

potato/server_utils/generated_templates.py:

_fallback_dir() (L66–69): `os.path.join(tempfile.gettempdir(), f"potato-templates-{sha256(abspath(pkg))[:12]}")` — the name is fully determined by the (known) install path.
`resolve_generated_templates_dir()` (L72): if the package dir is not writable → `_fallback_dir(); then os.makedirs(chosen, exist_ok=True) (L97)` — no owner or mode check, reuses a pre-existing directory.
The generator writes site templates into that directory (potato/server_utils/front_end.py L537/L541, L773/L778), and the loader reads them back from the same resolver (potato/flask_server.py L340) and `renders: rendered_html = render_template(html_fname, **context)` (flask_server.py L3366)

### Proof of concept

```text
1 predictable name          : app and attacker compute the same potato-templates-<digest>
2 non-writable pkg          : resolver routes to the shared-temp fallback (True)
3 reuse attacker dir        : app reuses attacker-pre-created dir; loader returns the attacker file (True)
4 TOCTOU swap               : attacker replaces the app-baked template (True)
5 SSTI executes (jinja2 3.1.6): render output -> '<html>POTATO-RCE-PROOF uid=501\n</html>'
POTATO /tmp HIJACK CONFIRMED : True   |   SSTI execution step : True
```

### Impact

On a shared multi-user host (e.g. a university server) where potato is installed system-wide and run by user A, a second local user B pre-creates the predictable directory (B owns it) and plants/swaps a Jinja template. When A's server renders the annotation page, B's template code runs as A — local RCE / privilege movement.

Found by static analysis with Auditmind (flags a predictable file/dir in a world-writable temp location used without an owner/permission check) and confirmed

## References

- https://github.com/davidjurgens/potato/security/advisories/GHSA-q32h-g32v-c59g

Page: https://cve.now/GHSA-Q32H-G32V-C59G

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
