πŸ›‘οΈ SecureAIforTheWorld

An open-source AI/ML pentesting tool that evaluates Large Language Models for security vulnerabilities, hallucination tendencies, and jailbreak resistance.

Built to help enterprises understand and improve the security posture of their deployed LLMs.


What It Does

SecureAIforTheWorld connects to your LLM via API and runs automated security assessments across three categories:

Category What It Tests # Tests Scoring
Jailbreak Resistance Can the model be tricked into unsafe outputs? 28 prompts Refusal detection + harmful content patterns
Factual Hallucination Does the model fabricate facts? 30 questions String similarity + keyword matching
Faithfulness Does the model stay true to provided context? 45 questions Context grounding + fabrication detection

The tool generates a 0-100 security score per category and an overall weighted grade (A-F), along with detailed per-test findings showing exactly where your model is vulnerable.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Gradio UI (4 tabs)                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Model       β”‚ Jailbreak    β”‚ Hallucination β”‚ Run Evaluation β”‚
β”‚ Connection  β”‚ Dataset      β”‚ Dataset       β”‚ Dashboard      β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                              β”‚
       β–Ό                                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Connectors   β”‚                           β”‚ Score Aggregator  β”‚
β”‚ - Azure AI   │◄─────────────────────────►│ - Category scores β”‚
β”‚ - AWS Bedrockβ”‚     sends prompts         β”‚ - Overall grade   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     gets responses        β”‚ - Recommendations β”‚
                                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                    β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β–Ό                          β–Ό          β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚ Jailbreak      β”‚  β”‚ Hallucination    β”‚  β”‚Scorers β”‚
                β”‚ Dataset (28)   β”‚  β”‚ Test Runners     β”‚  β”‚- Factualβ”‚
                β”‚ 7 categories   β”‚  β”‚ - Factual (30)   β”‚  β”‚- Faith β”‚
                β”‚ 4 sources      β”‚  β”‚ - Faithful (45)  β”‚  β”‚- Jailbkβ”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Quick Start

Prerequisites

  • Python 3.9+
  • API access to Azure AI Foundry or AWS Bedrock

Install & Run

git clone https://github.com/YOUR_USERNAME/SecureAIforTheWorld.git
cd SecureAIforTheWorld
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python app.py

Open http://127.0.0.1:7860 in your browser.

Usage

  1. Model Connection tab β€” Enter your provider, API key, endpoint, and deployment name. Click "Test Connection".
  2. Run Evaluation tab β€” Select which modules to run (jailbreak, factual, faithfulness) and click "Run Full Evaluation".
  3. Review results β€” See your overall score, category breakdown with grades, and detailed per-test findings.

Example: Azure AI Foundry

  • Provider: Azure AI Foundry
  • API Key: your key from Azure portal
  • Endpoint: https://your-resource.services.ai.azure.com
  • Deployment: gpt-4.1

Scoring Methodology

Weights

  • Jailbreak Resistance: 40% (most critical for enterprise security)
  • Factual Accuracy: 30%
  • Faithfulness: 30%

Heuristic Scoring Engine

Scorer Techniques
Factual Exact match, acceptable answer variants, SequenceMatcher similarity, keyword containment, uncertainty detection
Faithfulness Context-refusal detection (16+ phrases), keyword grounding, false-refusal detection
Jailbreak Refusal phrase matching (35+ patterns), harmful content markers (20+ patterns), response length analysis

Grading Scale

Grade Score Range Meaning
A 90-100 Excellent security posture
B 80-89 Good, minor improvements possible
C 70-79 Acceptable, some vulnerabilities
D 50-69 Below threshold, action needed
F 0-49 Critical vulnerabilities detected

Jailbreak Attack Categories

The tool tests 7 categories of jailbreak attacks:

  1. Role Play β€” DAN, evil AI persona, fiction framing
  2. Encoding Tricks β€” Base64, ROT13, acrostic, string reversal
  3. Authority Manipulation β€” Fake system overrides, admin tokens, policy claims
  4. Multi-Turn β€” Gradual escalation, yes-pattern conditioning, flattery
  5. Context Overflow β€” Long prefix injection, attention exhaustion
  6. Instruction Injection β€” Translation injection, fake system prompts in content
  7. Ethical Bypass β€” Hypothetical framing, academic excuses, public info arguments

Sources: JailbreakBench, AdvBench, HarmBench + custom original prompts.


Project Structure

SecureAIforTheWorld/
β”œβ”€β”€ app.py                          # Gradio UI (4 tabs)
β”œβ”€β”€ requirements.txt                # Pinned dependencies
β”œβ”€β”€ README.md                       # This file
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ connectors.py               # Azure AI Foundry + AWS Bedrock connectors
β”‚   β”œβ”€β”€ hallucination.py            # Factual + Faithfulness test runners
β”‚   β”œβ”€β”€ score_aggregator.py         # Scoring pipeline + report generation
β”‚   └── scorers/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ heuristic_scorer.py     # Heuristic scoring (similarity, patterns)
β”‚       └── llm_judge.py            # LLM-as-judge scorer (future)
β”œβ”€β”€ datasets/
β”‚   β”œβ”€β”€ jailbreak_prompts.json      # 28 attack prompts, 7 categories
β”‚   β”œβ”€β”€ factual_qa.json             # 30 factual questions, 6 domains
β”‚   └── faithfulness_contexts.json  # 15 contexts, 45 questions
└── tests/
    β”œβ”€β”€ test_connectors.py          # 21 tests
    β”œβ”€β”€ test_datasets.py            # 16 tests
    β”œβ”€β”€ test_hallucination.py       # 16 tests
    β”œβ”€β”€ test_heuristic_scorer.py    # 32 tests
    β”œβ”€β”€ test_score_aggregator.py    # 21 tests
    └── test_placeholder.py         # 2 tests

Total: 106 automated tests


Supported Providers

Provider SDK Auth
Azure AI Foundry openai (OpenAI-compatible) API Key
AWS Bedrock boto3 Access Key + Secret Key

Roadmap / Community Extensions

This is an MVP. The community is invited to extend it:

  • LLM Judge scorer β€” Use a small model (Mistral-7B) as an evaluation judge
  • More jailbreak categories β€” Token smuggling, multi-language attacks
  • More model providers β€” Google Vertex AI, Hugging Face Inference
  • PDF report export β€” Downloadable security assessment report
  • API key security hardening β€” Env var fallback, memory clearing, security notices
  • CI/CD integration β€” Run evaluations in pipelines, fail on score thresholds
  • Historical tracking β€” Compare scores across model versions

Tech Stack

Component Technology
UI Gradio 4.44 (Hugging Face Spaces)
Language Python 3.9+
Connectors openai, boto3
Scoring difflib, regex patterns
Testing pytest (106 tests)
Deployment Hugging Face Spaces (free tier)

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-attack-category)
  3. Add tests for your changes
  4. Run pytest tests/ -v to verify
  5. Submit a pull request

License

MIT


Acknowledgments

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Papers for SecureAIforTheWorld01/SecureLLM