Skip to content

fix(guard): catch ValueError from os.open on NUL-containing paths (#77780) - #77806

Closed
RelaxJonh wants to merge 1 commit into
NousResearch:mainfrom
RelaxJonh:fix/lifecycle-guard-null-byte-77780
Closed

fix(guard): catch ValueError from os.open on NUL-containing paths (#77780)#77806
RelaxJonh wants to merge 1 commit into
NousResearch:mainfrom
RelaxJonh:fix/lifecycle-guard-null-byte-77780

Conversation

@RelaxJonh

Copy link
Copy Markdown
Contributor

Fixes #77780

_read_referenced_script() in cron/lifecycle_guard.py calls os.open(path, flags) but only catches OSError. When the path contains an embedded NUL byte (from binary content tokenized as a script path), os.open() raises ValueError: embedded null byte which propagates uncaught through contains_gateway_lifecycle_command_or_referenced_scriptterminal_tool, blocking all subsequent terminal commands.

The caller at line 318 already handles ValueError for script_path.resolve(), but the os.open() call at line 260 was missed.

Fix

Add ValueError to the except clause at lifecycle_guard.py:261, matching the existing pattern at line 318.

…usResearch#77780)

os.open() raises ValueError when the path contains an embedded NUL
byte, but _read_referenced_script only caught OSError. Add ValueError
to the except clause to prevent the guard from crashing.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management tool/terminal Terminal execution and process management duplicate This issue or pull request already exists labels Aug 3, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #77729: its current open patch includes this os.open ValueError guard as well as the related remote-read binary handling and regression coverage. #77806 remains a focused fix for #77780.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lifecycle_guard crashes on ValueError: embedded null byte from os.open — breaks all terminal commands

3 participants