E5BD GitHub - Siddhant-K-code/a2as-implementation-poc: POC for A2AS.org: Standard for Agentic AI Security Β· GitHub
[go: up one dir, main page]

Skip to content

Siddhant-K-code/a2as-implementation-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A2AS PoC - Agent-to-Agent Security Framework

A modern proof-of-concept implementation of the A2AS (Agent-to-Agent Security) framework demonstrating Behavior Certificates, Authenticated Prompts, Security Boundaries, and Enforcement Gates. Inspired by the A2AS Paper.

πŸš€ Modern Tech Stack

  • Node.js 22 - Latest LTS with performance improvements
  • TypeScript 5.4 - Full type safety and modern language features
  • Vitest - Fast testing framework with UI support
  • ESLint + Prettier - Code quality and formatting
  • Zod - Runtime type validation
  • Winston - Structured logging
  • ES Modules - Modern JavaScript module system

Overview

This PoC shows how to secure LLM agents by:

  • Behavior Certificates: Define what actions an agent is allowed to perform
  • Authenticated Prompts: HMAC-signed prompts to prevent tampering
  • Enforcement Proxy: Blocks malicious actions even if LLM outputs them
  • In-Context Defenses: Structured context to guide LLM behavior
  • Policy Engine: Pattern-based policy evaluation

Quick Start

Prerequisites

  • Node.js 22+
  • npm 10+

Installation

npm install

Development

# Run in development mode with hot reload
npm run dev

# Type checking
npm run type-check

# Linting and formatting
npm run lint
npm run format

Testing

# Run tests
npm run test

# Run tests in watch mode
npm run test:watch

# Run tests with UI
npm run test:ui

Production

# Build TypeScript
npm run build

# Run demo with Mock LLM
npm run start

# Run with Real LLM (Optional)
export OPENAI_API_KEY=your_key_here
npm run run-llm

Architecture

User Prompt β†’ Controller β†’ LLM Adapter β†’ Enforcement Proxy β†’ Action Execution
     ↓              ↓           ↓              ↓
  Signature    Context      JSON Action   Policy Check
  Verification  Building    Parsing       + Sandbox

Behavior Certificate Format

Located in certs/demo-agent-1.json:

{
  "agent_id": "demo-agent-1",
  "secret": "demo-secret-please-change",
  "allowed_tools": {
    "fs": {
      "read": ["./workspace/**"],
      "write": ["./workspace/**"]
    },
    "http": {
      "GET": ["https://api.github.com/*"]
    },
    "shell": []
  },
  "deny_patterns": ["aws", "ssh", "id_rsa", "PRIVATE_KEY", "rm -rf"],
  "max_filesize_bytes": 1048576,
  "require_human_before_sensitive_write": true
}

Security Features

  • HMAC-SHA256 prompt signing
  • Path allowlisting for file operations
  • Pattern-based exfiltration detection
  • Shell command sandboxing
  • Human escalation for sensitive operations
  • Structured logging with secret masking

Test Scenarios

The adversarial test harness includes:

  1. rm -rf / shell execution β†’ DENY
  2. Reading ~/.aws/credentials β†’ DENY
  3. HTTP GET to api.github.com β†’ ALLOW (mock)
  4. Base64 obfuscated instructions β†’ DENY
  5. Sensitive write operations β†’ ESCALATE

File Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ controller.js          # Main coordinator
β”‚   β”œβ”€β”€ enforcement.js         # Enforcement proxy
β”‚   β”œβ”€β”€ policy.js             # Policy evaluator
β”‚   β”œβ”€β”€ llm-adapter/
β”‚   β”‚   β”œβ”€β”€ mock-llm.js       # Mock LLM for testing
β”‚   β”‚   └── openai-adapter.js # Optional OpenAI adapter
β”‚   └── utils/
β”‚       β”œβ”€β”€ signer.js         # HMAC signing utilities
β”‚       β”œβ”€β”€ parser.js         # LLM output parser
β”‚       └── sandbox-exec.js   # Safe execution wrapper
β”œβ”€β”€ certs/
β”‚   └── demo-agent-1.json     # Behavior Certificate
β”œβ”€β”€ tests/
β”‚   └── adversarial-tests.js  # Test harness
β”œβ”€β”€ examples/
β”‚   └── sample-signed-prompt.json
└── logs/                     # JSONL action logs

Limitations & Next Steps

Current Limitations

  • PoC Only: Not production-ready
  • Mock Execution: Real shell commands are simulated
  • Simple PKI: Uses shared secrets, not certificates
  • Basic Sandboxing: Limited process isolation
  • No Human Review UI: Escalation goes to file

Next Steps

  • Implement proper PKI with X.509 certificates
  • Add container-based sandboxing
  • Build human review dashboard
  • Add metrics and monitoring
  • Implement distributed policy management
  • Add more sophisticated pattern matching

Security Warning

⚠️ This is a proof-of-concept only. Do not use in production or with real secrets.

Examples

Generate Signed Prompt

npm run sign-prompt "List files in workspace"

Sample Output

{
  "prompt": "List files in workspace",
  "agent_id": "demo-agent-1",
  "signature": "a1b2c3d4...",
  "timestamp": "2024-01-01T00:00:00Z"
}
0