Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cron/lifecycle_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ def _read_referenced_script(path: Path) -> tuple[Optional[str], bool]:
flags = os.O_RDONLY | getattr(os, "O_NONBLOCK", 0)
try:
descriptor = os.open(path, flags)
except OSError:
except (OSError, ValueError):
# OSError: unreadable/long paths. ValueError: a path containing an
# embedded NUL byte (e.g. a binary's decoded contents tokenized as a
# path) — os.open raises ValueError for those, and a guarded path
# must never crash the guard (#76762). Treat both as "nothing to scan".
return None, False
try:
metadata = os.fstat(descriptor)
Expand Down Expand Up @@ -327,6 +331,12 @@ def _contains_unsafe_gateway_action(
if script_text is None and read_remote_script is not None:
# Local path missing; try the remote backend if one is available.
script_text = read_remote_script(str(script_path))
# The remote fallback may return raw binary decoded as text (e.g.
# `cat` of an ELF executable). NUL bytes mean binary — treat as
# "nothing to scan", mirroring the local-path NUL guard above,
# so a binary can't explode the recursion or false-positive.
if script_text and "\x00" in script_text:
script_text = None
if not script_text:
continue
# Relative references inside a script resolve against that script's
Expand Down