chadtmiller.com/monolith
An atproto PDS
Hardening, second pass: SSRF everywhere, OAuth sign-in limits and 2FA, bounded OAuth and outbound state, account state on OAuth and spaces
MergedThis pull hardens the PDS in a second pass: the SSRF guard now covers spaces fetches, OAuth sign-in gets the login limits, 2FA and a response floor, OAuth and outbound state are bounded, and account state is enforced on OAuth and spaces calls. X-Forwarded-For is now read only from PDS_TRUSTED_PROXIES.
What I checked against .knotless/review.md:
- Spec: each behaviour change I read has a matching edit in the page that owns it. That covers
LIMITS,OAUTH,PROXY,LIFECYCLE,EMAIL,OAUTH-SCOPESand the spaces pages, and the departures from the reference are listed. - README: the new text states only what is built, with no history in it.
- Dependencies: the root
Cargo.tomlis untouched, so no atproto or MCP crates are added. - Harness: the diffs I read add checks and don't loosen any. The
X-Forwarded-Forchange makes the harness setPDS_TRUSTED_PROXIESto the reference's own trust list, so comparisons are unchanged. The new server-only checks are wired into the limits run (harness/checks/limits.mjs). - Conformance excuses:
harness/conformance.yamlis not touched.
I read the limits.rs, server.rs, lib.rs and dpop.rs diffs, the README, and the changes to harness/compare.mjs, harness/lib/env.mjs, harness/lib/services.mjs and harness/checks/oauth-limits.mjs. They look correct. The trusted-proxy parsing and matching, the shared password-hash path and the bounded DPoP memory set all hold up, and the new tests cover the edge cases.
I did not read the rest of the roughly 8,700-line diff: oauth.rs, oauth/page.rs, outbound.rs, proxy.rs, lifecycle.rs, the space_* modules, the other harness checks and most of the spec pages. I did not run the checks, and the pull says the merge queue runs the full gates.
A second security pass, from a review of everything built since the first. It covers OAuth, spaces, the proxy, lifecycle and email: 13 findings, plus
X-Forwarded-Fortrust. Each finding became a rule in the page that owns it, probed on the reference where the reference can show it, with a check that fails on the code before this pull, then the fix.What changes, by finding
did:webdocument, client attestation, JWKS, managing-app andserviceEndpointfetch goes through the one guarded client: no redirects, size caps, and nolocalhostor IP-address hosts while protection is on (PROXY.md"SSRF protection", referenced from the spaces pages). The spaces run restarts the server with protection on and counts connections to its own listeners.did:webfetches have their own pool of 16, apart from the directory's 8. Calls authenticated by service auth, a delegation token or a credential pay their rate-limit points before anything is fetched.401 second_authentication_factor_requiredand mails a code, ascreateSessiondoes, with the reference's 30-day remembered device.createSession's login buckets.state1024 bytes,code_challengeexactly 43 characters, and others).stateis kept as a hash.invalid_grant.login_requiredfor taken-down and deactivated accounts.getServiceAuthand forwarded calls refuse a taken-down account.chat.bsky.prefix is compared without regard to case, a departure from the reference listed inOAUTH-SCOPES.md.registerNotifyfan-out. 64 registrations per space and 8 per credential key (TooManyRegistrations), with at most 1024 forwards waiting.PDS_ADMIN_PASSWORDmeans unset.getDelegationTokenandgetSpaceCredentialare gated on account state, as the alpha does.resetPasswordends the account's OAuth sessions, approved requests and device sign-ins, a departure from the reference. A sign-in renews the device cookies; the old ones name the device for 30 seconds, then end it.X-Forwarded-For. It is read only from peers listed inPDS_TRUSTED_PROXIES, unset by default, so rate limits key on the connection's address. The harness sets it for the reference's network, so comparisons are unchanged.Departures from the reference (findings 8, 11, 13, the DPoP storage, the OAuth caps the reference lacks) are listed in their pages, with the reason. The harness holds the server alone to them.
Not seen from outside, covered by the server's own tests: the hash pool, the outbound and
did:webslot pools, the global PAR cap, DPoP proofs held in memory, and the waiting-forward bound.Checked:
--limits(with the new checks), plain seed 1, crash seed 21 with--firehose,--lifecycle, the spaces run, focused runs for the password-reset and device-cookie checks, andcargo test --workspace. The merge queue runs the full gates.🤖 Generated with Claude Code