llm-trading-agent-security

Implements security controls for autonomous trading agents that sign and send blockchain transactions.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill llm-trading-agent-security-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: llm-trading-agent-security
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/llm-trading-agent-security
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill llm-trading-agent-security-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Autonomous trading agents with wallet or transaction authority face a harsher threat model than typical LLM apps: a prompt injection or bad tool path can directly cause asset loss. This Skill provides layered defensive patterns to prevent that. ## Core Features & Use Cases - Prompt Injection Defense: Sanitize on-chain data, token names, and social feeds before they enter an execution-capable LLM context. - Spend Limits & Circuit Breakers: Enforce hard per-transaction and daily USD caps, plus halt trading on consecutive losses or hourly drawdown thresholds. - Pre-Send Simulation & MEV Protection: Simulate transactions with eth_call, require min_amount_out, and route through private RPCs like Flashbots with slippage and deadline controls. - Use Case: When building an AI agent that executes swaps on-chain, apply these patterns so a malicious token description cannot trick the model into transferring funds to an attacker's address. ## Quick Start Ask the AI to audit your trading agent's execution code using the llm-trading-agent-security checklist and add spend limits, simulation, and circuit breakers.

Frequently Asked Questions about llm-trading-agent-security

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

FAQPage Schema
How do I secure an LLM trading agent against prompt injection?▼

Sanitize all external data such as token names, pair labels, and social feeds with regex-based injection pattern detection before injecting it into an execution-capable prompt. Treat any instruction-like content in on-chain data as a potential financial attack and reject it.

How to enforce spend limits on an autonomous trading bot?▼

Implement a SpendLimitGuard that checks each transaction against a maximum single-transaction USD cap and a rolling 24-hour daily limit, raising an error when exceeded. Enforce these limits independently from model output so the LLM cannot override them.

Why simulate transactions before sending on-chain?▼

Simulation via eth_call reveals the actual output of a transaction before it is broadcast, letting you compare it against a mandatory min_amount_out. If the simulated result falls below the expected minimum, the transaction is aborted to prevent slippage losses.

Can a trading agent use my main wallet private key?▼

No. Use a dedicated hot wallet holding only the funds required for the session, loaded from an environment variable or secret manager. Never point the agent at a primary treasury wallet or hardcode keys in code or logs.

What is a circuit breaker in algorithmic trading agents?▼

A circuit breaker halts the agent when risk thresholds are breached, such as three consecutive losses or an hourly drawdown beyond five percent of portfolio value. It also halts on invalid state like a non-positive hour-start value to prevent undefined behavior.

How do I protect swaps from MEV and sandwich attacks?▼

Route transactions through a private RPC endpoint such as Flashbots instead of the public mempool, and set per-strategy slippage tolerances in basis points plus short transaction deadlines. This reduces exposure to front-running and stale execution.