AAP-003: Tool Parameter Tampering & Shell Built-in Bypass
HERMES AGENTIC SECURITY SCORE & RISK
Target:Agentic Terminal Tools & Command Allowlist Runners HASS classifies AAP-003 as EXTREME (91/100). The attack abuses the agent's autonomous execution loop (such as Auto-Run mode), enabling an external attacker to execute arbitrary OS commands without user confirmation by poisoning environment variables in a stateful shell session.
AAP-003: Tool Parameter Tampering & Built-in BypassAGENTIC ATTACK_PATTERN
2. Attack Flow Execution Chain
Section titled β2. Attack Flow Execution ChainβAAP-003: Environment Variable Poisoning to Host Compromise
Agent Context Window Adversary implants hidden prompt instructions into a project file, pull request diff, or external documentation instructing the agent to set an environment variable.
Terminal Allowlist Filter Agent issues a shell built-in command (e.g. export BASH_ENV=/tmp/payload.sh). Because export is an internal shell primitive rather than an external binary file, the allowlist permits it without prompting.
Interactive Subshell Process The persistent terminal subshell registers BASH_ENV. Any subsequent non-interactive subshell invocation will automatically source and execute the target script.
Whitelisted Binary (e.g. git) Agent issues a harmless, pre-approved command (such as git branch or npm test). The spawned subshell evaluates BASH_ENV and executes the adversary's payload.
Developer Host OS The payload executes with the developer's full desktop permissions, establishing an outbound reverse shell and granting complete system access.
3. Technical Mechanism & Root Cause
Section titled β3. Technical Mechanism & Root CauseβThe vulnerability arises from a semantic discrepancy between path-based binary allowlisting and stateful shell execution semantics:
- Client-Side String Filtering: Many agentic IDEs and command-line agents (such as Cursor prior to v2.3, documented in CVE-2026-22708) evaluate terminal commands by inspecting the leading token against an allowlist of approved developer utilities:
// Vulnerable Pattern: Leading token check allows shell built-insconst isAllowed = ['git', 'npm', 'pytest', 'ls', 'cat'].includes(command.split(' ')[0]);
- Built-ins are Not Binaries: POSIX shells implement commands like
export,typeset,declare,set, andaliasas built-in functions inside the shell process itself. If the filter fails to block built-ins, the command executes without human confirmation. - Stateful Session Persistence: When an agent runs inside a persistent terminal rather than a stateless container, variable mutations alter the execution environment of all future commands.
4. Detection Engineering
Section titled β4. Detection Engineeringβtitle: Shell Built-in Environment Manipulation in Agent Sessionid: 4b21c910-c124-4f56-91e8-348b6c003001status: productiondescription: Detects command-line executions manipulating sensitive shell environment variables (BASH_ENV, PROMPT_COMMAND, LD_PRELOAD) from IDE child processes.references: - https://hermes-codex.vercel.app/agentic-attack-patterns/aap-003-tool-parameter-tampering/ - https://hermes-codex.vercel.app/cve/2026/cve-2026-22708/author: Hermes Codex AI Security Labdate: 2026-09-07logsource: category: process_creation product: linuxdetection: selection_parent: ParentImage|contains: - 'cursor' - 'code' - 'windsurf' - 'electron' selection_cmd: CommandLine|contains: - 'export BASH_ENV=' - 'export PROMPT_COMMAND=' - 'export LD_PRELOAD=' - 'export PYTHONPATH=' - 'typeset -x BASH_ENV' - 'declare -x BASH_ENV' condition: selection_parent and selection_cmdfields: - ParentImage - CommandLine - Userlevel: criticaltags: - attack.execution - attack.t1059.004 - hermes.aap-003-- Detect active developer shell processes with poisoned BASH_ENV or LD_PRELOADSELECT p.pid, p.name, p.cmdline, pe.key, pe.valueFROM processes pJOIN process_envs pe ON p.pid = pe.pidWHERE pe.key IN ('BASH_ENV', 'PROMPT_COMMAND', 'LD_PRELOAD', 'NODE_OPTIONS') AND (pe.value LIKE '/tmp/%' OR pe.value LIKE '/dev/shm/%' OR pe.value LIKE '%.sh');5. Hardened Mitigations
Section titled β5. Hardened Mitigationsβ| Defensive Layer | Recommendation | Implementation Technique |
|---|---|---|
| Stateless Execution | Enforce ephemeral subshells | Execute every agent tool call using env -i /bin/bash -c ... to purge inherited environment state. |
| AST-Level Tokenization | Parse shell syntax trees | Use formal shell parsers (bash-parser or tree-sitter) to identify built-ins, pipes, and variable assignments before execution. |
| Mandatory HITL Gating | Disable Auto-Run for built-ins | Enforce Human-in-the-Loop confirmation for any command altering shell state. |
| MicroVM Sandboxing | Contain tool execution | Confine agent workspaces inside ephemeral Dev Containers or microVMs with no access to host credentials. |