chadtmiller.com/group-host
atmosphere group host
A space's authority may be a did:web, its key kept a few minutes
MergedThis adds a Resolver (identity.rs) that reads did:plc and did:web documents and keeps them for five minutes. It routes the notifyWrite PDS lookup, credential verification and service-auth verification through that resolver. A key that fails verification is re-read once. The logic and tests look right. I didn't run the checks.
One thing should change before merge. The resolver now fetches and stores documents named by unauthenticated callers, with no cap on either. The "Shortcomings" section lists the unbounded cache but treats it as acceptable. It isn't, for the reasons below.
- Unbounded memory.
service_callerresolvesclaims.account()from a token it has not yet verified.credentialresolves a space authority taken from the request. Each newdid:web:<host>that answers with a document whoseidmatches adds a permanent entry tokept. Expired entries are never removed. A caller can grow the map without limit by serving documents from their own host. - Unbounded response body.
res.json()reads the whole body, so one request can pull in an arbitrarily large document, which is then stored. - Server-side requests to caller-chosen hosts. With
https, the host can be made to request any hostname. Check whethercrate::client()blocks private and loopback addresses. If it doesn't, internal services are reachable. This is also true ofdid:webin general, so a note in the docs is enough if you accept it.
Please cap the cache. Evict expired entries on insert, and bound the entry count. Also cap the document size, for example by reading at most a few hundred KB.
Smaller point: every bad signature from a known authority forces a fresh network read, with no limit on how often. This matches knotless, so I'm not asking for a change. It is another reason to keep the fetch size bounded.
crates/group-host/src/identity.rslines 59 to 63Outdated
These lines can no longer be read.
Inserted for any DID whose host serves a matching id, and never removed. Reached from unverified input (service_caller's iss, the space authority in a read). Evict expired entries here and bound the map's size.
crates/group-host/src/identity.rsline 55Outdated
These lines can no longer be read.
res.json() buffers the whole body, which is then also stored. Limit the bytes read, since the host is named by the caller.
The cache is now capped: it holds at most 10,000 documents, drops the lapsed first and then clears everything, and a test covers it. That answers the unbounded-memory point from my last round.
One request from last round is still open. The document size is not capped. document calls res.json(), which reads the whole body, and the client has only a 10-second timeout (lib.rs client()). A caller can name any did:web host and make the host buffer whatever that host streams in 10 seconds. A cached entry can then be that large, and with 10,000 entries the cache itself is still unbounded in bytes. Please read the body in chunks, or check Content-Length and count bytes as they arrive. Stop at a few hundred KB, and fail with an error. Add a test with an oversized document.
The server-side requests to caller-chosen hosts are still unaddressed. The client does not block private or loopback addresses. I said last round that a docs note would be enough. The "Shortcomings" section covers the GET to any host, but says nothing about internal addresses. A sentence in docs/design/spaces.md or the config reference would do.
The rest looks right: with_key re-reads once when the kept key fails, the id check, the did:web path refusal, and the config validation. I didn't run the checks.
crates/group-host/src/identity.rsline 74Outdated
These lines can no longer be read.
res.json() buffers the whole body, and the 10s timeout is the only limit. Cap the bytes read (a few hundred KB) and bail past that. This is the cap I asked for last round.
Both requests from last round are done, so I'm approving. I didn't run the checks.
- Document size:
body()reads the response in chunks and fails once it passes 256 KiB. A test covers an oversized document. With the 10,000-entry cap, the cache is now bounded in bytes. - Internal addresses:
docs/design/spaces.mdnow says that private and loopback addresses are not refused. It tells operators to keep the host's outgoing requests from reaching internal services.
I found nothing else to change.
What changes
A space's authority may be a
did:web. The host reads other accounts' DID documents through a new resolver (identity.rs): adid:plcfrom the PLC directory, adid:webfrom<scheme>://<host>/.well-known/did.json. It refuses adid:webwith a path, any other method, and a document whoseidisn't the DID asked for. These now go through it:notifyWrite;notifyCredentialRevoked.Keys are kept five minutes. Reads by the same authority's credentials no longer look up its document each time. When the kept key turns a signature away, the document is read again and the check made once more, so a key the authority moved to counts at once. With nothing kept, the document is read once.
DID_WEB_SCHEME(httpsby default, orhttp) sets how adid:webis read, so tests can serve one from a local port. It is listed indocs/reference/config.md.The spaces design page says how identities are read, and the plan marks the resolver done.
Why
The last pull listed two shortcomings: an authority could only be a
did:plc, and every read looked its key up afresh. This follows knotless'sidentity.rsfor both: thedid:webscheme setting, five minutes kept, and a fresh read when a signature fails. The reference PDS does the same withforceRefresh. Theidcheck is added because adid:webhost serves whatever it likes.How it was checked
tests/spaces.rs:a_space_of_a_did_web_authority: a write is told to the PDS adid:webdocument names, and that authority's credential reads the repo with its MAC;reads_with_a_credential_signed_by_an_authoritys_new_key: the authority rotates its key on the directory after the host kept the old one, and a credential signed with the new key still reads.tests/identity.rs: refusals of other methods, adid:webwith a path, a document of another DID, a document with no signing key (kept or read again), and a directory that doesn't answer.tests/config.rs:DID_WEB_SCHEMEand its refusal.just cov: 100% of lines and functions. Clippy is clean.Shortcomings
/.well-known/did.jsonfrom a host of their choosing. Each document is read to 256 KiB at most, and at most 10,000 are kept: when full, the lapsed go, then all. Private and loopback addresses are not refused.docs/design/spaces.mdsays so, for whoever deploys a host inside a network with such services.🤖 Generated with Claude Code