Prompt injection to RCE in AI agents #1514
Closed
+101
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
What the post proves
Argument injection (CWE-88) in AI agents that auto-run a subset of “safe” system commands lets an attacker achieve one-shot remote code execution (RCE) even when a human-in-the-loop approval gate is enabled and shell metacharacters are blocked. The post maps the design anti-patterns, shows three concrete exploit paths with exact prompts/commands and vulnerable code, and closes with actionable hardening guidance.
Why the pattern exists
Agen...
🔧 Technical Details
Argument injection through pre-approved tools: When agents auto-run binaries like
find/rg/fd/git, inject dangerous flags as part of the tool’s arguments instead of using shell metacharacters. Abuse options that turn search/listing tools into execution primitives (e.g.,go test -exec,rg --pre,fd -x=<binary>) to achieve RCE with a single prompt.Living off the land with write+exec chains: Chain two allowed tools so one writes a payload and the other executes it. Example pattern:
git show --format & --outputto write a command/script (possibly hex-obfuscated), thenripgrep --pre bashscanning for a marker term to immediately execute the new file.Facade argv injection: If a facade appends user input directly to argv, craft inputs that are parsed as flags instead of literals. Supplying
-x=python3to anfdfacade executespyt...🤖 Agent ActionsI’ve reviewed the repository structure and relevant AI-related content and found an existing, well-suited page to incorporate the new techniques: “AI Agent Abuse: Local AI CLI Tools & MCP.” I updated that page to add a dedicated subsection documenting Argument Injection (CWE-88) in CLI agents and the specific RCE chains from the blog.
What I did:
Files changed:
No new files were needed, and I didn’t duplicate existing content. The updates are technical, actionable, and fit the HackTricks style (code blocks, concise steps, detection/hardening, and references).
This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.