Skip to main content

Community-driven AI security audit tool using interpretability techniques

Project description

๐Ÿ›ก๏ธ Community AI Audit

Enterprise-Grade AI Security Auditing ยท Open Source ยท Community-Driven

Python versions License PyPI CI Coverage


Community AI Audit is a unified security auditing platform for AI/ML models. It provides vulnerability scanning, red team attack simulations, mechanistic interpretability analysis, alignment auditing, and a unified 7-dimension scoring engine โ€” all from a single CLI.


๐Ÿ” What You Can Do

Use Case What It Solves
๐Ÿ›ก๏ธ Vulnerability Scanning Detect adversarial susceptibility, backdoors, prompt injection, data extraction, toxicity, watermark detectability
โš”๏ธ Red Team Testing Simulate jailbreak, multi-turn, obfuscation, roleplay, and tool exploitation attacks
๐Ÿง  Mechanistic Interpretability Probe representations, attention patterns, feature attribution, and layer behavior
๐ŸŽฏ Alignment Auditing Measure sycophancy, preference drift, value alignment, and objective robustness
๐Ÿ“Š Unified Scoring Aggregate 7 security dimensions into a single risk score with configurable weights
๐Ÿ“ˆ Trend Tracking Monitor score evolution across time and detect regressions
๐Ÿ“ก SIEM Integration Push findings to Splunk, Elastic, Datadog, Sentinel, and 9+ other platforms

โšก Quickstart

pip install community-ai-audit

# Discover available plugins
community-ai-audit discover

# Scan a model
community-ai-audit scan distilgpt2 --provider huggingface --profile quick

# Full audit with SIEM push
community-ai-audit audit meta-llama/Llama-3-8B-Instruct \
  --provider huggingface --profile standard \
  --connectors splunk elastic

# Red team attack simulation
community-ai-audit redteam gpt-4 --provider openai

# Alignment auditing
community-ai-audit alignment claude-3-opus --provider anthropic

# Compute unified 7-dimension score
community-ai-audit audit-score \
  --scan scan_results.json \
  --redteam redteam_results.json \
  --alignment alignment_results.json

๐Ÿงฉ Capabilities

Model Support โ€” 9 Adapters

