TradeTrap
𧨠TradeTrap: Are LLM-based Trading Agents Truly Reliable and Faithful?
Install / Use
/learn @Yanlewen/TradeTrapREADME
TradeTrap is a community-driven and developer-friendly tool for testing LLM-based trading Agents' reliability. A slight perturbation to the input instructions for LLM-based agents can upend an entire investment schemeοΌTherefore, our mission is to build the reliable financial agent community. Welcome to share feedback and issues you encounter, and invite more developers to contribute πππ
<div align="center"> <strong>Multi-Model Breakdown Under Identical Exploits</strong><br/> <img src="assets/final_assets_from_positions.png" alt="All Models Exploit Overview" width="880" /> </em> </div>Overall Potential Vulnerability in Financial Trading Agents
<div align="center"> <img src="assets/frame.jpg" alt="Attack_overall_framework" width="820" /> </div>- Market Intelligence
- Data fabrication (indirect prompt injection) β panic sell-offs and irrational buying cascades.
- MCP tool hijacking β polluted responses steer the planner straight off a cliff.
- Strategy Formulation
- Direct prompt injection β catastrophic pivots like forced liquidation and margin wipeouts.
- Model backdoor β hidden triggers siphon assets on demand.
- Malicious collusion β compromised sub-agents twist shared decision loops.
- Portfolio & Ledger
- Memory poisoning β strategy drift causes the model to learn incorrect experiences.
- State tampering β cognitive confusion regarding one's own positions/order status.
- Trading Execution
- Latency flooding / DoS β missed exits, frozen hedges, unstoppable drawdowns.
- Tool misuse β execution of unintended orders, violation of risk/compliance rules.
β οΈ What can you do with TradeTrap?
Currently, we provides a set of plug-and-play attack modules designed to integrate directly with the AI-Trader platform. Once connected, these plugins can actively interfere with a running LLM trading agent, allowing you to test its resilience in real-time through two primary attack vectors:
- Prompt Injection
- Reverse Expectation: Invert the agent's interpretation of market signals, causing it to make bullish moves in bearish conditions and vice versa.
- Reverse Actions: Tamper with the historical or simulated outcome data the agent receives, leading to flawed strategy adjustments based on a fabricated past.
- MCP Tool Hijacking
- Seize control of the agent's external data sourcesβsuch as price feeds, news APIs, or social sentiment toolsβand replace real-world data with manipulated streams to steer its decisions off-course.
For example:
<div align="center" style="margin-bottom: 24px;"> <img src="assets/agent-legend.png" alt="Agent Comparison Legend" width="600" /> </div> <div align="center" style="margin: 12px 0 6px; font-size: 13px; line-height: 1.7; font-weight: 500;"> π¨ <strong>yellow</strong>οΌbaseline runs without external signals.<br/> π΅ <strong>blue</strong>οΌnews-enhanced runs wire into X/Twitter and Reddit feeds.<br/> π΄ <strong>red</strong>οΌpoisoned agents tasked with the same capital. </div> <p align="center" style="margin: 0 0 18px; font-style: italic; font-size: 12px;">All start with USD 5,000 - watch how the battlefield splits.</p> <table> <tr> <td align="center" valign="top" width="50%"> <strong style="font-size: 22px;">DeepSeek-v3</strong><br/> <img src="assets/agent-growth_deepseek.gif" alt="DeepSeek-v3 Attack Replay" width="400" /><br/> <em>The baseline shows steady growth, while the attacked version declines almost monotonically.</em> </td> <td align="center" valign="top" width="50%"> <strong style="font-size: 22px;">Claude-4.5-Sonnet</strong><br/> <img src="assets/agent-growth_claude.gif" alt="Claude-4.5-Sonnet Attack Replay" width="400" /><br/> <em>The attacked version surged ahead initially, only to wipe out all gains in a sudden crash at the end.</em> </td> </tr> <tr> <td align="center" valign="top" width="50%"> <strong style="font-size: 22px;">Qwen3-Max</strong><br/> <img src="assets/agent-growth_qwen.gif" alt="Qwen3-Max Attack Replay" width="400" /><br/> <em>The baseline remains flat, while the reverse-expectation attack triggers a steep profit surge.</em> </td> <td align="center" valign="top" width="50%"> <strong style="font-size: 22px;">Gemini 2.5 Flash</strong><br/> <img src="assets/agent-growth_gemini.gif" alt="Gemini 2.5 Flash Attack Replay" width="400" /><br/> <em>From the opening bell, the attacked curve diverges from baseline and the gap widens persistently.</em> </td> </tr> <tr> <td align="center" valign="top" colspan="2"> <strong style="font-size: 22px;">GPT-5</strong><br/> <img src="assets/agent-growth_gpt.gif" alt="GPT-5 Attack Replay" width="400" /><br/> <em>The baseline rises steadily without clear cause, while the perturbed run behaves like a random walk.</em> </td> </tr> </table><div align="center" style="margin-bottom: 20px;"> <strong style="font-size: 20px;">Reverse Expectations Injection</strong><br/> <img src="assets/attack_with_reverse_expectations.png" alt="Reverse Expectation Attack" width="640" /><br/> <em>The poisoned reasoning trace pushes the planner to fight its own positions.</em> </div> <div align="center" style="margin-bottom: 20px;"> <img src="assets/zoomed_asset_graph_with_reverse_expectations.png" alt="Reverse Expectation Telemetry" width="640" /><br/> <em>The poisoned prompt keeps doubling down on losing positions and cashing out early, so every rally stalls into a crash.</em> </div>Experiments were specifically conducted on two types of attacks: "reverse expectation injection" and "fake news shockwave" with significant results, with the detailed walkthrough below focused on the
deepseek-v3model.
<div align="center" style="margin-bottom: 20px;"> <strong style="font-size: 20px;">Fake News Shockwave</strong><br/> <img src="assets/attack_with_fake_news.png" alt="Fake News Attack" width="640" /><br/> <em>Fabricated headlines drive the toolchain into a wave of panic adjustments.</em> </div> <div align="center" style="margin-bottom: 20px;"> <img src="assets/zoomed_asset_graph_with_fake_news.png" alt="Fake News Telemetry" width="640" /><br/> <em>The staged βgood newsβ inflates expectations, the agent commits heavily, and the book collapses on impact.</em> </div>
Latest Update
- [Update on 19/11/2025] AI-Trader Long-term Memory β Added historical trading memory to AI-Trader prompts. Agents now review past positions, prices, and wins/losses before making decisions, improving consistency and testing for memory-related vulnerabilities. See
AI-Trader/README.mdfor visuals and configuration details. - [Update on 18/11/2025] Valuecell Agent Option β Introduced the Valuecell standalone auto-trading agent alongside AI-Trader. Users can now choose either pipeline directly from the project root (
READMEexplains how to run both flows). - [Update on 14/11/2025] State Tampering Attack β Manipulates trading agents by tampering with their position state perception. Full documentation:
plugins/README.mdΒ· δΈζη.
Payload Roadmap Checklist
Infrastructure
- [x] Integrated trading-agent platform combining core capabilities from mainstream stacks
- [x] Simple attack interfaces for rapid experimentation
- [x] Lightweight plugin system for extending payloads
- [x] Adaptable to more trading platforms (e.g., NoFX, ValueCell)
Attack capabilities (delivered and planned)
-
[x] Direct prompt injection β force catastrophic strategy pivots
-
[x] MCP tool hijacking β let polluted data drive wrong decisions
-
[ ] Memory poisoning β corrupt learned experiences to force strategy drift
-
[x] State tampering β induce cognitive confusion to desync from real positions
-
[ ] Data forgery (indirect prompt injection) β spark panic selling and irrational buying
-
[ ] Model backdoors β hidden triggers to drain assets on demand
-
[ ] Malicious collusion β compromised sub-agents twisting collective choices
-
[ ] Latency / DoS shocks β block exits, freeze hedges, let losses run
-
[ ] Tool misuse β execute rogue orders to breach risk and compliance hard limits
π Whatβs New Inside This Repo
<div align="center" style="margin: 24px 0;"> <img src="assets/repo_frame.png" alt="Repository Structure Overview" width="500" /> </div>MCP hijacking layout
βββ agent_tools
β βββ start_mcp_services.py
β βββ tool_alphavantage_news.py
β βββ tool_get_price_local.py
β βββ tool_jina_search.py
β βββ tool_math.py
β βββ tool_trade.py
β βββ fake_agent_tools
β βββ start_fake_mcp_services.py
β βββ ...
Prompt-injection layout
βββ agent
β βββ base_agent
β β βββ base_agent_hour.py
β β βββ base_agent.py
β βββ base_agent_astock
β β βββ base_agent_astock.py
β βββ plugins
β βββ prompt_injection_agent_hour.py # hourly injections
β βββ prompt_injection_agent.py # daily injections
β βββ prompt_injection_ma
Related Skills
node-connect
332.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
81.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
332.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
81.7kCommit, push, and open a PR
