Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/synapse/blob/main/docs/THREAT_MODEL.md # synapse A component of the AienOS ecosystem. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `synapse / docs / THREAT_MODEL.md` 41 lines ยท 7160 bytes Raw Blame History Source # Synapse Threat Model and Capability Enforcement Contract Tracking Issue: aien-spark/aien-sovereign-core#515 ## 1. Trust Boundaries - Agent Client Boundary: Autonomous builder, reviewer, verifier, and benchmark agents are untrusted callers until authenticated by an Ed25519 signature over the canonical request/changeset payload and authorized by an unexpired, repository-scoped `AgentCapabilityGrant`. - Storage Engine Boundary (`synapse-store`): The single-writer WAL and content-addressed blob store treat disk files and incoming payloads as potentially corrupted or adversarial. Every blob digest and WAL frame CRC32C + SHA-256 chain link is recomputed and verified on ingest and recovery. - Human Forge Projection Boundary (`synapse-git` / GitHub): GitHub pull requests and review comments are human-facing projections. A merged GitHub pull request or remote branch update is never trusted as proof of canonical promotion unless accompanied by verified Radicle delegate threshold signatures. - Canonical Authority Boundary (`synapse-radicle`): Only a `RadicleCanonicalHead` receipt backed by a verified `refs/rad/id` identity document (`xyz.radicle.project`) and at least `threshold` valid Ed25519 signatures over `refs/namespaces//refs/rad/sigrefs` for the target `GitOid` can mark a lineage as canonical. ## 2. Capability Permission Matrix Each `AgentCapabilityGrant` is signed by a repository authority Ed25519 key and binds `(repo_id, agent_did, capabilities, max_bytes_per_op, max_ops_per_window, issued_at_ms, expires_at_ms, grant_nonce)`. Operation Required Capability Additional Invariants Checked Refusal Code on Violation `get`, `tree`, `diff`, `history`, `provenance`, `conflicts`, `status`, `watch` `Read` `grant.repo_id == request.repo_id`, `now_ms <= grant.expires_at_ms`, changeset lookups (including ancestors and explicit conflict IDs) belong to the authorized repository, `page_size <= max_page_size` `AuthCapabilityDenied`, `AuthCrossRepoDenied`, `ChangesetNotFound`, `AuthGrantExpired`, `PaginationLimitExceeded` `submit` (propose changeset) `Propose` Valid agent Ed25519 signature over `ChangesetEnvelope`, payload within `max_bytes_per_op`, rate quota available, base tree known `AuthSignatureInvalid`, `AuthCapabilityDenied`, `QuotaPayloadTooLarge`, `QuotaRateLimitExceeded` `attach_evaluation` (test/benchmark receipt) `Evaluate` Target `ChangesetId` exists in `repo_id`, signed evaluation receipt digest valid, single-use request nonce not replayed `AuthCapabilityDenied`, `AuthReplayDetected`, `ChangesetNotFound` `record_review` (review verdict) `Review` Reviewer `agent_did != changeset.author_did` (no self-approval), valid signature, non-replayed nonce `AuthCapabilityDenied`, `AuthSelfReviewRefused`, `AuthReplayDetected` `project_git` / `promote_canonical` `Publish` For canonical promotion: verified `RadicleCanonicalHead` (`refs/rad/id` + `sigrefs` quorum >= `threshold`) and `base_git_oid == current_canonical_head` `AuthCapabilityDenied`, `RadicleQuorumInsufficient`, `RadicleSignatureInvalid`, `StaleBaseHead`, `SplitBrainDivergence` ## 3. Adversarial Threat Catalog and Mitigations Threat ID Adversarial Scenario Mitigation and Deterministic Refusal T1: Forged Agent Identity Attacker submits a changeset claiming `author_did = did:key:z6Mk...` with a forged or mismatched Ed25519 signature. `synapse-auth` extracts the 32-byte Ed25519 public key directly from `did:key:z6Mk...` (multicodec `0xed01`) and verifies the 64-byte signature over the domain-separated canonical envelope before any store admission. Refuses with `AuthSignatureInvalid`. T2: Cross-Repository Token or Object Reuse Agent holding a valid `Read`, `Propose` or `Publish` grant for `repo-A` requests a known `repo-B` changeset ID from a mixed store, or targets `repo-B` directly. Grants and requests are bound to `RepoId` (`AuthCrossRepoDenied`), and repository-scoped lookups refuse a foreign changeset as `ChangesetNotFound`, including provenance, virtual-tree ancestry, explicit conflict IDs and GitHub PR projection. Own-repository snapshot visibility errors retain their established diagnostic; foreign IDs never reveal their commit sequence. T3: Expired or Replayed Mutation Attacker replays a captured mutation token or uses an expired `AgentCapabilityGrant`. Grants enforce `now_ms <= expires_at_ms` (`AuthGrantExpired`). Mutation requests carry a monotonic or unique `request_nonce` tracked per `(repo_id, agent_did)` window; duplicates fail closed with `AuthReplayDetected`. T4: Unbounded Memory / Disk Exhaustion Flood of large blobs, deep directory trees, uncollected speculative changesets, or unauthenticated wire submissions. Blob, path, pending-operation and page limits apply. The audit log retains at most 4,096 decisions; when full, new authorization fails with `BackpressureOverCapacity` before signature verification or nonce/quota mutation. The wire server closes a connection after 64 refusals or on audit exhaustion. This is backpressure, not an audit drain: without an operator-provided durable export/restart, the enforcer remains closed to new decisions. T5: Split-Brain CanonicalSpoofing GitHub PR is merged or fast ingest `WalSeq` advances, and an agent attempts to mark the changeset canonical without Radicle delegate quorum. `synapse-radicle` refuses canonical promotion unless `refs/rad/id` and `refs/namespaces//refs/rad/sigrefs` verify at least `threshold` distinct delegate signatures on the target `GitOid` (`RadicleQuorumInsufficient`, `SplitBrainDivergence`). T6: Crash or Torn Write Corruption Process dies mid-blob write or mid-WAL frame append. Blobs are written and synced before the WAL frame is appended. Recovery verifies `SWAL` header magic, sequence continuity, CRC32C, and `prev_frame_sha256` hash chain; uncommitted blobs remain unindexed and torn tail frames are refused/quarantined without phantom visibility. ## 4. Tamper-Evident Security Audit Log Every decision actually evaluated by `PolicyEnforcer::authorize` or `authorize_chain` appends a hash-chained `AuditEntry` (admitted or refused) containing sequence, time, repository, actor, capability, operation, outcome and previous/current SHA-256 hashes. The log is in memory; it is not independently signed or automatically persisted. `AuditLog::verify_chain()` detects a changed entry or broken chain within the retained log. Entries retain at most 1,024 bytes per attacker-controlled string field; longer fields are replaced explicitly by their original byte length and SHA-256 digest, not silently truncated. At the fixed 4,096-entry capacity, authorization refuses before evaluating the next request; that backpressure refusal cannot itself be appended without exceeding the cap. Operators must durably preserve and inspect the full log before starting a fresh enforcer; discarding it is audit loss, not successful draining.