# Proposed security controls Controls an agent thinks are needed. None is implemented until the owner approves it. See AGENTS.md, "Security controls: propose, never implement". ## Proposed ### Release downloads: `SHA256SUMS` from the same bucket as the binary - What: sign the `SHA256SUMS` of a release (a detached signature by a key published out of band, or a record in the owner's repo), and have `docs/bidder.md` verify it. - Where: `docs/bidder.md` "Binary" (rc and main builds verify against the `SHA256SUMS` fetched from the same bucket directory); `README.md` pins the hashes inline for one rc. - Threat: whoever can write the bucket replaces the binary and its `SHA256SUMS` together; the check then proves nothing. The operator runs the binary as root (`install bidder`). ### The staging module: an `oci:` requester spec with a shell metacharacter - What: `prefix()` in `tests/modules/staging/src/lib.rs` could refuse an `oci:@sha256:` spec whose reference contains a single quote, a space or a semicolon. An agent added it without approval; it is removed. - Where: the staging module puts the reference into the root shell command it runs on each staging VM (`oras pull `). - Threat: a hostile spec (a target file, a fork's workflow input) could end the command and run another as root on the VM. Today the spec is written by `scripts/ci-staging-binary.sh` from `oci-push.sh` output; the VMs are rented for the run and a fork's are its own. - Proposal: quote the reference as one shell word instead of refusing it. ### The bidder: `--cpu-overcommit` below 1 - What: `run bidder`, `install bidder` and `dev up` could refuse `--cpu-overcommit` below 1 (and a MarketBidder `spec.cpuOvercommit` below 0). Not implemented: 0 means the default 2, and a negative value commits no vCPUs, so the bidder bids on nothing. - Where: `vmLimits` in `internal/market/bidder/vmsize.go`. - Threat: an operator typo takes its own bidder out of the market. There is no upper bound either: a large ratio lets one host commit far more vCPUs than it has cores, which is the operator's choice. - Proposal: refuse a negative ratio when the bidder starts, and say in `check-host` the ratio the bidder commits. ### A network PDS: pin a network name's address - What: when a network PDS fetches OAuth client metadata or a `jwks_uri` from a name under its network's domain, refuse a connection whose resolved address is not one the network value names (its `dns`, `xrpcFront` and `hosts` addresses). Not implemented: today the name alone decides (the network's domain, resolved by the host's resolver, TLS by the system roots plus the network CA). - Where: `internal/atproto/oauth/client.go` `httpClientFor`, `internal/services/pds/service.go` `oauthNetwork`. - Threat: whoever can answer DNS for a name under the network's domain on the PDS's host (a network whose domain is a public one, a poisoned resolver) points a client_id at any private address the PDS's host reaches; the PDS then GETs it (no redirect followed; the answer must be TLS under a trusted root and JSON client metadata to be used). - Proposal: a dial control on the network client that accepts only those addresses. ### A policy input that cannot be read - What: fail closed when a record the policy run names (`rfp`, `bid`, `accept`) cannot be read: `recordInput` (`internal/policyengine/controller/run.go:221-235`) drops the read error and hands the action `{uri, cid}` without `value`; `bid-payload` (`internal/policyengine/bundled-actions/tangy/policy-bid-payload`, `createBidPayloadFilterPolicy`) then answers `allow: true` when no offer is present. `requester-tangled-vouch` and the other trust policies never read the bid's value. - Where: those two places; the requester's winner run (`runner.go` the `winnerPolicy` step) passes the bid by strongRef. - Threat: a bid whose record the policy engine cannot read (gone, another version, a route that answers 404) passes a payload policy it would have failed. ### An invalid receipt leaves the bidder's VM running - What: when a receipt fails its check (`acceptReceipt` in `internal/market/requester/runner.go`: Failed `receiptInvalid`), send the bidder a release for the receipt read from its repo at the deterministic rkey (`market.ReceiptRKey`), not for the invalid one; today no release is sent (main does the same) and the VM runs until the bidder's own lease ends. Not one call on an existing path: `releaseContract` names `state.Receipt`, the invalid receipt, which the bidder refuses ("the inbound event names another receipt", seen 2026-11-20 in run a2-main). - Where: `acceptReceipt` and `releaseContract` in `internal/market/requester/runner.go`. - Threat: a forged or broken receipt costs the bidder a running guest for up to its lease (24 h by default). ### The bidder's check of a requester's signing key - What: give the bidder's `participant.Verifier` (`internal/market/participant/comms.go`) the verified binding the requester uses (`identlink.Remote.GetVerifiedRecord`), not a plain getRecord of the requester's `badgeBlueKeys`. - Where: `Verifier.BadgeBlueBinding`, used for the RFP and accept checks of `internal/market/bidder`. - Threat: a requester whose PDS is behind a route (a guest requester, a did:key ingress) gets an RFP or accept forged by whoever controls the route. ### Guest secrets: getSecrets plaintext at the did:key ingress relay - What: seal the getSecrets answer end to end to a key the guest makes at boot (it sends an age recipient with the request; the requester answers ciphertext), or serve getSecrets only on an ingress whose TLS ends at the requester. Not implemented. - Where: `secretsState.fetch` (`internal/market/requester/secrets.go`), setup-secrets (`internal/atproto/cloudinit/modules.go`); the guest's `SECRETS_URL` is the requester's ingress Exposure, on prod `https://did-key-.xrpc.fedproxy.com`, whose TLS ends at the relay host's Caddy; the Go relay (`internal/atproto/ingress`) carries the answer to the requester's websocket as a JSON body. - Threat: whoever runs or breaks into the relay host (xrpc.fedproxy.com) reads every bundle served on the direct path, in clear, and can answer a guest itself. The relay is ours, but it is a third party to each requester and bidder. ### Guest secrets: bind the peer channel to the guest's own iroh id - What: accept a getSecrets request over iroh only from the guest's iroh endpoint id (`status.contract.vmAddress`), or over WebRTC only with the guest agent's DTLS fingerprint (`vm.onNetwork` kind webrtc). Not implemented (owner, 2026-11-20: a proposal only; the workload identity token check is the authentication). - Where: the requester's iroh Exposure (`svc-requester--iroh`, `ingress/iroh`: `dumbpipe listen-tcp` reports no peer id) and its guest WebRTC ingress (`ingress/webrtc.Service.Accept` checks no fingerprint). - Threat: anyone holding the guest's workload identity token (the bidder, which issues it) can fetch over any channel; the binding would add nothing against the bidder and would refuse a guest whose key changed at a reboot. - Status: after roll two (owner, decision 69, 2026-11-20: the requester's ticket stays public, as the bidders' are). What it needs: a listener that reads the dialer's id (dumbpipe `listen-tcp` cannot; socialweb-meshd's `conn.remote_id()` check is the model, or a branch of the owner's dumbpipe fork with an id allowlist reloaded per contract), and a guest that dials with its own key (the agent's `dumbpipe connect` runs without `IROH_SECRET`, so its id is random per connection); about 2 to 3 days. ### Guest secrets: the bidder vouches for the guest's sealing key - What: none proposed without a guest attestation. The requester seals to the latest `guest.publicKey` tag `secrets` of the contract (`latestGuestSecretsKey`, `internal/market/requester/guestsecrets.go`), a record the bidder signs and publishes for the guest; a bidder can publish its own key and open the bundle. - Where: the sealed path (comms mode Firehose with `secretsFallback: Sealed`). - Threat: a malicious bidder reads the secrets. This is the trust model of the direct path too: the bidder runs the guest's workload identity issuer (it can mint a token with the guest's `sub` and fetch getSecrets itself) and runs the VM. The sealed path adds no reader beyond the bidder; it adds the ciphertext on the public protocol (relays, Jetstreams, archives) after the requester deletes the record at release, age X25519 (not post quantum) to be broken later. - Proposal: if the owner wants the published ciphertext to outlive a future break, seal to a hybrid post-quantum recipient (age's ML-KEM-768 + X25519) as well. ### GuestControlPlane: the unpinned-download warning is triggerable by anyone who reaches the route - What: rate-limit `pinned_download_not_pinned` (for example one line per name and sha256 per minute, with a count). Not implemented. - Where: `internal/kit/pinneddownloads/pinneddownloads.go` `ServeHTTP` (`GET /v1/downloads/{sha256}/{name}`, unauthenticated; the gateway's downloads route uses the same handler). - Threat: a guest or any peer that reaches the route asks for random sha256s and fills the bidder's journal with WARN lines (disk, log noise that hides real failures). ### The requester: release a Held contract after N minutes without a policy verdict - What: when the recorded-winner recheck (resume after a restart, adopt, a resubmitted accept) gives no verdict for N minutes (a run that does not complete: deadline, cancel, sandbox down, no PolicyEngine, a deny while trust lookups failed), treat it as a deny and release the contract. Not implemented: the owner-approved design (commit eca9f345, `docs/spec/integration-catalog.yaml` TestRequesterPolicyRelease) is that a run that does not complete fails the step without releasing, so an engine restart does not drop held VMs; `untilSettled` retries it for `TransientResumeGiveUp` (2 min) and then the step fails with the last error, the VM still held. - Where: `internal/market/requester/runner.go` `resumeAccepted`, `resumeReceipt`, `adopt` (`recordedWinnerAllowed`). - Threat: a winner whose trust was really withdrawn (vouch deleted) while its reads fail (its PDS or the voucher's PDS down, or answering 5xx on purpose) keeps the requester's VM and its secrets until a recheck completes (the next requester restart) or the contract is released or expires. The trade-off: with the release, any PolicyEngine or PDS outage longer than N minutes releases every held VM of the requester. - Proposal: keep the design; if the owner wants the bound, release after N minutes only when the run that gave no verdict had unconfirmed trust lookups (a deny with the reads failing), never for an engine, sandbox or deadline failure. ### The bidder: end an admitted accept that has no receipt after N minutes - What: a bidder ends (Obsolete, its capacity hold released) an accept it admitted (answered 202, or took from the firehose) that still has no receipt N minutes after its admission (N about the requester's `ReceiptTimeout`, 5 min by default; the old in-memory hold was 10 min). Not implemented. - Where: the provision StateSync of the accept (`internal/market/bidder/vmsize.go` `admitAccept`, `openHolds`): today its hold counts until the sync ends Rejected or Obsolete, settles, or its bid is over (released, failed, expired: the bid TTL, 24 h). No capacity check runs after admission, so a hold never lapses on its own. - Threat: an admitted accept whose attempts keep failing retryably before the receipt (the bidder's own PDS refuses the receipt write, the policy engine is down, a requester PDS stops answering after the 202) holds its room up to 24 h; the requester stopped waiting after its `ReceiptTimeout` and failed the contract. A requester that is the bid's `spec.requester` can make this happen on purpose only by making its own records unreadable after the 202 (an unreadable accept is abandoned at 3 to 5 min by `unresolvedAccept`; an unreadable RFP or payload is retried). - Trade-off: ending it is a timeout that cuts off the counterparty: an accept the requester still waits for (a longer `ReceiptTimeout`, a slow PDS) would lose its room and its receipt would never come. Keeping it costs room for at most the bid TTL, only while the bidder itself cannot finish the accept. ### The bidder: no single bidder process per state (pre-existing, not built) - What: a lease (or an flock on the bidder's state dir) so that only one bidder process admits accepts for one bidder. - Where: `internal/market/bidder` admission (`admitAccept` under `admitMu`, in memory per process). - Threat: two processes of one bidder each admit into the same room (their overlays and refusal maps are their own; the StateSync index catches up within the informer's lag). On a self-update this cannot happen: the update restarts `socialweb-computer-bidder@.service` (`install.RestartOwnUnits`), and systemd stops the whole control group (`KillMode=control-group`; SIGTERM, then SIGKILL after `TimeoutStopSec`, default 90 s) before it starts the new process, so the overlap is zero. It needs a second process started by hand on the same state (a `run bidder` beside the unit, or a `dev restart` racing another), which nothing prevents today. ### The bidder: a Releasing or deleted ComputeVM counts nothing against MemTotal (pre-existing, not built) - What: count a VM's committed memory against MemTotal until its VMM process has exited, not only while it is live. - Where: `internal/market/bidder/vmsize.go` `committed` (`liveGuest` excludes Releasing and deleted VMs). - Threat: during a release (seconds) a new guest's MemTotal check ignores memory the old VMM still holds. The MemAvailable check covers it (the old VMM's pages are charged and MemAvailable is lower until they are freed), so the exposure is only the MemTotal sum on a host whose MemAvailable is close to MemTotal. ## Approved by the owner and built ### The requester reads each bid from the bidder's own repo (approved and built 2026-11-20) - Owner: "The requester takes bids from a bidder's answer as given: fetch each bid from the bidder's own repo." - What: the submitRfp answer is never read for a bid (`bidsFromReply` is gone; the lexicon's answer has none and no bidder sent one). Of a submitBid the requester takes `uri` and `cid` only: the service-auth issuer must be the bid URI's authority (as before), the bid is read by `uri` and `cid` from that repo and only those bytes are used (400 when they do not hash to `cid`, 503 while unreadable: the bidder retries). The winning bid's `config` (`compute.config.wif.simple`, the token issuer of its guest's secrets) must be a record in that same repo, read by its strongRef (an owner question on this refusal is open). Bids from the streams and the catch-up read were already read from the bidder's repo. Not checked: that the bid's DID was one the RFP was sent to. - Where: `SubmitRFP` in `internal/market/requester/market.go`, `SubmitBid` in `internal/market/requester/callbacks.go`, `resolveBidConfig` in `internal/market/requester/secrets.go`. ### Every bid and receipt is signed by a key bound to the bidder (approved and built 2026-11-20, decision 71) - Owner: asked "verify the signature on every bid before it is queued, and prove the key-binding record is really in the bidder's repo by verifying the repo's signed commit against the DID document's key (the same check the vouch walk already does)", answered "Bids and receipts, in the batch". - What: before a bid is queued, by `SubmitBid` or by the bid mailbox (the streams and the catch-up read feed it), one check (`verifyBid`): an inline signature must verify and its key must be a key of the DID document of the repo that holds the bid, or bound by that repo's `badgeBlueKeys` record read with `com.atproto.sync.getRecord` and taken only when the CAR, the MST path and the commit signed by the DID document's atproto key check out (`identlink.Remote.GetVerifiedRecord`; the DID document from the PLC directory, never through the route). A signature entry whose `issuer` names another DID counts for nothing. A refusal answers 403 (`requester_bid_refused`); a failed lookup is an error, never "not bound" (SubmitBid answers 503, the mailbox tries again every 2 s and leaves the bid out after 2 min, `requester_bid_verify_gave_up`: a PLC or PDS outage fails closed). Receipts (`VerifyReceipt`) get the same rule; before, any key named inside the receipt's signature entry verified. Guest events use the same verified binding. A bound answer is kept 5 min; "not bound" and a failed lookup are never kept. The catch-up read checks the bid's bytes against the cid its server reported. The bidder offers and bids only once its binding is written and read back (retried with backoff). - Where: `internal/market/requester/keybinding.go`, `verifyBid` and `verifyOptions` in `events.go`, `SubmitBid` in `callbacks.go`, `processBidMailbox` in `inbox.go`, `verifyReceipt` in `runner.go`; `CheckRecordSignatures` in `internal/atproto/market/attest.go`, `VerifyReceipt` in `contract.go`; `GetVerifiedRecord` in `internal/identlink/remote.go`. - Threat it stops: a route in front of a bidder's PDS or market endpoint (every prod bidder today) forging a bid, its payload, its config (bound to the signed bid by cid) or a receipt. What it leaves: "The bidder's check of a requester's signing key", "A policy input that cannot be read", "An invalid receipt leaves the bidder's VM running". Upstream by design, not ours to close: a route can replay an older signed commit; TLS ends at the relay; `badgeBlueKeys` is unsigned and has no purpose separation (`service`); offerings are unsigned; no solicitation check. ### Record reads by strongRef check the bytes against the content id (approved and built 2026-11-20) - Owner: "Record reads trust the content id the server reports: check the bytes against the id asked for." - What: where a record is read with a known content id, the record value is decoded with exact integers (int64), encoded as dag-cbor (indigo `atdata`, the encoder our PDS writes with), hashed (CIDv1, dag-cbor, sha2-256) and compared with that id. Per site: `HTTPReader.Resolve`, `RepoStore.Resolve` and `remote.Repo.Resolve` fail hard (`recordcid.ErrMismatch`) unless the bytes hash to the id the server reports instead, which is another version and answers not found (before, the market readers took any version); `pdsclient.GetRecord` with an expected cid and the stream sink's relay fallback deliver another version under its own cid (as main did) and fail hard otherwise (the stream sink then neither falls back to another source nor fetches that `uri|cid` again within 15 s); the policy engine compares the cid its verified repo tree holds and answers another version as not found. The caller's own retry rules apply to not found; a mismatch is not retried. A read by URI alone (the latest version) has no id to check. - Where: `internal/atproto/recordcid`; `internal/atproto/market` (`http.go`, `repostore.go`), `internal/atprotorepo/remote`, `internal/atproto/pdsclient`, `internal/eventstream/market.go`, `Resolver.Resolve` in `internal/policyengine/trust`. - Proof the encoder agrees with the PDSes (2026-11-20, `hack/recordcheck`): see plan 0054 Proof for the counts. ### Ingress relay: a registration is bound to its key and to the token's issuer (approved and built 2026-11-19) - Owner: "only a signature by the key being registered counts, and the token issuer must equal it". - What: `getRegistrationNonce` answers 403 `IssuerMismatch` unless the service-auth `iss` equals the `key` asked for; `subscribe` answers 403 `IssuerMismatch` before the upgrade unless the `iss` equals the `did` param; the registration counts only signatures whose `key` is the registration's `key` (`no signature by the registered key`). A newer subscription of the same key still takes the route, and the relay now closes the replaced socket with 4009. - Where: `internal/atproto/ingress/nonce.go` `Verify`, `signaturesBy`, `verifySignatures`; `internal/atproto/ingress/server.go` `handleNonce`, `handleSubscribe`, `denyIssuer`. - Threat it stops: anyone who reaches the relay self-signs a token with a fresh did:key, asks a nonce for another DID, signs it with its own key and subscribes as that DID: it got that DID's host (`