Skip to content

Commit 16db9e0

Browse files
committed
feat(v1.3.0): Profile E/C reframe, Security V2 (205/205), offline verify-bundle, 753-case 4-oracle harness & RETRACTION.md
1 parent e1a1e3d commit 16db9e0

193 files changed

Lines changed: 52944 additions & 932 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77

88
env:
99
CARGO_TARGET_DIR: /tmp/cowrie-cargo-target
10+
# The Bend kernel artifact is committed at harness/kernel/ with provenance
11+
# (PROVENANCE.json) and verified nightly by `make kernel-verify`, which
12+
# recompiles from formal/CowrieKernel.bend and compares sha256. The PR gate
13+
# runs all four oracles against the committed artifact.
14+
HARNESS_ORACLES: rust,py,wasm,bend
1015

1116
jobs:
1217
verify:
@@ -29,12 +34,57 @@ jobs:
2934
- name: WebAssembly build & Node test suite
3035
run: make wasm
3136
- name: Ecosystem connectors, Cloudflare Workers & adversarial/legacy suites
32-
run: make connectors && make adversarial
37+
run: make connectors && make adversarial-legacy
38+
- name: Security V2 adversarial suite, vLLM Profile E/C unit gates & offline verify-bundle tests
39+
run: |
40+
COWRIE_LIB_PATH=/tmp/cowrie-cargo-target/release/libcowrie_core.so python3 tests/test_security_v1_3_adversarial.py
41+
COWRIE_LIB_PATH=/tmp/cowrie-cargo-target/release/libcowrie_core.so python3 tests/test_vllm_kv_connector_unit.py
42+
COWRIE_LIB_PATH=/tmp/cowrie-cargo-target/release/libcowrie_core.so python3 tests/test_evidence_bundle.py
3343
- name: Build & smoke-test self-contained Python wheel
3444
run: |
3545
python3 -m pip install --upgrade setuptools wheel
3646
make wheel
3747
python3 -m venv /tmp/wheel-venv
3848
/tmp/wheel-venv/bin/pip install /tmp/cowrie-dist/*.whl
3949
/tmp/wheel-venv/bin/cowrie --version
40-
/tmp/wheel-venv/bin/python -c "import cowrie; from cowrie.integrations.langgraph import CowrieLangGraphGuard; print(cowrie.alpha_handle(cowrie.verify_frame(cowrie.encode_json({'ok':1}))['cid']))"
50+
/tmp/wheel-venv/bin/python -c "import cowrie; from cowrie import evidence, profiles; from cowrie.integrations.langgraph import CowrieLangGraphGuard; print(cowrie.__version__, cowrie.alpha_handle(cowrie.verify_frame(cowrie.encode_json({'ok':1}))['cid']))"
51+
52+
adversarial:
53+
runs-on: ubuntu-latest
54+
timeout-minutes: 10
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: dtolnay/rust-toolchain@stable
58+
with:
59+
targets: wasm32-unknown-unknown
60+
- uses: actions/setup-python@v5
61+
with:
62+
python-version: "3.12"
63+
- uses: actions/setup-node@v4
64+
with:
65+
node-version: "22"
66+
- name: Cache Cargo and harness build artifacts
67+
uses: actions/cache@v4
68+
with:
69+
path: |
70+
~/.cargo
71+
harness/cowrie-harness/target
72+
key: ${{ runner.os }}-cowrie-harness-${{ hashFiles('harness/**/Cargo.lock') }}
73+
restore-keys: |
74+
${{ runner.os }}-cowrie-harness-
75+
- name: Verify CowrieError disposition ABI freeze
76+
run: make abi-check
77+
- name: Build wasm32 oracle artifact
78+
run: RUSTFLAGS="-C strip=symbols" cargo build -p cowrie-core --target wasm32-unknown-unknown --release
79+
- name: Run adversarial differential harness
80+
run: make adversarial
81+
- name: Upload harness triage artifacts on failure
82+
if: failure()
83+
uses: actions/upload-artifact@v4
84+
with:
85+
name: adversarial-harness-triage
86+
path: |
87+
harness/
88+
!harness/cowrie-harness/target
89+
if-no-files-found: warn
90+
retention-days: 14
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: kernel-provenance
2+
3+
# The PR gate runs the Bend oracle against a committed, provenance-stamped artifact
4+
# (harness/kernel/cowrie_kernel_verified.mjs + PROVENANCE.json). Bend compilation is
5+
# deterministic, so this nightly job installs the pinned compiler, recompiles the kernel
6+
# from formal/CowrieKernel.bend, and fails if the sha256 no longer matches. That keeps the
7+
# 10-minute PR budget while proving the artifact really is the one the source produces.
8+
9+
on:
10+
schedule:
11+
- cron: "17 4 * * *" # 04:17 UTC nightly
12+
workflow_dispatch:
13+
14+
jobs:
15+
kernel-verify:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 90
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: dtolnay/rust-toolchain@stable
22+
23+
- name: Cache cargo bin + registry
24+
uses: actions/cache@v4
25+
with:
26+
path: |
27+
~/.cargo/bin
28+
~/.cargo/registry
29+
~/.cargo/git
30+
key: ${{ runner.os }}-bend-2.0.35-${{ hashFiles('harness/kernel/PROVENANCE.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-bend-2.0.35-
33+
34+
- name: Install Bend 2.0.35 (pinned)
35+
run: |
36+
if ! command -v bend >/dev/null; then
37+
cargo install bend-lang --version 2.0.35 --locked
38+
fi
39+
bend --help | head -3
40+
41+
- name: Verify committed kernel artifact matches its source
42+
run: make kernel-verify
43+
44+
- name: Run the full harness with all four oracles
45+
run: make adversarial
46+
env:
47+
HARNESS_ORACLES: rust,py,wasm,bend

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ __pycache__/
1010
wasm/cowrie_core.wasm
1111
wasm/*.tgz
1212
formal/lean/.lake/
13+
harness/witnesses.jsonl
14+
harness/cowrie-harness/target/
15+
docs/ECONOMIC-IMPACT-AND-OUTREACH.md
16+
docs/*.bak-*
17+
docs/*.draft.md

‎CHANGELOG.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Changelog
2+
3+
All notable changes to Cowrie (`cowrie-ai`) are documented in this file.
4+
5+
## [1.3.0] — 2026-11-29
6+
7+
### Architecture & Scale Inversion (32K–250K & Big/MoE)
8+
- **Profile E (Edge) / Profile C (Cloud) Split (`python/cowrie/profiles.py`, `docs/PROFILES.md`):** Separated local workstation and multi-tenant cloud serving into explicit, immutable presets sharing one canonical core.
9+
- **Profile E (Edge):** `durable=True` (`fsync` on local `btrfs`/NVMe), `min_statepage_ctx_tokens=4096`, local grammar-gated `B2-b` virtualization (`16 KB`), `A2-Split`, `S3` capsules, and durable single-use nonce ledgers.
10+
- **Profile C (Cloud):** `durable=False` (`/dev/shm` restart/swap or dedicated local NVMe), StatePage hard-gated **OFF** below `32,768` tokens (`65,536` recommended for dense 8B) and hard-gated **OFF** on `overlayfs`, `B2-b` off on cached APIs, and stateless challenge-nonce verification.
11+
- **Scale inversion validated (`receipts/RUN-INDEX.md`):** Confirmed that KV StatePages cross breakeven cleanly at `>= 32K` tokens on both dense (`Llama-3.3-70B-AWQ`) and MoE (`Qwen3.5-35B-A3B-FP8`, `GLM-4.5-Air-AWQ`) models while staying sub-breakeven at short contexts (`<= 16K`) and on `overlayfs`.
12+
- **Native V4 vLLM Connector (`adapters/vllm/cowrie_kv_connector.py`):** Self-describing V4 layout with pinned-slab async staging, split durability policy, Profile E/C admission gates (`<32K` and `overlayfs`), and fail-closed `MambaSpec` handling until vLLM exposes exact recurrent-state slot layouts.
13+
- **S3 Semantic Capsules & A2-Split (`python/cowrie/__init__.py`):** Shipped `encode_s3_capsule` / `decode_s3_capsule` for cross-family big-chewer → small-worker knowledge handoff (`+16.7 pp` to `+100 pp` accuracy lift on small workers, `100%` `0x80` taint preservation) and `canonicalize_a2_split` for cache-friendly static/dynamic framing.
14+
15+
### Security Hardening (Finalized, 12/12 Attack Classes / 205/205 Refused)
16+
- **Capability Tokens V2 (`COWRIE_CAP_V2\0`):** Replaced blank-check V1 declassification tokens on all host paths (Rust `cowrie mcp-proxy`, Python `CowrieMemoryStore` & `CowrieToolGuard`, Node/WASM `CowrieMcpMediator`, ComfyUI, and Cloudflare Workers) with Ed25519 capability tokens bound to `target_cid`, `action`, `tool_name`, canonical `args_hash`, `destination`/audience, `session_id`, `issued_at`, short `expiry` (`<= 300 s`), and a single-use 16-byte `nonce`. V1 downgrades are unconditionally rejected.
17+
- **Durable & Stateless Replay Defense:** Added `CWNL0002` `0600` `O_NOFOLLOW` `fsync`'d `NonceLedger` (surviving process restarts and Durable Object evictions) and O(1)-memory `StatelessChallengeVerifier` (verifier-minted HMAC-bound single-use challenge nonces with immediate burn and epoch rotation).
18+
- **Fail-Closed C-ABI Pins:** `cowrie_statepage_open_strict`, `cowrie_statepage_open_full`, `cowrie_statepage_open_checked`, `cowrie_statepage_open`, and `cowrie_statepage_verify_bytes` now unconditionally reject NULL or empty `expected_model_sha`, `expected_doc_cid`, `expected_runtime_id`, and `verify_hash == 0` (`ERR_INVALID_CONTRACT`). Removed `COWRIE_ALLOW_UNSIGNED_OVERRIDE` env-var bypass; no environment variable can disable verification in a release build.
19+
- **Taint Below the 16 KB Floor:** Guaranteed `_meta.cowrie` (`cid`, `authority`, `tainted`, `virtualized`) and `BIT_TAINTED (0x80)` survive payloads under `16 KB`, `B2-b` virtualization, `cowrie_get` slices, `A2-Split` canonicalization, `S3` capsules, and omitted-parent `CowrieMemoryStore` summaries.
20+
- **Host Lineage, Secret-Path & Malicious Tool-List Defenses:** Hard-disabled caller-supplied `_cowrie_parents` trust overrides; tightened output classification to default-untrusted for unknown tools (e.g., `get_ticket`); blocked direct and symlink-resolved secret-path reads (`~/.ssh`, `.env`, `/proc/self/environ`, `/etc/shadow`, etc.) unless explicitly allow-listed; pinned MCP `tools/list` canonical hashes to reject mid-session rug-pulls and ignore deceptive server `readOnlyHint: true` annotations; logged every refusal to stderr and `.cwwal`.
21+
- **Honest Security Docs (`docs/SECURITY.md`):** Withdrew all "prompt-injection firewall" claims and documented exact cryptographic/container guarantees vs non-guarantees.
22+
23+
## [1.2.0] — 2026-11-28
24+
25+
- Initial `cowrie-ai` unified Rust/C-ABI/Python/WASM core (`COWR`, `CWRF`, `CWSP`, `CWIV`, `CWZM`, `.cwwal`), vLLM V1 `CowrieKVConnectorV1`, `llama.cpp` StatePages, Bend 2.0.35 + Lean 4 formal verification (`formal/`), and ecosystem connectors.

‎CITATION.cff‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
cff-version: 1.2.0
2+
title: "Cowrie: 16 KB-Aligned Content-Addressed AI Container, Verified KV StatePages, S3 Semantic Capsules, and Capability V2 Provenance Runtime"
3+
message: "If you use Cowrie, its wire specification, formal verification suite (Bend + Lean 4), or benchmark receipts in research or production, please cite it using this metadata."
4+
type: software
5+
authors:
6+
- family-names: Adeniran
7+
given-names: Femi
8+
affiliation: OmenWorks
9+
website: "https://femiadeniran.com"
10+
repository-code: "https://github.com/Neumenon/cowrie"
11+
url: "https://omenworks.dev"
12+
license: Apache-2.0
13+
version: "1.3.0"
14+
date-released: "2026-11-30"
15+
keywords:
16+
- canonical-serialization
17+
- ai-infrastructure
18+
- kv-cache
19+
- vllm
20+
- llama-cpp
21+
- mcp
22+
- provenance
23+
- capability-tokens
24+
- ed25519
25+
- formal-verification
26+
- lean4
27+
- merkle-tree
28+
abstract: >-
29+
Cowrie is a zero-dependency Rust/C-ABI/WebAssembly canonical binary container (COWR/CWRF),
30+
verified 16 KB-aligned inference state checkpoint format (CWSP StatePages split into Profile E
31+
Edge and Profile C Cloud), S3 semantic handoff capsule format, and Capability V2 (COWRIE_CAP_V2)
32+
provenance and offline audit runtime (cowrie verify-bundle), verified by 37 Bend laws, 40 Lean 4
33+
theorems, and a 753-case 4-oracle adversarial differential harness.

‎Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ members = [
33
"crates/cowrie-core",
44
"crates/cowrie-cli",
55
]
6+
exclude = ["fuzz"]
67
resolver = "2"
78

89
[workspace.package]
9-
version = "1.2.0"
10+
version = "1.3.0"
1011
edition = "2021"
1112
license = "Apache-2.0"
1213
repository = "https://github.com/Neumenon/cowrie"

‎MANIFEST.in‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
include README.md LICENSE Cargo.toml Cargo.lock pyproject.toml setup.py
1+
include README.md CHANGELOG.md LICENSE Cargo.toml Cargo.lock pyproject.toml setup.py
2+
include docs/SECURITY.md docs/PROFILES.md docs/QUICKSTART.md
23
recursive-include crates *.rs *.toml *.h
34
recursive-include python *.py
45
recursive-include adapters/vllm *.py

‎Makefile‎

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
CARGO_TARGET_DIR ?= /tmp/cowrie-cargo-target
2-
BUILD_DIR ?= /tmp/cowrie-build
3-
WHEEL_DIR ?= /tmp/cowrie-dist
4-
LLAMA_ROOT ?= /home/omen/prism-llama.cpp
1+
CARGO_TARGET_DIR ?= /tmp/cowrie-cargo-target
2+
HARNESS_TARGET_DIR ?= harness/cowrie-harness/target
3+
HARNESS_MANIFEST ?= harness/cases
4+
HARNESS_WITNESS ?= harness/witnesses.jsonl
5+
HARNESS_ORACLES ?=
6+
BUILD_DIR ?= /tmp/cowrie-build
7+
WHEEL_DIR ?= /tmp/cowrie-dist
8+
LLAMA_ROOT ?= /home/omen/prism-llama.cpp
9+
BUILD_PYTHON ?= $(shell python3 -c 'import setuptools, wheel' 2>/dev/null && echo python3 || echo /usr/bin/python3)
510

6-
.PHONY: build wasm formal formal-bend formal-lean test conformance connectors adversarial wheel adapter bench clean
11+
.PHONY: build wasm formal formal-bend formal-lean test conformance connectors adversarial adversarial-legacy abi-check wheel dist adapter bench clean
712

813
build:
914
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) cargo build --release
@@ -14,18 +19,42 @@ wasm:
1419
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) RUSTFLAGS="-C strip=symbols" cargo build -p cowrie-core --target wasm32-unknown-unknown --release
1520
node wasm/test_wasm.mjs
1621

17-
connectors: build wasm
22+
connectors: build wasm adversarial-legacy
1823
COWRIE_LIB_PATH=$(CARGO_TARGET_DIR)/release/libcowrie_core.so python3 tests/test_ecosystem_connectors.py
1924
COWRIE_LIB_PATH=$(CARGO_TARGET_DIR)/release/libcowrie_core.so python3 adapters/lancedb/cookbook_lancedb_mcp.py
2025
node adapters/cloudflare-workers/test_worker.mjs
2126

22-
adversarial: build wasm
27+
adversarial-legacy: build wasm
2328
COWRIE_LIB_PATH=$(CARGO_TARGET_DIR)/release/libcowrie_core.so python3 tests/test_adversarial_and_legacy.py
2429
node wasm/test_adversarial.mjs
2530

31+
kernel-build:
32+
bend formal/CowrieKernel.bend -o harness/kernel/cowrie_kernel_verified.mjs
33+
@sha256sum harness/kernel/cowrie_kernel_verified.mjs
34+
35+
kernel-verify:
36+
@python3 harness/kernel/verify_kernel.py
37+
38+
BEND_BIN ?= /home/omen/toolchains/bend-2.0.35/rel/bend/bin/bend
39+
40+
abi-check:
41+
python3 harness/check_err_codes.py
42+
43+
adversarial:
44+
CARGO_TARGET_DIR=$(HARNESS_TARGET_DIR) cargo build --release --manifest-path harness/cowrie-harness/Cargo.toml
45+
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(HARNESS_TARGET_DIR)/release/cowrie-harness \
46+
--manifest $(HARNESS_MANIFEST) \
47+
--witness-out $(HARNESS_WITNESS) \
48+
$(if $(HARNESS_ORACLES),--oracles $(HARNESS_ORACLES),)
49+
2650
wheel: build
2751
mkdir -p $(WHEEL_DIR) $(BUILD_DIR)/pybuild
28-
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) python3 setup.py egg_info --egg-base $(BUILD_DIR)/pybuild build --build-base $(BUILD_DIR)/pybuild bdist_wheel --dist-dir $(WHEEL_DIR) --bdist-dir $(BUILD_DIR)/bdist
52+
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(BUILD_PYTHON) setup.py egg_info --egg-base $(BUILD_DIR)/pybuild build --build-base $(BUILD_DIR)/pybuild bdist_wheel --dist-dir $(WHEEL_DIR) --bdist-dir $(BUILD_DIR)/bdist
53+
54+
dist: build
55+
rm -rf $(WHEEL_DIR) $(BUILD_DIR)/pybuild $(BUILD_DIR)/bdist
56+
mkdir -p $(WHEEL_DIR) $(BUILD_DIR)/pybuild
57+
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(BUILD_PYTHON) setup.py egg_info --egg-base $(BUILD_DIR)/pybuild sdist --dist-dir $(WHEEL_DIR) build --build-base $(BUILD_DIR)/pybuild bdist_wheel --dist-dir $(WHEEL_DIR) --bdist-dir $(BUILD_DIR)/bdist
2958

3059
formal-bend: build wasm
3160
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) COWRIE_LIB_PATH=$(CARGO_TARGET_DIR)/release/libcowrie_core.so python3 formal/verify_formal.py
@@ -65,3 +94,22 @@ bench: build
6594

6695
clean:
6796
rm -rf $(CARGO_TARGET_DIR) $(BUILD_DIR)
97+
98+
# Manual / nightly fuzz smoke (NOT in PR gate); default 300s per target.
99+
FUZZ_TIME ?= 300
100+
FUZZ_MAX_LEN ?= 65536
101+
FUZZ_RSS_MB ?= 512
102+
FUZZ_TARGETS ?= frame shard statepage ivf
103+
104+
.PHONY: fuzz-smoke
105+
fuzz-smoke:
106+
python3 fuzz/seed_corpus.py
107+
@set -e; for t in $(FUZZ_TARGETS); do \
108+
echo "=== FUZZ SMOKE: $$t (FUZZ_TIME=$(FUZZ_TIME)s, max_len=$(FUZZ_MAX_LEN)) ==="; \
109+
ASAN_OPTIONS="detect_odr_violation=0:quarantine_size_mb=16" \
110+
cargo +nightly fuzz run --fuzz-dir fuzz $$t fuzz/corpus/$$t -- \
111+
-max_total_time=$(FUZZ_TIME) \
112+
-max_len=$(FUZZ_MAX_LEN) \
113+
-rss_limit_mb=$(FUZZ_RSS_MB) \
114+
-timeout=2; \
115+
done

0 commit comments

Comments
 (0)