Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

security: block extra_args from bypassing codec allowlist

ZJZACad83a3228334
diff --git a/kdenlive/agent-harness/cli_anything/kdenlive/utils/melt_backend.py b/kdenlive/agent-harness/cli_anything/kdenlive/utils/melt_backend.py
index a1709f79a..0f3eb91b4 100644
--- a/kdenlive/agent-harness/cli_anything/kdenlive/utils/melt_backend.py
+++ b/kdenlive/agent-harness/cli_anything/kdenlive/utils/melt_backend.py
@@ -48,6 +48,22 @@ def _validate_codec(value: str, allowed: frozenset, label: str) -> str:
return value
+# Arguments that could override validated codec or consumer settings.
+_BLOCKED_ARG_PREFIXES = ("vcodec=", "acodec=", "-consumer")
+
+
+def _validate_extra_args(extra_args: list) -> list:
+ """Reject extra_args that would bypass codec or consumer validation."""
+ for arg in extra_args:
+ for prefix in _BLOCKED_ARG_PREFIXES:
+ if arg.startswith(prefix):
+ raise ValueError(
+ f"extra_args cannot override '{prefix.rstrip('=')}'. "
+ f"Use the dedicated parameter instead."
+ )
+ return extra_args
+
+
def find_melt() -> str:
"""Find the melt executable. Raises RuntimeError if not found."""
path = shutil.which("melt")
@@ -122,6 +138,7 @@ def render_mlt(
]
if extra_args:
+ _validate_extra_args(extra_args)
cmd.extend(extra_args)
result = subprocess.run(
diff --git a/shotcut/agent-harness/cli_anything/shotcut/utils/melt_backend.py b/shotcut/agent-harness/cli_anything/shotcut/utils/melt_backend.py
index 56366fcac..757f2f6d6 100644
--- a/shotcut/agent-harness/cli_anything/shotcut/utils/melt_backend.py
+++ b/shotcut/agent-harness/cli_anything/shotcut/utils/melt_backend.py
@@ -43,6 +43,21 @@ def _validate_codec(value: str, allowed: frozenset, label: str) -> str:
return value
+_BLOCKED_ARG_PREFIXES = ("vcodec=", "acodec=", "-consumer")
+
+
+def _validate_extra_args(extra_args: list) -> list:
+ """Reject extra_args that would bypass codec or consumer validation."""
+ for arg in extra_args:
+ for prefix in _BLOCKED_ARG_PREFIXES:
+ if arg.startswith(prefix):
+ raise ValueError(
+ f"extra_args cannot override '{prefix.rstrip('=')}'. "
+ f"Use the dedicated parameter instead."
+ )
+ return extra_args
+
+
def find_melt() -> str:
"""Find the melt executable. Raises RuntimeError if not found."""
path = shutil.which("melt")
@@ -117,6 +132,7 @@ def render_mlt(
]
if extra_args:
+ _validate_extra_args(extra_args)
cmd.extend(extra_args)
result = subprocess.run(