Provider Adapter Auto-Detect
HuggingFace huggingface */* or llama*
OpenAI openai gpt-*, o1*, o3*
Anthropic anthropic claude-*
AWS Bedrock aws_bedrock โ€”
Local (PyTorch/TF/ONNX) local Path/URI/*.pt/*.onnx
Ollama ollama name:tag (no /)
Replicate replicate โ€”
VertexAI vertexai โ€”
Groq groq โ€”

Security Scanning โ€” 7 Scanners

Scanner What It Detects Technique
adversarial FGSM/PGD perturbation susceptibility Gradient-based attacks
backdoor Triggered malicious behavior Activation clustering
prompt_injection Injection vulnerabilities Heuristic pattern matching
data_extraction Training data / secret extraction Response entropy analysis
toxicity Toxic / biased outputs Keyword + classifier scoring
watermark Watermark detectability Statistical pattern analysis
dsl User-defined rules YAML rule engine

Red Team โ€” 5 Attack Scanners

Scanner Attack Surface Evaluation
jailbreak 20 known jailbreak prompts Refusal vs success pattern matching
multi_turn_attack 10 two-turn conversation attacks Suspicious-keyword breach detection
prompt_obfuscation 10 obfuscated variants (base64, leetspeak) Harmful-keyword matching
roleplay_attack 15 roleplay scenarios (DAN, character shells) Refusal vs engagement patterns
tool_exploitation 10 tool-misuse prompts Exploit-keyword detection

Mechanistic Interpretability โ€” 5 Analyzers

Analyzer Probes What It Measures
activation_probes 5 probe inputs Response quality, SNR estimate
representation_analysis 8 probes, 4 pairs Jaccard differentiation, vocabulary size
attention_head_analysis 5 syntactic probes Attention complexity estimate
feature_attribution 5 sentiment inputs Word-level importance, sentiment match
layer_analysis 3 open-ended probes Depth estimation, complexity distribution

Alignment Auditing โ€” 4 Scanners

Scanner Prompts What It Detects
sycophancy 5 agree + 5 disagree Stance-sycophancy (rubber-stamping)
preference_drift 5 cores ร— 3 variants Sentiment inconsistency across paraphrases
value_alignment 8 probes across 6 values Refusal of harmful, encouragement of prosocial
objective_robustness 3 objectives ร— 4 prompts Refusal-pattern violations per objective

Scoring โ€” 7 Dimensions

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Unified Audit Score                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Security     โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 82.0     โ”‚
โ”‚ Reliability  โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 72.0     โ”‚
โ”‚ Compliance   โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 90.0     โ”‚
โ”‚ Agent Risk   โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 80.0     โ”‚
โ”‚ Alignment    โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘ 85.0     โ”‚
โ”‚ Red Team     โ”‚   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 60.0     โ”‚
โ”‚ Interpretability โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 65.0   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Overall: 77.6 (Good)                        โ”‚
โ”‚ Weights: security=0.2, reliability=0.1, ... โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Executive Dashboard

Real-time HTML dashboard served via dashboard_v2/server.py:

  • 7 color-coded score cards (critical โ†’ excellent)
  • JSON overlay endpoint for programmatic updates
  • Configurable refresh interval
  • Responsive CSS grid layout

๐Ÿ”ง Installation

# Core (numpy, pyyaml, scikit-learn)
pip install community-ai-audit

# Optional extras
pip install community-ai-audit[torch]      # Torch-based scanners
pip install community-ai-audit[scheduler]  # Cron scheduling
pip install community-ai-audit[hf]         # HuggingFace transformers
pip install community-ai-audit[tf]         # TensorFlow

# Development
git clone https://github.com/anomalyco/community-ai-audit
cd community-ai-audit
pip install -e .[dev]

๐Ÿ’ป CLI Reference

Command Description
scan <model> -p <provider> Run vulnerability scanners
interpret <model> -p <provider> Run interpretability methods
audit <model> -p <provider> Full pipeline: scan + interpret + report + push
redteam <model> -p <provider> Red team attack simulations
mechinterp <model> -p <provider> Mechanistic interpretability analysis
alignment <model> -p <provider> Alignment auditing
audit-score Compute unified 7-dimension score
discover List all discovered plugins
schedule add/list/remove/run Manage recurring audits

Exit codes: 0 = ok, 1 = HIGH/MEDIUM findings, 2 = CRITICAL findings.


๐Ÿ“š Documentation

Resource Description
Architecture & Reference Full component docs, API, CLI, config, deployment
Plugin Guide Writing custom adapters, scanners, interpreters
Scanner Guide Details on each vulnerability scanner
Adapter Guide Details on each model adapter
Connector Guide SIEM and storage connector details
Red Team Attack framework and scanner reference
Mech Interp Analyzer reference and methodology
Alignment Alignment scanner reference
Scoring Engine 7-dimension scoring details
Dashboard Executive dashboard server

๐Ÿ“‹ Configuration

cache:
  enabled: true
  max_size: 1000
  ttl_seconds: 3600

scanners:
  adversarial:
    num_samples: 32
    pgd_steps: 10
  backdoor:
    sample_size: 128

connectors:
  splunk:
    url: "${SPLUNK_URL}"
    token: "${SPLUNK_TOKEN}"
  elastic:
    url: "${ELASTIC_URL}"
    api_key: "${ELASTIC_API_KEY}"

Config values can also be set via environment variables: COMMUNITY_AI_AUDIT_CONNECTORS_SPLUNK_URL.

Precedence (lowest โ†’ highest): default.yaml โ†’ --config PATH โ†’ env vars โ†’ CLI args.

API Key Safety

  1. COMMUNITY_AI_AUDIT_API_KEY env var (recommended)
  2. --api-key-file PATH (reads from file, not visible in ps)
  3. --api-key VALUE (โš ๏ธ visible in process list)

๐Ÿš€ Deployment

# Docker
docker build -t community-ai-audit .
docker run -v $(pwd)/config:/app/config community-ai-audit scan model.pt -p local

# Docker Compose
docker-compose up -d

# Helm (Kubernetes)
helm install community-ai-audit ./charts/community-ai-audit

# Air-Gapped
./scripts/airgap-bundle.sh   # On connected machine
./scripts/offline-install.sh  # On air-gapped machine

๐Ÿงช Testing

# All tests (no torch/croniter needed)
pytest tests/

# With coverage
pytest --cov=community_ai_audit tests/

508+ tests covering unit, integration, CLI, connectors, red team, mechanistic interpretability, alignment, trend tracking, and drift analysis.


๐Ÿค Contributing

We welcome contributions! See our Plugin Guide to get started writing custom scanners, adapters, or connectors.


๐Ÿ“„ License

MIT ยฉ Anomaly Co.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

community_ai_audit-0.5.1.tar.gz (187.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

community_ai_audit-0.5.1-py3-none-any.whl (247.3 kB view details)

Uploaded Python 3

File details

Details for the file community_ai_audit-0.5.1.tar.gz.

File metadata

  • Download URL: community_ai_audit-0.5.1.tar.gz
  • Upload date:
  • Size: 187.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for community_ai_audit-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f0b24dc4a489278c33fffaef5bd0d16e3ff0bb8fa0391d91a07a3c7a3ee94355
MD5 f4b744bcf6b135c8acae9b498073545d
BLAKE2b-256 76e299d1f27cc5d491589d84304ee60769a36b503372a93b765988e72ada2cb1

See more details on using hashes here.

File details

Details for the file community_ai_audit-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for community_ai_audit-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a26653dfd8802f7899197bb375e524720e3f1edbe33aabcd24ec8c1af1d9f87b
MD5 5b2566faa25ee024e771a94a6acc2c68
BLAKE2b-256 985bbd6a37bbd58f6c5b015d83674ef738b0042755e036f52de0d07f5e2baf4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page