Summary
Hermes-agent's Skills Guard Multi-Word Prompt Handler contains an injection flaw in the handling of the THREAT_PATTERNS argument, allowing untrusted input to be interpreted in a more powerful context than intended.
A remote attacker who can influence or control THREAT_PATTERNS can potentially inject crafted patterns that bypass or subvert the guard's logic, leading to unauthorized actions or unsafe prompt handling.
Affected context
The vulnerability resides in the file agent/skills_guard.py, specifically within the Skills Guard Multi-Word Prompt Handler that uses the THREAT_PATTERNS argument to detect or block unsafe content.
It is relevant wherever:
- The agent relies on pattern-based filtering or guarding of prompts or skills
- THREAT_PATTERNS can be influenced by external input (configuration, API parameters, or user-controlled data)
- The guard logic interprets these patterns in a way that affects downstream behavior, routing, or execution
Exploit preconditions
- Attack surface: Remote interfaces that accept or indirectly influence THREAT_PATTERNS (e.g., configuration APIs, plugin inputs, or user-supplied prompt metadata).
- Required access: Ability to supply or modify THREAT_PATTERNS values or any input that the guard uses to build or extend this structure.
- Trigger point: Invocation of the Skills Guard Multi-Word Prompt Handler in
skills_guard.pywhere THREAT_PATTERNS is parsed, interpolated, or evaluated. - Why exploitation is possible: The guard logic does not sufficiently neutralize or constrain THREAT_PATTERNS before using it in pattern matching or other interpretation steps, permitting crafted input to alter control flow or neutralization behavior (CWE-74/CWE-707).
Why this happens
The underlying issue stems from improper neutralization and validation of inputs that are used as patterns or rules inside the Skills Guard.
THREAT_PATTERNS, intended to be a declarative list or structure describing threats, is treated in a way that allows embedded control characters, wildcards, or meta-syntax to influence how the guard processes content.
This maps to CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component) and CWE-707 (Improper Neutralization) where untrusted data is passed into a component (such as a pattern engine, interpreter, or router) without sufficient sanitization, causing the downstream component to execute or interpret the data differently than intended.
Potential impact
- Attackers may craft THREAT_PATTERNS that disable or bypass the Skills Guard, allowing unsafe prompts or actions to proceed unchecked.
- The guard may misclassify benign content as malicious or vice versa, leading to denial of service or unpredictable behavior.
- Malicious patterns can cause the agent to route requests to unintended skills or workflows, potentially triggering unauthorized operations.
- In broader deployments, compromised guard behavior could lead to data exposure, execution of unintended automation tasks, or integration misuse.
General mitigation guidance
Effective mitigation focuses on constraining how THREAT_PATTERNS are defined, parsed, and used:
- Treat all pattern definitions as untrusted input and apply strict validation, allowing only a limited, documented subset of characters and structures.
- Use safe, declarative pattern formats that avoid executable or interpretable sub-syntax, and avoid passing patterns directly into generic interpreters or evaluators.
- Normalize and canonicalize input before pattern evaluation so that alternative encodings or obfuscations do not escape guard logic.
- Apply least-privilege design to skills and downstream actions so that a guard failure does not automatically imply high-impact actions.
- Centralize guard logic and enforce default-deny behavior when pattern definitions are invalid, malformed, or untrusted rather than attempting best-effort parsing.
How teams detect issues like this
Detection typically involves both code-centric and behavior-centric approaches:
- Perform static analysis to identify use of untrusted data in pattern engines, regular expressions, or other interpretive contexts, especially where THREAT_PATTERNS or similar constructs are used.
- During code review, look for direct inclusion of user-controlled values in pattern strings, regular expressions, or routing tables without normalization or whitelisting.
- Add logging and monitoring around guard decisions, flagging unusual THREAT_PATTERNS or sudden shifts in classification rates that may indicate exploitation.
- Incorporate automated policy checks in CI/CD pipelines to enforce safe pattern APIs, disallow dynamic evaluation, and ensure that pattern sources are appropriately constrained.

