/

CVE-2026-10221

Severity:

HIGH RISK

(7.3)

Injection in NousResearch hermes-agent _compress_context

CVE-2026-10221

Deferred

Vulnerability type

Category:

Injection

CWE:

CWE-74, CWE-707

Impact:

Injection Leading to Unauthorized Actions or Code Execution, Depending on Integration

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

NousResearch hermes-agent up to version 0.12.0 contains an injection vulnerability in the _compress_context function of run_agent.py, where untrusted data is combined into a context string without adequate sanitization.

In deployments where remote input can influence the compressed context, an attacker may inject crafted content that alters downstream processing or execution, potentially leading to unauthorized actions in high-privilege environments.

Affected context

This issue affects deployments of hermes-agent (up to 0.12.0) that:

  • Accept remote or otherwise untrusted input that is incorporated into the agent's context
  • Use the _compress_context function in run_agent.py to condense or transform conversation/context data
  • Pass the resulting compressed context into downstream components (e.g., command runners, template engines, interpreters, or external tools) without strict separation between data and control

The risk is heightened where the agent has access to sensitive systems or automation hooks that act on its generated outputs.

Exploit preconditions

  • Attack surface: Remote, via interfaces (API endpoints, chat connectors, webhooks, or integrations) that feed user-controlled data into hermes-agent.
  • Required access: Ability to submit or influence content that will be processed by _compress_context, such as messages, prompts, or external event payloads.
  • Trigger point: Invocation of _compress_context during context building or truncation, after which the compressed context is used by downstream logic or tools.
  • Why exploitation is possible: The implementation does not sufficiently neutralize or encode control syntax when merging user-controlled content into a composite context string, allowing attacker-supplied fragments to be interpreted as commands, directives, or structured control tokens by subsequent consumers.

Why this happens

The core issue is an injection flaw consistent with CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.

The _compress_context function combines multiple pieces of data into a unified context representation but fails to robustly escape, encode, or separate user-controlled content from control or structural syntax.

As a result, when this compressed context is later consumed by a parser, interpreter, tool framework, or automation layer, embedded special characters or control sequences can change behavior instead of remaining inert data.

This pattern also relates to CWE-707: Improper Neutralization, as it reflects a broader failure to consistently handle dangerous characters across the data transformation pipeline.

Potential impact

  • An attacker may inject specially crafted content that alters the behavior of downstream tools or automation wired to the agent.
  • Injected payloads could cause unintended commands to be executed by integrated systems (e.g., shell commands, API calls, or administrative actions), depending on the environment.
  • The agent's decision-making or response generation can be steered toward attacker-controlled objectives, potentially leading to data exposure or integrity violations.
  • In tightly integrated environments, the issue may contribute to a broader compromise of connected services or workflows.

General mitigation guidance

Effective mitigation focuses on treating all context fragments derived from untrusted sources as data, never control, and enforcing strict neutralization at the boundaries where context is constructed:

  • Robust encoding and escaping: Normalize and escape special characters in user-controlled values before they are merged into the compressed context, especially characters that are meaningful to downstream parsers, interpreters, or template engines.
  • Structured representations: Prefer structured data (e.g., JSON objects, typed records) rather than ad-hoc string concatenation when representing context; let downstream components consume well-defined fields instead of parsing free-form text for control semantics.
  • Layered trust boundaries: Clearly separate trusted system metadata from untrusted user content; avoid mixing them in the same field or format where control tokens and data interleave.
  • Least-privilege integrations: Configure any tools, connectors, or automation that act on agent outputs with minimal required permissions, limiting the blast radius of any injected behavior.
  • Input validation policies: Apply conservative size limits and content validation (e.g., allowed character sets, disallowed control sequences) on input that will be fed into context compression.

How teams detect issues like this

Detection efforts can focus on identifying risky string handling patterns and validating how compressed context is consumed:

  • Static analysis: Flag locations in run_agent.py and related modules where user-controlled data is concatenated, interpolated, or formatted into context strings without escaping or encoding, especially before passing to downstream interpreters or tools.
  • Code review signals: During review, pay attention to helper functions like _compress_context that aggregate large amounts of user-driven content; ensure they apply a consistent neutralization strategy and treat all untrusted input as opaque data.
  • Policy enforcement: Introduce guidelines that prohibit direct string-based command construction or protocol framing from agent context, enforcing the use of structured APIs or parameterized interfaces for all external actions.
  • Runtime monitoring: Instrument logging for anomalous or unusually structured context segments and for unexpected downstream operations originating from agent-driven workflows; use these traces to refine validation rules.

Sources

SourceLink
gist.github.comgist.github.com/YLChen-007/d343fcfe2c009cd45f56dc475fd5ac03
vuldb.comvuldb.com/cve/CVE-2026-10221
vuldb.comvuldb.com/submit/822019
vuldb.comvuldb.com/vuln/367500
vuldb.comvuldb.com/vuln/367500/cti

Frequently asked

questions

Yes. Wherever hermes-agent accepts remote or otherwise untrusted input that flows into the _compress_context function, an attacker can attempt to craft payloads that trigger injection in downstream consumers of the compressed context.

The attacker typically needs only the ability to send or influence inputs processed by the agent (such as messages, prompts, or integration payloads). No local system access is required if the agent is exposed through an API or external integration.

The most robust fix is to treat context as structured data instead of free-form concatenated strings, applying strict escaping or encoding to all user-controlled fields and ensuring downstream components consume typed fields via parameterized interfaces rather than parsing control syntax from the compressed context.

To prevent similar vulnerabilities, adopt a consistent neutralization strategy for all data entering agent context, avoid mixing control tokens with user data, enforce code review rules around string construction and external calls, and favor structured, parameterized APIs over ad-hoc string-based protocols or commands.

Find out what's already
exploitable in your codebase.