Skip to content

About

A sandboxed research testbed where a defense AI continuously rewrites its own execution policy to counter an adaptive attacker

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Self-Modifying Runtime

Adversarially Evolving Computation — a sandboxed research testbed where a defense AI continuously rewrites its own execution policy to counter an adaptive attacker in a minimax game loop, on top of an information-flow (taint-tracking) abstract machine. The default experiment world models the July 2026 Hugging Face intrusion kill chain.


The Idea

Normal computers have a fixed execution policy. This system has a mutable one. An adversarial attacker probes the machine; a defender observes each disclosure — including partial ones like arithmetic oracles — generalises it into a counterexample-guided patch, has it verified and signed by an immutable core, and deploys it. The machine's attack surface is rewritten after every round:

Attack → Grade disclosure → Defend (CEGIS) → Verify → Sign → Deploy → repeat

Soundness properties

  1. Authenticated principals below the mutable policy. Commands carry credentials; the substrate verifies identity and overrides claims — issuer spoofing is impossible by construction, and no policy rewrite can undo it.
  2. Taint lattice everywhere. Every derived value carries the highest classification of its operands: copies preserve labels, sums/compares of secrets are secret-derived, only sanctioned ≤1-bit sanitizers declassify, and writing sensitive-derived data into a lower-labeled container raises a label-downgrade counterexample before the value settles.
  3. Honest grading, honest worlds, honest states. Disclosures are graded from the lattice; attacker_knowledge measures what the attacker has deduced; generated worlds use neutral shuffled names so the black-box attacker learns nothing from naming; a deadlocked defense is reported as UNRECOVERABLE, never as eternal "EVOLVING".
  4. A verifier whose guarantees are enforced. Pure checks; HMAC approval that install_policy verifies; multi-variant utility probes; anti-rollback differential probing so restrictions can only be added or generalized.
  5. Genuine CEGIS defense. Counterexample suite → candidate ladder incl. a quarantine rung → compound (set-cover) synthesis with joint utility checks → pruning so complexity can go down.

Architecture

┌──────────────────────────────────────────────┐
│ IMMUTABLE CORE                               │
│  Verifier: pure checks · HMAC approval       │
│  anti-rollback probing · signed installs     │
│  PrincipalRegistry: credential-based identity│
└──────────────┬───────────────────────────────┘
               ▼
┌──────────────────────────────────────────────┐
│ MUTABLE RUNTIME                              │
│  ordered rules + fail-closed posture         │
│  max-over-operands gating · effect semantics │
│  quarantine (ISOLATE) · label-downgrade guard│
└──────────────┬───────────────────────────────┘
               ▼
┌──────────────────────────────────────────────┐
│ ABSTRACT MACHINE (taint lattice)             │
│  class(result) = ⨆ class(operands)           │
│  bounded scratch · redacted snapshots        │
└──────────────────────────────────────────────┘

Project Layout

self-modifying runtime/
├── core/
│   ├── machine.py       # Abstract machine + taint lattice + bounded scratch
│   ├── scenario.py      # Parameterized worlds: declarations + generators
│   ├── policy.py        # Mutable policy DSL: rules, posture, pruning
│   ├── runtime.py       # Policy-enforcing dispatcher, signed installation
│   ├── auth.py          # Principal registry: credential-verified identity
│   ├── verifier.py      # Immutable gatekeeper (5 checks + HMAC approval)
│   └── audit.py         # Hash-chained audit log (verifiable, exportable)
├── agents/
│   ├── attacker.py      # random | search | rl | oracle (+ belief deduction)
│   └── defender.py      # Counterexample-guided synthesizer (CEGIS)
├── engine/
│   ├── minimax.py       # Budgeted sampled α–β game-tree search
│   ├── synthesizer.py   # CEGIS loop against the pure verifier checks
│   └── coevolution.py   # Orchestrator: grading, metrics, convergence
├── experiments/
│   ├── metrics.py       # RoundMetrics incl. knowledge & integrity
│   └── visualizer.py    # Dark-mode matplotlib panels
├── dashboard/           # Live dashboard (Chart.js + D3 policy tree)
├── tests/               # pytest — one regression test per fixed flaw class
├── SPRINT/              # Sprint submission (standard, matrix, checklist, RFI)
├── ANALYSIS.md          # Critical audit summary
├── sprint_evidence.py   # Ablation table generator (~2 min)
├── sprint_hf_replay.py  # Kill-chain replay (~10 s)
├── main.py              # CLI (run / sweep / serve / plot)
├── server.py            # WS + HTTP server for the dashboard
└── requirements.txt

Setup

pip install -r requirements.txt

Usage

# Run on the default incident scenario
python main.py run --attacker random --epochs 30 --seed 42

# Game-tree search attacker
python main.py run --attacker search --epochs 30 --depth 3

# Ablation: spoofing without auth (total compromise)
python main.py run --attacker random --spoof 0.5 --no-auth

# Reproducible multi-seed sweep
python main.py sweep --modes random,oracle --seeds 1,7,42 --epochs 25 --out sweep.json

# Live dashboard (starts on first browser connect)
python main.py serve --attacker search --epochs 20 --seed 42 --rounds 5

# Kill-chain replay (P₀ vs hardened v0.1 posture)
python sprint_hf_replay.py

# Ablation evidence table
python sprint_evidence.py

Tests

pytest tests/ -v
File Covers
test_machine.py taint propagation, scratch bounds, redacted snapshots
test_policy.py matching, fail-closed posture, pruning, validation
test_verifier.py purity, signatures, targeted-condition bypass, escalation, anti-rollback
test_runtime.py effect semantics, mixed-operand gating, signed install
test_auth_and_rigor.py spoof coercion, black-box views, stale equations, quarantine, UNRECOVERABLE
test_audit.py chain verification, tamper detection, export round-trip
test_agents.py attacker deduction/corruption-resistance, defender CEGIS
test_scenarios.py generated worlds, multi-secret, agent source purity, soak invariants
test_arena.py end-to-end invariants, seed reproducibility, containment
test_hf_replay.py kill-chain replay: P₀ leaks, hardened contains, spoof blocked

Key Concepts

Term Meaning
Policy Ordered Allow/Deny/Transform/Require/Isolate rules + mutable fail-closed posture
Principal Credential-verified identity (attacker / legitimate); claims never trusted
Posture Least-privilege switch: unmatched untrusted access to sensitive data is denied
Taint lattice PUBLIC < PROTECTED < SECRET; derivations take the join of operands
Label downgrade Sensitive-derived data written into a lower-labeled container — flagged pre-settlement
Quarantine ISOLATE-based masking of attacker deliveries from a poisoned container, legit users unaffected
Disclosure grades protected / oracle (partial) / full (verbatim secret revealed)
Attacker knowledge Fraction of secret values correctly deduced from disclosures
CEGIS Counterexample-guided synthesis: propose → replay attacks+probes locally → refine
Anti-rollback Verifier rejects any candidate denying less than the current policy
UNRECOVERABLE Defender provably deadlocked amid continuing disclosures — a reported lost state

About

A sandboxed research testbed where a defense AI continuously rewrites its own execution policy to counter an adaptive attacker

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages