kraken-v2 / README.md
zkaedi's picture
Upload README.md with huggingface_hub
969fa6d verified
|
Raw History Blame Contribute Delete
3.87 kB
metadata
tags:
  - safetensors
  - zkaedi-prime
  - hamiltonian-dynamics
  - vulnerability-detection
  - bytecode-analysis
  - bare-metal
  - evm
  - smart-contracts
  - security
  - ensemble-specialist
license: mit

🔱 Kraken v2.2 — Bytecode Feature Vulnerability Classifier

Ensemble Specialist #2 (Leviathan v2 = Specialist #1)

8 independent binary MLP classifiers detecting EVM bytecode vulnerability patterns. Each classifier answers one question: "Is this bytecode vulnerable to [specific class]?"

Architecture

EVM Bytecode
  → Disassemble (skip PUSH immediates)
  → 32-dim hand-crafted feature vector:
      [0-15]  Category ratios (16 opcode categories)
      [16]    Unguarded CALL→SSTORE (reentrancy signal)
      [17]    SSTORE before CALL (CEI safe pattern)
      [18-21] Dangerous opcode flags (DELEGATECALL, SELFDESTRUCT, ORIGIN, TIMESTAMP)
      [22]    Guarded CALL→SSTORE (anti-reentrancy)
      [23]    Arithmetic without guard ratio (overflow risk)
      [24-25] Context (CALLVALUE, BALANCE)
      [26]    Consecutive CALLs without SSTORE (flash loan)
      [27]    Unchecked CALL (CALL→POP)
      [28-31] Statistical (total ops, unique ops, entropy, CALL density)
  → 8× BinaryMLP(32 → 32 → 1)
  → 19-dim score vector

Performance

Class F1 Precision Recall
Reentrancy (SWC-107) 1.000 1.000 1.000
Integer Overflow (SWC-101) 1.000 1.000 1.000
tx.origin Auth (SWC-115) 1.000 1.000 1.000
Delegatecall Inj (SWC-112) 1.000 1.000 1.000
Flash Loan Attack 1.000 1.000 1.000
Selfdestruct (SWC-106) 1.000 1.000 1.000
Timestamp Dep (SWC-116) 1.000 1.000 1.000
Unchecked Return (SWC-104) 1.000 1.000 1.000

Total parameters: 8,712 (1,089 per classifier × 8 classifiers)

Ensemble Fusion (v2.2)

For 2 specialists (Leviathan + Kraken), simple rule-based fusion:

  • Both flag > 0.5 → THREAT (mean + 0.10 agreement boost)
  • One flags > 0.8 → THREAT (max × 0.85 single-detect)
  • One flags > 0.5 → UNCERTAIN (max × 0.50)
  • Neither flags → CLEAN (pass through)

No FHN Laplacian coupling (caused cross-class energy leaking in v2.1). FHN with kappa=0 reserved for 3+ specialists.

ZKAEDI Security Pipeline

Solidity Code
  → gemma-2-9b-solidity-merged (vulnerability energy signatures)
    → prime-swarm-hunter (12-agent temporal compound detection)
      → LEVIATHAN v2 (EVM trace topology: 265K params)
      → KRAKEN v2.2 (bytecode features: 8,712 params)  ← THIS MODEL
        → PRIME Simple Fusion (rule-based for 2 specialists)
          → solidity-vuln-auditor-7b (final audit report)

Usage

from safetensors.numpy import load_file
import numpy as np

# Load weights
d = load_file("kraken_v2.2.safetensors")

# Reconstruct classifier (example for reentrancy)
w1, b1 = d["reentrancy.w1"], d["reentrancy.b1"]
w2, b2 = d["reentrancy.w2"], d["reentrancy.b2"]

# Inference
features = extract_features(bytecode)  # 32-dim vector
h = np.maximum(features @ w1.T + b1, 0)  # ReLU
score = 1.0 / (1.0 + np.exp(-(h @ w2.T + b2)[0]))  # sigmoid

Companion Files

File Purpose
kraken_v2.2.safetensors Trained weights (safetensors)
kraken_v2.2.npz Trained weights (numpy)
kraken_v2.2_weights.h C header for bare-metal inference

Version History

  • v1.0: CNN on 16×16 manifold, 265K params → dead (all outputs 0.105)
  • v1.1: +MaxPool, 19K params → still dead (sparse manifold)
  • v2.0: Feature-based + 8 binary MLPs → 7/8 F1=1.0, reentrancy FPs
  • v2.1: Strict reentrancy features → 8/8 F1=1.0, but FHN Laplacian leaked
  • v2.2: Simple fusion rules for 2 specialists → clean, no false positives ✓

Author

ZKAEDI — Offensive Healer