You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e06936b
Browse filesBrowse the repository at this point in the historyBrowse files
### 2.4 Hardening Bounds (Mandatory for All Compliant Decoders)
53
53
-**`MAX_DEPTH = 64`:** Any nested container at depth `> 64` MUST reject immediately with `ERR_MAX_DEPTH`.
54
+
-**`MAX_DECODED_BYTES = 64 MiB` & `MAX_KEY_LEN = 65,536`:** Both the binary `COWR` decoder and the RFC 8259 JSON parser MUST track cumulative decoded memory footprint (`MAX_DECODED_BYTES`) and per-key byte length (`MAX_KEY_LEN`), failing closed with `ERR_ALLOC_LIMIT` before OOM.
54
55
-**Zero-Allocation Wire Verification:**`verify_frame_zero_alloc` validates every canonical rule with zero heap allocations (`[u64; 4]` stack bitmask for `<= 256` keys).
55
56
-**Byte-Bounded Allocation:** Wire counts (`nkeys`, array length, map length, tensor dims) MUST be validated against remaining buffer bytes and arithmetic overflow before allocation (`ERR_ALLOC_LIMIT`).
-`runtime_id` (`[288..304)`, up to 16 ASCII bytes: `"llama.cpp"`, `"eureka-llm"`, `"eureka-creative"`, `"vllm-v1"`; when a caller specifies a non-empty `expected_runtime_id`, an empty or mismatched file `runtime_id` MUST fail closed with `ERR_RUNTIME_MISMATCH`) + `layout_ver: u16` (`[304..306)`)
-`hash_mode` (`0 = flat SHA-256`, `1 = parallel 4 MiB chunked RFC 6962 Merkle SHA-256` over bounded `WorkerPool`, accelerated by x86_64 `SHA-NI` and ARMv8 `SHA2`)
101
102
- Optional **RFC 2104 HMAC-SHA256** tag (`[308..340)`, `hmac_flag = 1` at `page0[75]` when `COWRIE_HMAC_KEY` is configured)
102
103
-**HMAC Error Precedence:** When `hmac_flag == 1` (or caller provides an HMAC key), RFC 2104 `HMAC-SHA256` verification over Page-0 `[0..308)` MUST execute on a stack-snapshotted copy BEFORE semantic header parsing (`ERR_AUTH_MAC_MISMATCH` precedes `ERR_INVALID_CONTRACT` / `ERR_MODEL_MISMATCH`).
104
+
-**Fail-Closed C-ABI Pins (`v1.3`):**`cowrie_statepage_open_strict` and `cowrie_statepage_verify_bytes` require non-empty `expected_model_sha`, `expected_doc_cid`, and `expected_runtime_id`, and reject `verify_hash == 0` with `ERR_INVALID_CONTRACT` (legacy unpinned `cowrie_statepage_open*` wrappers fail closed with `ERR_INVALID_CONTRACT`). For scheduler prefix-match lookups that do not read KV tensor payload bytes, `cowrie_statepage_probe_header` performs an O(1) read-only verification of Page 0 + 94-byte EOF trailer + HMAC + pins via `pread` without mapping payload bytes; full payload Merkle verification runs unconditionally once on worker load (`cowrie_statepage_open_strict`).
103
105
- Supports both zero-copy `mmap` (`MappedStatePage`) and 16 KB-aligned `O_DIRECT` into double-buffered `cudaHostAlloc` pinned memory overlapped with dual-stream `cudaMemcpyAsync`.
104
106
105
107
### 3.4 Plane C Profile B — Co-Located 16 KB IVF-INT8 Index (`CWIV`, `flags & 0x02`) & `LiveIvfStore`
@@ -133,7 +135,7 @@ Lenses are pure functions of `Plane A` (zero model calls); any `tier > 3` fails
@@ -143,16 +145,39 @@ Lenses are pure functions of `Plane A` (zero model calls); any `tier > 3` fails
143
145
|`0x08`|`MODEL_SYNTH`| Model-synthesized summary or derived claim |
144
146
|`0x80`|`BIT_TAINTED`| Sticky transitive taint flag: set automatically on any frame derived from any parent having `(auth & (0x04 | 0x80)) != 0` |
145
147
146
-
-**Fail-Closed Privileged Gates:**`shell_exec`, `cred_read`, `net_exfil`, and `fs_write` fail closed (`ERR_TAINTED_EXECUTION_BLOCKED`) on tainted, unknown, empty, or colliding argument IDs.
147
-
-**Scoped Asymmetric Declassification (`COWRIE_DECLASSIFY_V1`, `v1.2`):** Pure-Rust RFC 8032 `Ed25519` signatures over `"COWRIE_DECLASSIFY_V1\0" || target_cid_34 || action_u8 || expiry_u64_le` (`64 B` message, strict `S < L` and canonical curve-point verification) allow an operator's public key to approve one specific reviewed 34-byte CID for one specific `ToolAction` before `expiry_unix_secs` without sharing symmetric keys or approving any other tainted CID in context.
148
-
-**Transparent MCP Wire Firewall (`cowrie mcp-proxy`, `v1.2`):** Wraps unmodified stdio JSON-RPC MCP servers, logging tool responses into `.cwwal`, sealing external fetch/search/browser/email results as `0x04 UNTRUSTED_EXT`, and blocking tainted privileged `tools/call` messages at the wire (`-32025 ERR_TAINTED_EXECUTION_BLOCKED`) unless covered by valid `Ed25519``_cowrie_declassify` tokens.
148
+
-**Fail-Closed Privileged Gates:**`shell_exec`, `cred_read`, `net_exfil`, and `fs_write` fail closed (`ERR_TAINTED_EXECUTION_BLOCKED`) on tainted, unknown, empty, or colliding argument IDs. Secret-path access (`~/.ssh`, `/etc/shadow`, cloud credentials, `.env`, `.git/hooks`, etc.) is refused fail-closed even on untainted sessions unless explicitly allowlisted, after RFC 8089 `file://localhost/` decoding, interior quote/backslash normalization, and deepest-existing-ancestor symlink resolution.
149
+
-**Single-Use Scoped Capability Tokens (`COWRIE_CAP_V2`, `v1.3`):** Pure-Rust RFC 8032 `Ed25519` (strict `S < L`, canonical `y < p`, and small-order Curve25519 torsion rejection on both `pubkey` and `R`) over the length-prefixed preimage:
Fields `tool_name`, `destination`, and `session_id` MUST be non-empty and `<= 1024` bytes (`MAX_CAP_FIELD_LEN`); `expiry > issued_at`; `expiry - issued_at <= max_ttl_secs` (`DEFAULT_MAX_CAP_TTL_SECS = 300`); `issued_at <= now + MAX_CLOCK_SKEW_SECS` (`30s`); and `now <= expiry`.
163
+
-**Session Taint Snapshot Root (`COWRIE_TAINT_SET_V1`, `v1.3`):** To prevent signature explosion on multi-read tainted sessions without weakening taint binding, a single `COWRIE_CAP_V2` token MAY bind to the exact deduplicated set of active tainted CIDs via `target_cid = 0x53 0x20 || SHA-256("COWRIE_TAINT_SET_V1\0" || sorted_unique_cids)` (distinct `0x53 0x20` prefix prevents cross-type collision with `0x12 0x20` frame CIDs; JSON tokens may supply `"session_taint_root": "<64-hex>"` or the 68-hex `target_cid`). Per-CID `0x12 0x20` tokens covering all deduplicated tainted CIDs remain accepted for backward compatibility.
164
+
-**Mandatory V1 Downgrade Rejection (`v1_downgrade_rejected`):** Legacy `COWRIE_DECLASSIFY_V1\0` tokens lack tool/args/destination/session/nonce binding and MUST be rejected fail-closed (`ERR_AUTH_MAC_MISMATCH`) by all v1.3 enforcement gates (`mcp-proxy`, `CowrieToolGuard`, `EvidenceBundle`). Legacy `cowrie_declassify_*` symbols are retained strictly for ABI compatibility and regression testing.
165
+
-**Durable Single-Use Nonce Ledger (`CWNL0002`, `v1.3`):** Replay protection across restarts uses an `O_NOFOLLOW`, `0600`, `fsync`'d binary journal starting with 8-byte magic `"CWNL0002"` followed by fixed 24-byte records `nonce[16] || expiry_u64_le[8]` (legacy 16-byte `CWNL0001` logs are rejected fail-closed). Entries satisfying `expiry + MAX_CLOCK_SKEW_SECS < now` are pruned on load and periodically on `consume`, with crash-safe atomic `O_CREAT|O_EXCL 0600` temp-file + `sync_all` + `rename` compaction.
166
+
-**Stateless Challenge-Response Verifier (`StatelessChallengeVerifier`, `COWRIE_CHAL_V2\0`):** For zero-disk or serverless deployments (e.g. edge workers), the verifier mints an ephemeral single-use challenge nonce `nonce = HMAC-SHA256(secret, "COWRIE_CHAL_V2\0" || epoch_u64_le || issued_at_u64_le || expiry_u64_le || tool_name || args_hash || destination || session_id)[..16]`, stores one active slot, and unconditionally burns the slot and increments `epoch` on `verify_and_consume`, eliminating replay without a persistent nonce file.
0 commit comments