interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

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

  1. 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.
  2. 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.
  3. 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.
  4. 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/<nid>/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).

OperationRequired CapabilityAdditional Invariants CheckedRefusal Code on Violation
get, tree, diff, history, provenance, conflicts, status, watchReadgrant.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_sizeAuthCapabilityDenied, AuthCrossRepoDenied, ChangesetNotFound, AuthGrantExpired, PaginationLimitExceeded
submit (propose changeset)ProposeValid agent Ed25519 signature over ChangesetEnvelope, payload within max_bytes_per_op, rate quota available, base tree knownAuthSignatureInvalid, AuthCapabilityDenied, QuotaPayloadTooLarge, QuotaRateLimitExceeded
attach_evaluation (test/benchmark receipt)EvaluateTarget ChangesetId exists in repo_id, signed evaluation receipt digest valid, single-use request nonce not replayedAuthCapabilityDenied, AuthReplayDetected, ChangesetNotFound
record_review (review verdict)ReviewReviewer agent_did != changeset.author_did (no self-approval), valid signature, non-replayed nonceAuthCapabilityDenied, AuthSelfReviewRefused, AuthReplayDetected
project_git / promote_canonicalPublishFor canonical promotion: verified RadicleCanonicalHead (refs/rad/id + sigrefs quorum >= threshold) and base_git_oid == current_canonical_headAuthCapabilityDenied, RadicleQuorumInsufficient, RadicleSignatureInvalid, StaleBaseHead, SplitBrainDivergence

3. Adversarial Threat Catalog and Mitigations

Threat IDAdversarial ScenarioMitigation and Deterministic Refusal
T1: Forged Agent IdentityAttacker 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 ReuseAgent 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 MutationAttacker 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 ExhaustionFlood 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 CanonicalSpoofingGitHub 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/<nid>/refs/rad/sigrefs verify at least threshold distinct delegate signatures on the target GitOid (RadicleQuorumInsufficient, SplitBrainDivergence).
T6: Crash or Torn Write CorruptionProcess 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.