Metadata-Version: 2.5
Name: crucible-verify
Version: 0.1.1
Summary: Deterministic AI security verification MCP server with cryptographic evidence chains
Project-URL: Homepage, https://github.com/Sandeep332005/Crucible-
Project-URL: Repository, https://github.com/Sandeep332005/Crucible-
Project-URL: Issues, https://github.com/Sandeep332005/Crucible-/issues
Author: Sandeep Kumar
License-Expression: MIT
Keywords: ai-safety,mcp,penetration-testing,security,verification
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Requires-Python: >=3.11
Requires-Dist: mcp
Description-Content-Type: text/markdown

<!-- mcp-name: io.github.Sandeep332005/crucible -->

<p align="center">
  <img src="https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white" alt="Rust">
  <img src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white" alt="Python">
  <img src="https://img.shields.io/badge/MCP-Model_Context_Protocol-blueviolet?style=for-the-badge" alt="MCP">
  <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="License">
  <img src="https://img.shields.io/pypi/v/crucible-verify?style=for-the-badge&color=blue" alt="PyPI">
  <br>
  <img src="https://img.shields.io/badge/Cage%20Parity-100.0%25-00e5ff?style=for-the-badge" alt="Cage Parity">
  <img src="https://img.shields.io/badge/Tests-66%20Passed-10b981?style=for-the-badge" alt="Tests">
  <img src="https://img.shields.io/badge/Hallucinations-0.0%25-success?style=for-the-badge" alt="Hallucinations">
</p>

<h1 align="center">Crucible</h1>
<h3 align="center">Deterministic AI Security Verification Harness</h3>

<p align="center">
  <b>Claims In. Proven Verdicts Out. Zero Hallucinations.</b><br>
  A hybrid Rust + Python MCP server that constrains autonomous AI security agents inside <b>The Cage</b> — transforming probabilistic guesses into cryptographically-verified, replay-deterministic proofs.
</p>

<p align="center">
  <a href="https://sandeep332005.github.io/Crucible-/3d-cage.html"><b>🎮 Launch Live 3D WebGL Explorer</b></a> &bull;
  <a href="#the-cage-architecture">The Cage Architecture</a> &bull;
  <a href="#interactive-demo">Interactive Demo</a> &bull;
  <a href="#live-benchmark-results">crAPI Benchmark</a> &bull;
  <a href="#the-5-edge-functions">5 Edge Functions</a> &bull;
  <a href="#the-143-pattern-noise-gate">143 Noise Rules</a> &bull;
  <a href="#quick-start">Quick Start</a> &bull;
  <a href="#cryptographic-proof-reports">Proof Exporter</a>
</p>

---

<p align="center">
  <a href="https://sandeep332005.github.io/Crucible-/3d-cage.html" title="Click to launch interactive 3D WebGL scene">
    <img src="assets/crucible-cage-3d.gif" alt="Crucible 3D Cage Architecture Animation" width="100%">
  </a>
  <br>
  <sub><i>▲ Continuous 3D isometric simulation of The Cage. <b><a href="https://sandeep332005.github.io/Crucible-/3d-cage.html">Click here to launch the 360° Interactive Three.js 3D Explorer</a></b>.</i></sub>
</p>

---

## The Problem

Autonomous AI agents hallucinate security vulnerabilities. In unconstrained benchmark testing, autonomous LLM security scanners yield **~78% false positives** — producing roughly 14 fabricated findings for every 4 genuine bugs. 

Triagers waste hundreds of engineering hours sorting through low-signal noise, missing CSP headers, and out-of-scope reports. Worse, unconstrained agents have **no cryptographic evidence chain**: if a security engineer or client asks *"prove this exploit executed against origin"*, the agent can offer only conversational logs.

## The Solution: The Cage

Crucible does not merely scan or guess. It **cages** the AI agent. Every hypothesis generated by the model must survive a gauntlet of **5 deterministic edge functions** and a 3-legged differential verification harness:

```
  CONFIRMED  ──  Cryptographic proof: canary marker verified across trust boundary
  DISPROVEN  ──  Mathematical proof: response matches negative control at origin
  UNRESOLVED ──  Insufficient evidence or edge WAF block: cannot safely prove or disprove
```

* **Zero Trust in AI Output:** Every HTTP interaction is captured as a SHA-256 hashed `.bin` artifact.
* **Deterministic Replay:** Any finding can be independently replayed and mathematically verified years later.
* **Dual Origin Check:** Disproval logic asserts that negative controls genuinely touched the origin backend rather than an edge CDN/WAF block.
* **The 143 Noise Gate:** Automatically suppresses reports matching the complete Bugcrowd VRT and HackerOne non-qualifying taxonomy before human triage.

---

## Interactive Demo

