fix(terminal): block sudo -S password guessing when SUDO_PASSWORD is unset - #22194
Closed
29206394 wants to merge 1 commit into
Closed
fix(terminal): block sudo -S password guessing when SUDO_PASSWORD is unset#2219429206394 wants to merge 1 commit into
29206394 wants to merge 1 commit into
Conversation
…not set Fixes NousResearch#9590: Block explicit sudo -S (stdin password mode) commands when the SUDO_PASSWORD environment variable is not configured. The attack vector: the LLM constructs 'echo guessedpass | sudo -S cmd' to brute-force sudo passwords, iterates based on sudo's error output ('Sorry, try again'). The existing _transform_sudo_command only injects -S when SUDO_PASSWORD exists; without it, the LLM's explicit sudo -S must be treated as a guessing attempt. Changes: - Add _check_sudo_stdin_guard() in approval.py: detects sudo -S when SUDO_PASSWORD is absent, anchored to command-start positions (^ ; && || | etc.) to avoid false positives on literal text - Integrate into check_all_command_guards() above yolo/mode=off so the block is unconditional (like the hardline floor) - Add 6 tests covering: detection, allow-list, SUDO_PASSWORD bypass, integration with check_all_command_guards, yolo non-bypass, container backend bypass
10 tasks
This was referenced May 11, 2026
Collaborator
|
Merged via #23736 (salvage: cherry-picked onto current main). Your commit authorship preserved in git log. Thanks for the fix! |
JinyuID
pushed a commit
to JinyuID/hermes-agent
that referenced
this pull request
May 11, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
AlexFoxD
pushed a commit
to AlexFoxD/hermes-agent
that referenced
this pull request
May 21, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
Seven74AI
pushed a commit
to Seven74AI/hermes-agent
that referenced
this pull request
Jun 13, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
T02200059
pushed a commit
to T02200059/hermes-agent
that referenced
this pull request
Jun 18, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
- openclaw@agent.local → 29206394 (PR NousResearch#22194) - freedemon@gmail.com → fr33d3m0n (PR NousResearch#21128)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (fixes #9590)
The LLM can brute-force sudo passwords by iterating:
The existing
_transform_sudo_commandonly injects-SwhenSUDO_PASSWORDis configured. Without it, any explicitsudo -Sin the command is the LLM piping a guessed password — a brute-force attack vector.Fix
Add a
_check_sudo_stdin_guard()intools/approval.py:sudo -S(stdin password flag) whenSUDO_PASSWORDenv var is not set^ ; && || |etc.) to avoid false positives on literal text mentionscheck_all_command_guards()above yolo/mode=off, like the hardline floor — this is never legitimateWhen
SUDO_PASSWORDIS set, the guard is bypassed (the system itself injects-Sin that case, which is legitimate).Changes
tools/approval.pytests/tools/test_hardline_blocklist.pyTests (6 new, all pass — 246 total in related suites)
sudo -S, piped variants, compound commands with&&sudo,-Son other tools, literal echo textcheck_all_command_guardsreturns block resultHERMES_YOLO_MODE=1still blocked