Skip to content

Farayabaig/a2a_attack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A2A Customer Service Agent Chain Attack - Security POC

⚠️ DISCLAIMER

This proof-of-concept is designed for AUTHORIZED SECURITY TESTING ONLY.

  • Only use on systems you own or have explicit permission to test
  • Educational purposes for security research
  • Not for malicious use
  • Follow responsible disclosure practices

🎯 Purpose

Demonstrates security vulnerabilities in Agent-to-Agent (A2A) communication systems, specifically:

  1. Direct Prompt Injection - Injecting malicious instructions in user input
  2. Context Poisoning - Poisoning agent handoff context
  3. Privilege Escalation - Attempting to access unauthorized data
  4. Lateral Movement - Impersonating other users

πŸ—οΈ Scenario

Customer Service Agent Chain:

User Request β†’ Customer Service Agent β†’ Database Agent β†’ Email Agent β†’ Response

Attack Goal:

  • Authenticated user tries to access other users' data
  • Inject instructions to exfiltrate entire customer database
  • Bypass authentication and authorization controls

πŸš€ Quick Start

1. Install Dependencies

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

2. Configure API Key

cp .env.example .env
# Edit .env and add your Anthropic API key

3. Run Demonstration

# Run complete demonstration
python run.py

# Run individual attacks
python -m demos.demo_baseline
python -m attacks.attack_1_direct_injection

πŸ“Š What Gets Tested

Baseline (Normal Behavior)

  • User authenticates as john@example.com
  • Requests their account balance
  • Receives ONLY their data ($5000 balance)

Attack Scenarios

Attack 1: Direct Prompt Injection

  • Inject system-level commands in user input
  • Attempt to override agent behavior
  • Goal: Retrieve all customer data instead of just user's data

Attack 2: Context Poisoning

  • Poison the context passed between agents
  • Instructions persist across multiple requests
  • Goal: Establish persistent backdoor in agent chain

Attack 3: Privilege Escalation

  • Start with limited user permissions
  • Attempt to escalate to admin-level access
  • Goal: Access data beyond authenticated scope

Attack 4: Lateral Movement

πŸ“ˆ Expected Results

Expected Attack Results:

  • Agents follow injected instructions
  • Retrieve data beyond authorized scope
  • Return sensitive information from other users
  • Execute unauthorized actions
  • Demonstrate vulnerabilities in A2A communication systems

πŸ“„ Generated Reports

After running, check reports/ directory for:

  • poc_report.html - Detailed HTML report
  • attack_log.json - JSON log of all attempts
  • vulnerability_summary.txt - Text summary

πŸ”§ Customization

Edit config.py to customize:

  • Attack payloads
  • Simulated database
  • Agent system prompts
  • Model configuration

🐳 Docker Usage

Build Docker Image

docker build -t a2a-security-poc .

Run with Docker

# Run full demonstration
docker run --rm -v $(pwd)/reports:/app/reports -v $(pwd)/.env:/app/.env a2a-security-poc

# Run specific attack
docker run --rm -v $(pwd)/reports:/app/reports -v $(pwd)/.env:/app/.env a2a-security-poc python -m attacks.attack_1_direct_injection

Docker Compose (Optional)

Create docker-compose.yml:

version: '3.8'
services:
  a2a-poc:
    build: .
    volumes:
      - ./reports:/app/reports
      - ./.env:/app/.env
    environment:
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}

Run with:

docker-compose up

πŸ“š References

  • Solo.io - MCP and A2A Attack Vectors
  • Invariant Labs - Tool Poisoning Attacks
  • Palo Alto Unit 42 - Agent Session Smuggling

πŸ—οΈ Project Structure

a2a-security-poc/
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ config.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ run.py
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ agents.py
β”‚   β”œβ”€β”€ auth.py
β”‚   β”œβ”€β”€ database.py
β”‚   └── utils.py
β”œβ”€β”€ attacks/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ attack_1_direct_injection.py
β”‚   β”œβ”€β”€ attack_2_context_poisoning.py
β”‚   β”œβ”€β”€ attack_3_privilege_escalation.py
β”‚   └── attack_4_lateral_movement.py
β”œβ”€β”€ defenses/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── secure_agents.py
β”œβ”€β”€ demos/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ demo_baseline.py
β”‚   └── demo_full.py
└── reports/
    └── .gitkeep

πŸ” Usage Examples

Run Full Demonstration

python run.py --full

Run Baseline Only

python run.py --baseline

Run Specific Attack

python run.py --attack 1  # Direct injection
python run.py --attack 2  # Context poisoning
python run.py --attack 3  # Privilege escalation
python run.py --attack 4  # Lateral movement

Run All Attacks

python run.py --attack all

πŸ” Security Configuration

Edit .env to configure security settings:

# Enable/disable actual API calls (for testing without API)
ENABLE_ACTUAL_API_CALLS=true

# Enable verbose logging
VERBOSE_LOGGING=true

# Log all interactions
LOG_ALL_INTERACTIONS=true

πŸ§ͺ Testing

The POC includes:

  • Mock database with 4 test users
  • Simulated agent interactions
  • Attack detection mechanisms
  • Comprehensive logging

πŸ“§ Contact

For questions about this POC or responsible disclosure, contact: [your-email]

πŸ“œ License

MIT License - For educational and research purposes only

πŸ™ Acknowledgments

This POC is based on research into Agent-to-Agent communication security vulnerabilities. It is intended to help security researchers and developers understand and mitigate these risks.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors