fix(cron): prevent lifecycle guard crash on binary remote-read paths - #79041
fix(cron): prevent lifecycle guard crash on binary remote-read paths#79041o269 wants to merge 1 commit into
Conversation
When the gateway terminal tool scans shell scripts that reference system binaries (e.g. /usr/bin/flock in godmode-bus watchdog scripts), the remote-read callback decodes ELF contents with NUL bytes intact. Tokenizing that machine code produced paths with embedded NULs, causing os.open to raise ValueError and block every terminal command until gateway recovery. - Catch ValueError alongside OSError in _read_referenced_script os.open - Skip remote-read content that contains NUL bytes (binary → nothing to scan) - Strip NUL bytes in _iter_command_segments before tokenization - Strip NUL bytes in _resolve_script_path for cron script values Fixes godmode-bus/bin/*.sh execution via Hermes terminal tool (NousResearch#76762). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Closing as superseded by #80258, which fixes this whole bug class architecturally rather than per-callsite: path candidates are sanitized once at the ingestion boundary (NUL/empty/unexpandable tokens rejected before any OS call), text from any Your report and fix targeted a real member of this class — thank you. The per-callsite patches kept leaving sibling frames exposed (#76762 → #77703 → #77780 → #78256 each crashed one frame away from the previous fix), which is why we went with the boundary fix instead of merging the fragments individually. #80258 carries regression tests for the NUL-path, binary-callback, oversized-read, unset-HOME, and walk-crash cases plus an adversarial never-raises sweep. |
Summary
ValueError: embedded null bytecrash incron/lifecycle_guard.pywhen the gateway terminal tool scans shell scripts that reference system binaries (e.g./usr/bin/flockingodmode-bus/bin/disk-watchdog.sh)_read_referenced_scriptcorrectly skips local binary reads, but theread_remote_scriptcallback (used byterminal_tool.pyin_HERMES_GATEWAYsessions) decodes ELF contents with NUL bytes intact; tokenizing that machine code produced paths with embedded NULs, crashingos.open/tmpfirst (bypasses the recursive binary scan path)Fix (3 defensive layers, same class as #76762)
_iter_command_segments()\x00before tokenization_read_referenced_script()except (OSError, ValueError)atos.open_contains_unsafe_gateway_action()_resolve_script_path()Path()constructionTest plan
tests/hermes_cli/test_gateway_restart_loop.py— 84 passedtest_remote_read_of_binary_does_not_crash_the_guard(ELF via remote callback)test_shell_script_referencing_system_binary_does_not_crash_guard(flock-shaped godmode-bus script)bash ~/godmode-bus/bin/disk-watchdog.shwithread_remote_scriptcallback → no crashMade with Cursor