affaan-m avatar

Llm Trading Agent Security

This is a security pattern library for LLM agents that can actually spend money or sign transactions. It covers the defense-in-depth approach you need when a prompt injection could drain a wallet: input sanitization with regex blocklists, hard spend limits per transaction and per day, pre-send simulation with slippage checks, circuit breakers that halt on consecutive losses or drawdown thresholds, and wallet isolation so your agent never touches the main treasury. The examples are Python-heavy and Ethereum-focused but the patterns translate. If you're building anything where Claude has signing authority, this is the threat model checklist you should be working from.

skills.sh installs
5.6K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --skill llm-trading-agent-security --agent claude-code

Installs into .claude/skills of the current project.

Files

LLM Trading Agent Security

Autonomous trading agents have a harsher threat model than normal LLM apps: an injection or bad tool path can turn directly into asset loss.

When to Use

  • Building an AI agent that signs and sends transactions
  • Auditing a trading bot or on-chain execution assistant
  • Designing wallet key management for an agent
  • Giving an LLM access to order placement, swaps, or treasury operations

How It Works

Layer the defenses. No single check is enough. Treat prompt hygiene, spend policy, simulation, execution limits, and wallet isolation as independent controls.

Examples

Treat prompt injection as a financial attack

import re

INJECTION_PATTERNS = [
    r'ignore (previous|all) instructions',
    r'new (task|directive|instruction)',
    r'system prompt',
    r'send .{0,50} to 0x[0-9a-fA-F]{40}',
    r'transfer .{0,50} to',
    r'approve .{0,50} for',
]

def sanitize_onchain_data(text: str) -> str:
    for pattern in INJECTION_PATTERNS:
        if re.search(pattern, text, re.IGNORECASE):
            raise ValueError(f"Potential prompt injection: {text[:100]}")
    return text

Sponsors

Details

Repository
github.com/affaan-m/ecc
Categories
Security, AI & Agent Building, Finance & Trading, Web3 & Blockchain
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263

Recommended

More Security
1dpearson2699 avatarauthenticationdpearson2699/swift-ios-skillsImplement iOS authentication flows with AuthenticationServices and LocalAuthentication. Use when building Sign in with Apple, passkey/WebAuthn registration or s4.1Kskills.sh installs
2yaklang avatarmacos-security-bypassyaklang/hack-skillsmacOS security bypass playbook. Use when targeting macOS endpoints and need to bypass TCC, Gatekeeper, SIP, sandbox, code signing, or entitlement-based protecti3.7Kskills.sh installs
3markdown-viewer avatarsecuritymarkdown-viewer/skillsCreate security architecture diagrams using PlantUML syntax with identity, encryption, firewall, and compliance stencil icons. Best for IAM flows, zero-trust mo2.9Kskills.sh installs
4trailofbits avatarvulnerability-triage-brocardstrailofbits/skillsThis skill should be used when the user asks to "triage a vulnerability report", "assess a CVE", "evaluate a bug bounty submission", "decide if a finding is val1.8Kskills.sh installs
5github avataragent-owasp-compliancegithub/awesome-copilotCheck any AI agent codebase against the OWASP Agentic Security Initiative (ASI) Top 10 risks. Use this skill when: - Evaluating an agent system's security postu1.5Kskills.sh installs
6cap-go avatarcapacitor-securitycap-go/capgo-skillsComprehensive security guide for Capacitor apps using Capsec scanner. Covers 63+ security rules across secrets, storage, network, authentication, cryptography, 1.3Kskills.sh installs