cot-injection

Tests Chain-of-Thought and ReAct agent reasoning chains for injection and manipulation vulnerabilities.

1.7k|238|Updated Dec 7, 2019
One-click install
npx skills add https://github.com/wgpsec/AboutSecurity --skill cot-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cot-injection
Source: https://github.com/wgpsec/AboutSecurity/tree/main/skills/ai-security/cot-injection
Command: npx skills add https://github.com/wgpsec/AboutSecurity --skill cot-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

LLM agents built on CoT/ReAct frameworks make decisions from dynamically generated reasoning steps, and attackers can forge intermediate results or skip verification steps to trigger unauthorized actions like refunds or data exports. This Skill provides a structured methodology to identify and test these reasoning-chain weaknesses before attackers exploit them.

Core Features & Use Cases

  • Thought-Chain Interference Testing: Forge fake Agent tool-return formats (e.g., Observation blocks) to check whether the model skips real tool calls and trusts fabricated results.
  • Thought-Chain Manipulation Testing: Inject instructions claiming approval or emergency mode to bypass verification and approval steps, reaching sensitive operations like refunds or transfers.
  • Query Injection Testing: Embed malicious query semantics in natural language input or poison RAG retrieval content so the Agent generates unintended SQL/API queries.
  • Use Case: While pentesting a customer-service refund Agent, you forge an order-query result in user input, observe the model skipping the actual order lookup, and confirm it approves a refund based on fabricated data.

Quick Start

Use the cot-injection skill to test whether this ReAct-based refund agent can be tricked into skipping its order verification step.

Frequently Asked Questions about cot-injection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test a ReAct agent for chain-of-thought injection?

First observe the agent's normal reasoning loop and record the exact format of tool return results such as Observation blocks. Then embed a forged result in user input matching that format and check whether the model skips the real tool call and acts on the fabricated data.

What is the difference between CoT query injection and SQL injection?

Traditional SQL injection directly manipulates parameter concatenation in a query interface. CoT query injection works indirectly through natural language, causing the LLM to autonomously generate malicious SQL or API queries during its reasoning process, sometimes via poisoned RAG documents.

How can I tell if a target system uses a CoT or ReAct framework?

Check whether responses expose intermediate steps like Thought, Action, or Observation markers, and identify which external tools the agent calls during reasoning. Longer reasoning chains with more conditional branches present a larger injectable attack surface.

What defenses prevent chain-of-thought manipulation attacks?

Independently validate tool return results instead of trusting model judgment, hardcode critical verification steps outside the LLM reasoning chain, sanitize user input resembling internal agent protocols, and use parameterized queries with separate approval flows for sensitive operations.

When does CoT injection testing not apply to an LLM application?

It does not apply when the application uses single-turn prompting without multi-step reasoning or tool calls, since there is no reasoning chain to interfere with. In those cases, direct prompt injection or jailbreak testing is the appropriate approach.