Experience Crucible's verification pipeline with zero external dependencies:

```bash
crucible-core demo
```

```text
====================================================================
        CRUCIBLE : DETERMINISTIC AI SECURITY CAGE DEMO             
====================================================================
Architecture: The Cage (100% Parity Rig)
Specification: 5 Deterministic Edge Functions | 143 Noise Rules

[ACT 1: THE 143 NOISE GATE (PREVENTING TRIAGE NOISE)]
  AI Claim:       "Missing Content-Security-Policy header on /dashboard"
  Impact Claim:   "User may be vulnerable to in-page script injection"
  Cage Analysis:  Running f_noise(claim)...
  [REJECTED]      Matched Pattern #32: (?i)missing.*(csp|content.?security.?policy)
  Rationale:      "Missing CSP is a hardening recommendation, not a vulnerability."
  Verdict:        SUPPRESSED — Zero human triage cycles wasted.

[ACT 2: DUAL ORIGIN & WAF DETECTION (PREVENTING FALSE DISPROVALS)]
  AI Claim:       "Broken Object Level Authorization (BOLA) on /api/user/4891"
  Triad Engine:   Executing Positive, Negative, and Test probes...
    Positive:     GET /api/user/me   -> 200 OK  [Origin Reached: true]
    Negative:     GET /api/user/9999 -> 403 Forbidden [Origin Reached: false (Cloudflare WAF Block)]
    Test Exploit: GET /api/user/4891 -> 403 Forbidden [Origin Reached: false]
  Cage Analysis:  test_fp == neg_fp, BUT negative control blocked at edge WAF!
  [UNRESOLVED]    Negative control blocked at edge/WAF, did not reach origin.
  Verdict:        CAGE PROTECTED — AI prevented from hallucinating DISPROVEN.

[ACT 3: THE 3-LEGGED TRIAD (CRYPTOGRAPHIC VERIFICATION)]
  AI Claim:       "Vehicle PII Exfiltration via /api/v2/vehicle/order"
  Triad Engine:   Executing Positive, Negative, and Test probes...
    Positive:     GET /api/v2/vehicle/1   -> 200 OK [Marker 'VIN-90812' found]
    Negative:     GET /api/v2/vehicle/2   -> 200 OK [Marker 'VIN-90812' absent]
    Test Exploit: GET /api/v2/vehicle/1   -> 200 OK [Target Marker 'VIN-90812' matched]
  Cage Analysis:  Cross-boundary differential match confirmed!
  [CONFIRMED]     Target marker 'VIN-90812' found in test response (status 200).
  Evidence Hash:  SHA-256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  Verdict:        MATHEMATICAL PROOF ACHIEVED — 0.0% Hallucination Guarantee.
```

---

## Live Benchmark Results

Tested against **OWASP crAPI** (Completely Ridiculous API) — the industry-standard deliberately vulnerable application.

