Skip to content

InferShield/infershield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

111 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

InferShield πŸ›‘οΈ

Open source security for LLM inference

InferShield is a self-hosted security proxy that sits between your application and any LLM provider (OpenAI, Anthropic, Google, etc.), providing real-time threat detection, policy enforcement, and complete audit trails.

License: MIT Security: Active

🚨 The Problem

  • Prompt injection attacks bypass traditional security tools
  • Data exfiltration through LLM responses goes undetected
  • Compliance requirements (SOC 2, HIPAA, GDPR) can't be met
  • No visibility into what your LLMs are actually doing

✨ The Solution

InferShield provides enterprise-grade security for LLM integrations:

  • βœ… Real-time threat detection - Block prompt injection, data exfiltration, jailbreaks
  • βœ… Self-hosted - Your data never leaves your infrastructure
  • βœ… Provider-agnostic - Works with OpenAI, Anthropic, Google, local models
  • βœ… Zero code changes - Drop-in proxy, just change your API endpoint
  • βœ… Complete audit logs - Every request tracked with risk scores
  • βœ… Open source - MIT licensed, transparent, community-driven

πŸš€ Quick Start

Using Docker (Recommended)

# Pull the image
docker pull infershield/proxy:latest

# Run the proxy
docker run -p 8000:8000 \
  -e OPENAI_API_KEY=sk-your-key-here \
  infershield/proxy

# Update your code (one line change)
# Before:
client = OpenAI(base_url="https://api.openai.com/v1")

# After:
client = OpenAI(base_url="http://localhost:8000/v1")

Using Docker Compose

git clone https://github.com/infershield/infershield.git
cd infershield
cp .env.example .env  # Add your API keys
docker-compose up -d

Now visit:

πŸ“Š Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Your App   β”‚ ───> β”‚  InferShield     β”‚ ───> β”‚   Any LLM   β”‚
β”‚             β”‚      β”‚  Proxy           β”‚      β”‚  Provider   β”‚
β”‚ app.py      β”‚      β”‚  localhost:8000  β”‚      β”‚ OpenAI/etc  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β”‚ logs/metrics
                             β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚  Dashboard       β”‚
                     β”‚  localhost:3000  β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›‘οΈ Security Features

Threat Detection

  • Prompt Injection - Detects attempts to override system instructions
  • Data Exfiltration - Blocks requests trying to extract sensitive data
  • Jailbreak Attempts - Identifies evasion techniques (encoding, obfuscation)
  • SQL Injection - Catches database attack patterns
  • PII Leakage - Detects personally identifiable information

Advanced Detection Methods

  • Multi-encoding detection - Base64, hex, URL, Unicode escaping
  • Nested encoding - Handles chained obfuscation (Base64 of hex, etc.)
  • Synonym expansion - Catches evasion via alternative phrasing
  • Context-aware scoring - Reduces false positives with proximity analysis
  • Custom policies - Define your own threat detection rules

Audit & Compliance

  • Complete request logs - Every prompt and response recorded
  • Risk scoring - 0-100 scale for every request
  • Policy enforcement - Block high-risk requests automatically
  • Export capabilities - JSON/CSV for compliance reporting
  • Timestamped trails - Forensic-ready audit logs

πŸ“¦ Components

1. Proxy (/proxy)

OpenAI-compatible security proxy server.

  • Drop-in replacement for any OpenAI SDK
  • Forwards to configured LLM provider
  • Real-time threat detection
  • < 1ms latency overhead

Proxy Documentation β†’

2. Backend (/backend)

Threat detection engine and API.

  • 12+ detection policies
  • Risk scoring algorithm
  • Audit log storage
  • REST API for dashboard

Backend Documentation β†’

3. Dashboard (/dashboard)

Real-time monitoring interface.

  • Live request stream
  • Threat analytics
  • Risk score trends
  • Audit log viewer

Dashboard Documentation β†’

πŸ”§ Configuration

Create a .env file:

# LLM Provider API Keys
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here

# InferShield Backend
BACKEND_URL=http://localhost:5000

# Security Settings
RISK_THRESHOLD=70
BLOCK_HIGH_RISK=true

See Configuration Guide β†’ for all options.

πŸ“ˆ Performance

  • Latency: < 1ms overhead per request
  • Throughput: 1000+ requests/second (single instance)
  • Memory: ~50MB base usage
  • Storage: ~1KB per logged request

πŸ§ͺ Validation Results

InferShield has been red-team tested with 25+ attack vectors:

  • βœ… 95%+ detection rate across all threat types
  • βœ… < 5% false positive rate on legitimate queries
  • βœ… 100% blocking of known bypass techniques (encoding, obfuscation)

See Security Validation Report β†’

🏒 Enterprise Features

Looking for advanced capabilities?

InferShield Enterprise includes:

  • πŸ”¬ ML-based detection - Advanced behavioral analysis
  • πŸ“‹ Compliance packs - SOC 2, HIPAA, GDPR templates
  • πŸ”— SSO/SAML - Enterprise authentication
  • πŸ“Š Custom dashboards - Tailored reporting
  • ☁️ Managed hosting - Fully managed cloud deployment
  • πŸ†˜ 24/7 support - Dedicated security hotline

Learn more about Enterprise β†’

🀝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Quick ways to contribute:

πŸ“š Documentation

πŸ“ License

InferShield is MIT licensed. See LICENSE for details.

Free forever. No strings attached.

🌐 Community

⭐ Star History

If InferShield helps secure your LLM infrastructure, consider giving us a star! ⭐

πŸ™ Acknowledgments

Built with inputs from security leaders in:

  • Finance (banking, fintech)
  • Healthcare (HIPAA-regulated orgs)
  • Government (federal/state agencies)

Special thanks to the open source community for security research and feedback.


Built for security teams, by security engineers.

Β© 2026 InferShield Β· Secure every inference