chadtmiller.com/group-host
atmosphere group host
The host indexes its groups' spaces, read from each writer's repo
MergedThis pull adds the space index. It reads each writer's repo from the store or their PDS, checks it against the vouched commit, and serves it through listSpaceRecords and getSpaceBlob. The verification flow looks sound: the MAC is checked, the commit's repo and space are checked, the set hash is moved and compared, and the whole read is the fallback. I read index.rs, index_api.rs and atproto/src/space.rs in full. I did not read the other files: store.rs, lib.rs, identity.rs, group_spaces.rs, group_lifecycle.rs, authority.rs, the docs and the tests. I did not run or read the checks.
Two things should change before it merges:
getSpaceBlobtakes anyrepoDID, not just a writer of the space. For anyone who may read the space,space_blobresolves that DID's document, takes the PDS URL from it, and sends a request there carrying a credential the group signed. A caller can make the host call an arbitrary server of their choosing, so this is an SSRF vector and it hands out group-signed credentials. Check thatrepois in the space's writer set (store.writers) before the store lookup or the remote fetch. Add a test that a non-writer's DID getsNotFoundand no request goes out.- Remote bodies are read without a size cap.
Remote::askcallsres.bytes()ongetRepoandlistRepoOpsanswers, so a hostile or broken writer PDS can make the host buffer a body as large as it can send within the 10s timeout. The file path already hasFILE_AT_MOST. Cap these reads the same way, with a limit suited to a repo archive and an oplog page.
Also worth a look: list_space_records calls sync_space on every request, which walks all writers one after another over the network. A single slow or unreachable writer can add up to the 10s timeout per read. Failures are only logged, so the caller still gets the stale index with no signal. Consider bounding the time spent, or syncing only the writers whose digest differs, which the loop already does.
crates/group-host/src/index_api.rsline 204Outdated
These lines can no longer be read.
repo is not checked against the space's writers, so any reader can make the host resolve an arbitrary DID, call its PDS, and send a group-signed credential there. Require repo to be a writer of space first.
crates/group-host/src/index.rsline 78Outdated
These lines can no longer be read.
res.bytes() has no size limit, so a getRepo or listRepoOps answer from a hostile PDS is buffered whole. Stream it with a cap, as file does for blobs.
Both changed:
- getSpaceBlob now refuses a repo not in the space's writer set before any lookup, local or remote. A test checks that a non-writer's DID gets NotFound and the fake PDS is never asked.
- Remote answers (getRepo, listRepoOps, getBlob) are read in chunks through one capped reader: 64 MiB for a repo or an oplog page, 5 MiB for a file. The file test covers the cap.
- listSpaceRecords now waits on the index's sync for 5s at most, then answers with the index as it is.
The pull adds the space index and serves it through listSpaceRecords and getSpaceBlob. The two changes I asked for last round are done, and I found nothing new that must change. I read index.rs and index_api.rs in full. I did not read the other 14 changed files (the atproto STAR reader, store.rs, lib.rs, identity.rs, the lifecycle and authority edits, the docs and the tests), and I did not read the checks.
- SSRF in
getSpaceBlob: fixed.space_blobnow returns early unlessrepois in the space's writer set (index_api.rs:197-202). That is before any DID resolution or credential signing. I did not read the test for it. - Uncapped remote bodies: fixed.
Remote::asknow reads throughcapped(res, REPO_AT_MOST)(index.rs:81), which is 64 MiB. File fetches still use the 5 MBFILE_AT_MOST. - Slow writers on read:
list_space_recordsnow wrapssync_spacein a 5s timeout and serves the index as it is when that runs out (index_api.rs:92). Only writers whose digest differs are fetched.
The 64 MiB cap is generous for one oplog page of 500 writes. A tighter limit for listRepoOps would make a hostile PDS cost less memory per request, but I wouldn't hold the merge for it.
What changes
The host indexes its groups' spaces.
index.rskeeps a copy of what each writer has written in each group space, read from wherever their repo is.index_pending, woken byrecord_writerand each minute inserve), and before answering for the space.space_sync.rsreads a space:#atproto_kemkey for each request.listRepoOps, every page. The set hash is moved by each write and checked against the commit, whose MAC must check. Each record is checked against its write's CID.getRepo's STAR archive and checked the same way. A record that isn't a DRISL map is hashed, since the commit covers it, and left out.index_repoandindex_record. Deleting a space or an account forgets their part of the index.The index is served by
index_api.rs:fyi.opensocial.listSpaceRecordslists records newest first, by collection, by a field's value (a dotted path), or one by URI, a page at a time.fyi.opensocial.getSpaceBlobserves a file in a space. A file a writer here has is read from the store; one elsewhere is read from the writer's PDS. It must be the file asked for and at most 5 MB.atprotogainsspace::read_starandspace::parse_mac_header, checked against the vectors' archive and MAC.From the last two pulls' reviews:
updateSpacerefusesreadableBy: []rather than ignoring it;Why
This is the last part of step 4. A group's pages read their spaces' contents in one request, rather than a credential and a listing per writer. The prototype's
spaceIndex.tskept the same copy. The reading follows knotless's verified sync rather than the prototype's, including the knotless pull that leaves out a record that isn't a map.checkUserAccesscomes with invites.How it was checked
tests/index.rs:tests/identity.rs: a redirect not followed, an oversized resolver answer, the address backfill.tests/interop.rs: the authority test now has the index read the alpha member's repo from the reference PDS and checks her record. This runs in CI.atproto/tests/space.rs: the STAR reader, round-tripped and refused six ways, and the MAC header parser.just covis at 100% of lines and functions. Clippy is clean.Shortcomings
listSpaceRecordshas norevand noactorsyet. Actors come with people's profiles.🤖 Generated with Claude Code