Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

fix(image): tighten mflux_python_path validator to mflux-generate* only

mrbizarrof0c8a4d36694
diff --git a/agent/image_engine.py b/agent/image_engine.py
index 81505c1..8a66690 100644
--- a/agent/image_engine.py
+++ b/agent/image_engine.py
@@ -348,16 +348,17 @@ def _resolve_mflux_bin(config: ImageEngineConfig) -> str | None:
# Defensive re-validation at exec time. Save-time
# (_validate_mflux_python_path in mlx_ltx_panel.py) already
# gates this field, but the file may have been deleted between
- # save and use, or an older config may pre-date the gate. Only
- # accept absolute paths to existing executable files whose
- # basename starts with python3 or mflux-generate. Anything
- # else: fall back silently to the panel's bundled venv.
+ # save and use, or an older config may pre-date the gate. The
+ # exec call site below treats this as the mflux CLI binary
+ # (not a Python interpreter), so we only accept mflux-generate*
+ # names. Anything else (including legacy python3 entries from
+ # before the validator was tightened): fall back silently to
+ # the panel's bundled venv.
cand = Path(config.mflux_python_path)
if (cand.is_absolute()
and cand.is_file()
and os.access(cand, os.X_OK)
- and (cand.name.startswith("python3")
- or cand.name.startswith("mflux-generate"))):
+ and cand.name.startswith("mflux-generate")):
return str(cand)
repo_root = Path(__file__).resolve().parent.parent
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index 4a8b113..72be2e3 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -4582,11 +4582,19 @@ def _validate_mflux_python_path(value: str) -> str:
the next mflux call would exec it (defense-in-depth on top of the
CSRF gate in `_is_local_request`).
+ The field name is misleading — it is NOT a Python interpreter path.
+ The execution path in agent/image_engine.py runs
+ `[bin_path, "--model", ...]`, which is the mflux CLI's argv
+ convention, not python3's. Accepting `python3` here let the user
+ save a value that immediately failed at exec time. Tighten the
+ allowlist to mflux-generate* binaries only.
+
Acceptable values:
- "" → cleared, falls back to the panel's bundled venv
- An absolute path that EXISTS, is a regular file, is executable
- by the user, AND whose basename starts with `python3` /
- `mflux-generate` (the only binaries we ever spawn).
+ by the user, AND whose basename starts with `mflux-generate`
+ (covers mflux-generate, mflux-generate-flux2,
+ mflux-generate-qwen-edit, etc.).
Anything else raises ValueError → caller maps to HTTP 400.
"""
s = (value or "").strip()
@@ -4595,8 +4603,9 @@ def _validate_mflux_python_path(value: str) -> str:
p = Path(s)
if not p.is_absolute():
raise ValueError(
- "mflux_python_path must be an absolute path to a python3 "
- "or mflux-generate executable in a venv bin directory"
+ "mflux_python_path must be an absolute path to an "
+ "mflux-generate* binary (the field name is misleading; "
+ "this is the mflux CLI, not the Python interpreter)"
)
try:
rp = p.resolve()
@@ -4604,14 +4613,16 @@ def _validate_mflux_python_path(value: str) -> str:
raise ValueError(f"mflux_python_path is not resolvable: {e}")
if not rp.is_file() or not os.access(rp, os.X_OK):
raise ValueError(
- "mflux_python_path must be an existing python3 executable "
- "in a venv bin directory"
+ "mflux_python_path must point at an existing executable "
+ "mflux-generate* binary in a venv bin directory"
)
name = rp.name
- if not (name.startswith("python3") or name.startswith("mflux-generate")):
+ if not name.startswith("mflux-generate"):
raise ValueError(
- "mflux_python_path basename must start with 'python3' or "
- "'mflux-generate' (a venv bin entry)"
+ "mflux_python_path basename must start with 'mflux-generate' "
+ "(the field name is misleading; this is the mflux CLI, not "
+ "a Python interpreter — point it at e.g. "
+ "<venv>/bin/mflux-generate-qwen-edit)"
)
return str(rp)