Skip to content

The agent that grows with you

fix(cron): reject NUL-bearing script paths before any Path call (#76762 class)

SHT40586082e5a9
diff --git a/cron/scheduler.py b/cron/scheduler.py
index 6598f0e102b..a6cab6a6ee2 100644
--- a/cron/scheduler.py
+++ b/cron/scheduler.py
@@ -3199,6 +3199,14 @@ def _run_job_script(
scripts_dir.mkdir(parents=True, exist_ok=True)
scripts_dir_resolved = scripts_dir.resolve()
+ # Same ingestion contract as cron.lifecycle_guard._expand_candidate_path:
+ # a NUL-bearing value can never name a real script, and on Windows the
+ # Path operations raise ValueError *after* expanduser (expanduser never
+ # expands "~user" there, so the try below never fires) — reject eagerly
+ # so both platforms fail cleanly instead of crashing the scheduler.
+ if "\x00" in script_path:
+ return False, f"Blocked: script path contains a NUL byte: {script_path!r}"
+
try:
raw = Path(script_path).expanduser()
except (ValueError, RuntimeError, OSError):