# Universal Poison Armor 🛡️ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Python: 3.9+](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/) [![Model Context Protocol](https://img.shields.io/badge/MCP-Protocol-purple.svg)](https://modelcontextprotocol.io/) [![FastMCP](https://img.shields.io/badge/FastMCP-Enabled-green.svg)](https://github.com/jlowin/fastmcp) [![Universal-Poison-Armor MCP server](https://glama.ai/mcp/servers/mzaid007/Universal-Poison-Armor/badges/score.svg)](https://glama.ai/mcp/servers/mzaid007/Universal-Poison-Armor) [![LobeHub MCP](https://lobehub.com/badge/mcp/mzaid007-universal-poison-armor)](https://lobehub.com/mcp/mzaid007-universal-poison-armor) [![Listed on mcpservers.org](https://mcpservers.org/badge.svg)](https://mcpservers.org/servers/mzaid007/universal-poison-armor) [![Security: AI Poison Defense](https://img.shields.io/badge/Security-AI%20Poison%20Defense-red.svg)](#) [![Universal-Poison-Armor MCP server](https://glama.ai/mcp/servers/mzaid007/Universal-Poison-Armor/badges/card.svg)](https://glama.ai/mcp/servers/mzaid007/Universal-Poison-Armor) **Universal Poison Armor** is an open-source, production-grade security framework and **Model Context Protocol (MCP)** server for AI agents, LLM pipelines, and RAG systems. It provides multi-layer protection against indirect prompt injection, zero-width Unicode steganography, adversarial suffixes (GCG attacks), tracking pixels / Markdown XSS, semantic dataset poisoning, and Consensus Poisoning / Sybil attacks. Combines standard, native agentic behavioral directives (`SKILL.md`) with a high-performance local FastMCP server. --- ## 📖 Table of Contents - [🚨 What is AI Poisoning?](#-what-is-ai-poisoning) - [🛡️ Multi-Layer Defense Architecture](#️-multi-layer-defense-architecture) - [1. Tracking Pixel & Markdown XSS Neutralization](#1-tracking-pixel--markdown-xss-neutralization) - [2. Deterministic Normalization & Heuristic Redaction](#2-deterministic-normalization--heuristic-redaction) - [3. Shannon Entropy & Adversarial Suffix Detection (GCG)](#3-shannon-entropy--adversarial-suffix-detection-gcg) - [4. Unsupervised Semantic Anomaly Detection](#4-unsupervised-semantic-anomaly-detection) - [5. Consensus Poisoning & Sybil Attack Defense](#5-consensus-poisoning--sybil-attack-defense) - [6. Persistent Security Audit Logging](#6-persistent-security-audit-logging) - [📂 Project Structure](#-project-structure) - [⚡ Quickstart & Installation](#-quickstart--installation) - [🤖 Native Agent & Skill Installation](#-native-agent--skill-installation) - [Glama (1-Click Install & Cloud Chat)](#glama-1-click-install--cloud-chat) - [LobeChat / LobeHub (1-Click Install & Verification)](#lobechat--lobehub-1-click-install--verification) - [Docker Container](#docker-container) - [Claude Code (Native Skill)](#claude-code-native-skill) - [Google Antigravity](#google-antigravity) - [Claude Desktop](#claude-desktop) - [Cursor IDE / Windsurf](#cursor-ide--windsurf) - [Cloud Deployment (Glama, Hugging Face, CreateOS, GCP, AWS)](#-universal-deployment-architecture) - [🛠️ Exposed MCP Primitives (Tools, Resources, Prompts)](#️-exposed-mcp-primitives-tools-resources-prompts) - [`sanitize_document`](#sanitize_document) - [`scan_dataset_for_anomalies`](#scan_dataset_for_anomalies) - [`verify_article_consensus`](#verify_article_consensus) - [`sanitize_model_output`](#sanitize_model_output) - [MCP Resources](#mcp-resources) - [MCP Prompts](#mcp-prompts) - [⚙️ Configuration & Environment Variables](#️-configuration--environment-variables) - [🔍 Dry-Run / Audit-Only Mode](#-dry-run--audit-only-mode) - [📊 Public Attack Benchmark Suite & Performance Validation](#-public-attack-benchmark-suite--performance-validation) - [⚠️ Adversarial Robustness & Known Failure Modes](#️-adversarial-robustness--known-failure-modes) - [🚀 Reverse Proxy Concurrent Load Benchmark](#-reverse-proxy-concurrent-load-benchmark) - [📝 Security Audit Logs (`security_audit.json`)](#-security-audit-logs-security_auditjson) - [🐍 Python API, Middleware & Reverse Proxy Usage](#-python-api-middleware--reverse-proxy-usage) - [1. Direct Python Engine](#1-direct-python-engine) - [2. Client-Side Interceptor SDK Middleware](#2-client-side-interceptor-sdk-middleware) - [3. Transparent HTTP & SSE Reverse Proxy Gateway](#3-transparent-http--sse-reverse-proxy-gateway) - [4. Ecosystem & Framework Plugins (LangChain, LlamaIndex, CrewAI)](#4-ecosystem--framework-plugins-langchain-llamaindex-crewai) - [5. Automated Local ONNX Model Downloader](#5-automated-local-onnx-model-downloader) - [🛡️ Addressing Architectural Limitations & Defense-in-Depth](#️-addressing-architectural-limitations--defense-in-depth) - [🔒 Security & Privacy Guarantees](#-security--privacy-guarantees) - [📄 License](#-license) --- ## 🚨 What is AI Poisoning? As autonomous AI agents, coding assistants, and Retrieval-Augmented Generation (RAG) pipelines ingest external data from repositories, web search results, PDFs, and databases, they are vulnerable to **Adversarial Context & Data Poisoning Attacks**: ``` +-------------------------------------------------------------------------------+ | AI Context Poisoning Vectors | +-------------------------------------------------------------------------------+ | 1. Indirect Prompt Injection | Attacker hides instructions inside data to | | | hijack the agent's system prompt & tools. | | 2. Zero-Width Steganography | Invisible Unicode tokens (ZWSP, tags) bypass| | | human review but trigger LLM token actions. | | 3. Adversarial Suffixes (GCG) | High-entropy mathematical token gibberish | | | designed to force model safety bypasses. | | 4. Tracking Pixel Exfiltration | Markdown images/iframes leak IP addresses. | | 5. Semantic RAG Poisoning | Adversary seeds knowledge bases with trojan | | | clusters that alter model reasoning. | | 6. Consensus & Sybil Attacks | Bot networks flood search results with near-| | | identical claims to trick AI into consensus.| +-------------------------------------------------------------------------------+ ``` **Universal Poison Armor** neutralizes these threats *before* untrusted content reaches the LLM context window. --- ## 🛡️ Multi-Layer Defense Architecture ``` +---------------------------------------------------------------------------+ | Incoming Untrusted Context | | (Files, Web Pages, Datasets, RAG Context Chunks) | +---------------------------------------------------------------------------+ | v +---------------------------------------------------------------------------+ | LAYER 1: Tracking Pixel & Markdown XSS Stripping | | • Strips ![alt](url) Markdown images, , and