> **Live Interactive Report:** Explore the full interactive benchmark artifact with clickable request payloads, diff viewers, and SHA-256 checks at [sandeep332005.github.io/Crucible-](https://sandeep332005.github.io/Crucible-/).

```
┌─────────────────────┬──────────────────────────┬────────────────────┐
│ Metric              │ Crucible (The Cage)      │ Unconstrained AI   │
├─────────────────────┼──────────────────────────┼────────────────────┤
│ Precision           │ 100.0%                   │ ~22.0%             │
│ False Positive Rate │ 0.0%                     │ ~78.0%             │
│ Replay Rate         │ 100.0% (deterministic)   │ 0.0% (stochastic)  │
│ Scope Violations    │ 0 (compiled regex gate)  │ Best-effort prompt │
│ Evidence Integrity  │ SHA-256 Chained .bin     │ Unstructured logs  │
│ Benchmark Outcome   │ 5 Confirmed, 2 Disproven │ 18 (14 Hallucinated│
└─────────────────────┴──────────────────────────┴────────────────────┘
```

### Verified Findings on OWASP crAPI

| Finding ID | Vulnerability | Domain | Verdict | Cryptographic Proof |
|:---|:---|:---|:---:|:---|
| **T1** | Vehicle Location BOLA | IDOR / Authz | **CONFIRMED** | Cross-user GPS coordinates & PII leaked via vehicle UUID |
| **T2** | Workshop Order IDOR | IDOR | **CONFIRMED** | Victim email & phone disclosed via sequential order ID |
| **T3** | Negative Quantity Credit Fraud | Business Logic | **CONFIRMED** | User balance increased 100 → 250 via `quantity: -10` |
| **T4** | SSRF via `contact_mechanic` | SSRF | **CONFIRMED** | Internal microservice token exfiltrated in payload |
| **T5** | Session Invalidation Failure | Authentication | **CONFIRMED** | JWT remains valid on backend post-logout endpoint |
| **T6** | Arithmetic RCE Probe | RCE | **DISPROVEN** | Math echo product `$((A*B))` absent; returns 404 |
| **T7** | Time-Based SQL Injection | SQLi | **DISPROVEN** | 3-Sigma analysis: $\Delta = 10\text{ms}$ vs $5000\text{ms}$ expected |

---

## The 5 Edge Functions

Crucible mathematically formalizes vulnerability discovery as five deterministic edge functions:

```
           Claim (u, C, T)
                 │
                 ▼
         ┌───────────────┐      No
         │ f_scope(u) ?  ├──────────────► [ABORT: Out of Scope]
         └───────┬───────┘
                 │ Yes
                 ▼
         ┌───────────────┐      Match
         │ f_noise(C) ?  ├──────────────► [SUPPRESS: Known Non-Bug]
         └───────┬───────┘
                 │ Pass
                 ▼
         ┌───────────────┐
         │ f_triad(P,N,T)│
         └───────┬───────┘
                 ├─── Marker Present ───► [CONFIRMED (Proof)]
                 │
                 └─── Match Negative ───► ┌──────────────────┐
                                          │ f_origin(H) ?    │
                                          └────────┬─────────┘
                                                   ├─── Origin Reached ──► [DISPROVEN]
                                                   └─── WAF Blocked    ──► [UNRESOLVED]
```

### 1. Scope Boundary Gate: $f_{\text{scope}}$
$$f_{\text{scope}}: \text{URL} \to \{\text{Allowed}, \text{Denied}\}$$
Compiles strict regex boundaries in native Rust. Blocks network calls before DNS resolution if target parameters attempt egress outside explicitly permitted roots.

### 2. Triad Differential Verification: $f_{\text{triad}}$
$$f_{\text{triad}}(P, N, T) \to \{\text{CONFIRMED}, \text{DISPROVEN}, \text{UNRESOLVED}\}$$
Evaluates a 3-legged differential experiment:
* **Positive Control ($P$):** Accessing authorized resource with canary marker. Verifies endpoint is active.
* **Negative Control ($N$):** Accessing non-existent resource. Establishes baseline error profile.
* **Test Request ($T$):** The unauthorized exploit attempt across the trust boundary.

### 3. Dual Origin vs WAF Classifier: $f_{\text{origin}}$
$$f_{\text{origin}}(\text{Headers}) \to \{\text{Edge/WAF}, \text{Origin}\}$$
Grounded in differential security research (USENIX DiffCSP). Distinguishes superficial edge blocks (Cloudflare, Akamai 403/429/503) from genuine backend logic. Asserts that both test and negative requests reached origin before concluding `DISPROVEN`.

### 4. 3-Sigma Statistical Timing Engine: $f_{\text{timing}}$
$$z = \frac{\bar{T}_{\text{probe}} - T_{\text{baseline}}}{\sigma}$$
Evaluates time-based blind injection (SQLi, Command Injection). Requires $z \ge 3.0$ and $\bar{T} \ge 0.8 \times \text{delay}$ over multiple runs to eliminate jitter false positives.

### 5. Noise Gate (143 Rejection Rules): $f_{\text{noise}}$
$$f_{\text{noise}}(\text{Claim}) \to \{\text{Pass}, \text{Reject}\}$$
Evaluates vulnerability claims against 143 Bugcrowd VRT and HackerOne non-qualifying closure reasons.

---

## The 143-Pattern Noise Gate

Crucible filters out reports across 11 standard rejection classes before wasting human review time:

| Category | Patterns | Common Intercepted Findings |
|:---|:---:|:---|
| **Headers & Transport** | 14 | Missing CSP, HSTS, X-Frame-Options, Permissions-Policy, Cookie flags without hijack, HPKP |
| **CORS & CSRF** | 10 | Permissive CORS without credentials, preflight cache, Login/Logout CSRF, idempotent search CSRF |
| **UI Redress & Client** | 14 | Self-XSS, copy-paste XSS, clickjacking without state-change, tabnabbing, autocomplete UX |
| **Info Disclosure** | 17 | Stack traces without secrets, username/email enumeration, directory indexing, robots.txt, swagger |
| **Rate Limiting & DoS** | 11 | Missing rate limiting on public search/forms, Slowloris, theoretical ReDoS, compression bombs |
| **Email & Transport** | 11 | Missing SPF/DKIM/DMARC, TLS 1.0/1.1 without cipher weakness, self-signed test certs |
| **DNS & Infrastructure** | 6 | Subdomain takeover without proof/claim, AXFR without internal records, WHOIS, DNSSEC |
| **Injection Reachability**| 15 | CSV injection, SQL syntax errors without extraction, SSRF without metadata/OOB, XXE without file leak |
| **Auth & Sessions** | 12 | Weak password policies, password expiration, session not expiring on browser close |
| **Mobile Client Boundaries**| 12 | Root detection, cert pinning bypass, task switcher screenshots, ProGuard omission, Google Maps keys |
| **Logic & Dependencies**| 11 | Outdated library banner without reachable CVE, scraping public data, price tamper without checkout |

---

## Comparative Matrix

| Feature | Crucible (The Cage) | DAST (Nuclei/ZAP) | SAST (Semgrep/Snyk) | Raw LLMs (PentestGPT) |
|:---|:---:|:---:|:---:|:---:|
| **False Positive Rate** | **0.0% (Proven)** | 35% – 60% | 40% – 70% | ~78% (Hallucinated) |
| **Evidence Storage** | **SHA-256 .bin** | Text logs | AST Snippet | Conversational Text |
| **Differential Triad Testing** | **Yes (3-Legged)** | No | No | No |
| **Dual Origin WAF Shield** | **Yes** | No | No | No |
| **143-Rule Triage Gate** | **Built-in** | Manual Tags | No | No |
| **Deterministic Replay** | **100% Replayable** | Best-effort | Replayable | Non-deterministic |
| **Model Context Protocol (MCP)**| **Native 6 Tools** | External CLI | Plugin | API Prompting |

---

## Quick Start

### 1. Build from Source

```bash
git clone https://github.com/Sandeep332005/Crucible-.git
cd Crucible-

# Build optimized Rust core
cargo build --release

# Add to PATH (or link binary)
export PATH="$PWD/target/release:$PATH"
crucible-core --help
```

### 2. Configure Scope

Create `~/.crucible/config.toml`:

```toml
[scope]
allowed = [
    "^https://api\\.target\\.com/",
    "^https://staging\\.target\\.com/v[12]/"
]

[origin]
markers = ["x-backend-server", "x-origin-id", "x-request-id"]
```

### 3. Run Verification Probes

```bash
# Initialize a session
crucible-core init

# Send probed requests (evidence saved as immutable SHA-256 .bin files)
crucible-core probe GET "https://api.target.com/user/me" -H "Authorization: Bearer $MY_TOKEN"
crucible-core probe GET "https://api.target.com/user/0000" -H "Authorization: Bearer $MY_TOKEN"
crucible-core probe GET "https://api.target.com/user/victim_id" -H "Authorization: Bearer $MY_TOKEN"

# Evaluate Triad
crucible-core triad op_pos_id op_neg_id op_test_id \
    --pos-marker "myemail@domain.com" \
    --target-marker "victim@domain.com"
```

---

## Cryptographic Proof Reports

Export any session into a standalone, single-file HTML proof report:

```bash
crucible-core export-proof --output proof.html
```

The generated artifact bundles:
* Complete audit summary with verified SHA-256 hashes.
* Full raw HTTP request headers and response payloads.
* Embedded offline client-side JavaScript verifier (zero CDN dependencies).
* Ready to attach directly to HackerOne, Bugcrowd, or internal security tickets.

---

## MCP Server Integration

Crucible natively exposes its verification engine over the Model Context Protocol (stdio):

```json
{
  "mcpServers": {
    "crucible": {
      "command": "python3",
      "args": ["-m", "crucible_mcp.server"],
      "cwd": "/path/to/crucible/src"
    }
  }
}
```

### Available MCP Tools

* **`check_scope`**: Validates target URL against compiled Rust regex boundary.
* **`probe_endpoint`**: Dispatches HTTP probe and commits raw evidence to disk.
* **`evaluate_triad`**: Runs differential verification with dual origin check.
* **`assert_invariant`**: Evaluates business logic invariants (`balance_conserved`, `refund_lte_charge`).
* **`filter_noise`**: Runs claims against the 143 Bugcrowd/HackerOne rejection catalog.
* **`bind_state`**: Extracts response values (JSONPath) and binds them to downstream requests.

---

## Defensive Hardening

Crucible is tested against the 5 core MCP attack vectors across **66 automated tests**:

```bash
pytest tests/
```

```text
============================== 66 passed in 0.35s ==============================
- Filesystem Boundary: Path traversal in op_ids strictly blocked
- Subprocess Execution: Shell metacharacters treated as literals (shell=False)
- Network Egress: Private CIDRs and cloud metadata endpoints (169.254.169.254) blocked
- Schema Integrity: Type and length boundaries enforced on all arguments
- Tool Shadowing: Registry integrity checks and name collisions rejected
- Noise Gate Parity: 143 patterns validated for regex compilation and category coverage
```

---

## License

MIT License. Designed for security teams, independent researchers, and autonomous agent builders who demand deterministic proof over probabilistic hallucinations.
