CoolFace
Modelpublic

SecureAIforTheWorld01/SecureLLM

sourceHugging Facemitupdated 2mo agoView on Hugging Face
1likes
Model Card

πŸ›‘οΈ 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:

CategoryWhat It Tests# TestsScoring
Jailbreak ResistanceCan the model be tricked into unsafe outputs?28 promptsRefusal detection + harmful content patterns
Factual HallucinationDoes the model fabricate facts?30 questionsString similarity + keyword matching
FaithfulnessDoes the model stay true to provided context?45 questionsContext 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

bash
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. 1.Model Connection tab β€” Enter your provider, API key, endpoint, and deployment name. Click "Test Connection".
  2. 2.Run Evaluation tab β€” Select which modules to run (jailbreak, factual, faithfulness) and click "Run Full Evaluation".
  3. 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

ScorerTechniques
FactualExact match, acceptable answer variants, SequenceMatcher similarity, keyword containment, uncertainty detection
FaithfulnessContext-refusal detection (16+ phrases), keyword grounding, false-refusal detection
JailbreakRefusal phrase matching (35+ patterns), harmful content markers (20+ patterns), response length analysis

Grading Scale

GradeScore RangeMeaning
A90-100Excellent security posture
B80-89Good, minor improvements possible
C70-79Acceptable, some vulnerabilities
D50-69Below threshold, action needed
F0-49Critical vulnerabilities detected

Jailbreak Attack Categories

The tool tests 7 categories of jailbreak attacks:

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

ProviderSDKAuth
Azure AI Foundryopenai (OpenAI-compatible)API Key
AWS Bedrockboto3Access 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

ComponentTechnology
UIGradio 4.44 (Hugging Face Spaces)
LanguagePython 3.9+
Connectorsopenai, boto3
Scoringdifflib, regex patterns
Testingpytest (106 tests)
DeploymentHugging Face Spaces (free tier)

Contributing

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

License

MIT


Acknowledgments