~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

A space read's bad signature is BadSpaceSignature, and a wrong audience a 401

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:spaces/bad-space-signature

A space credential's request with a failed signature now gets 401 BadSpaceSignature, the spaces alpha's name for it; we answered BadSignature. A request signed for another repo now gets 401 BadSpaceAudience rather than a 400. The audience and signature are also checked in the order the reference PDS uses.

Claude Opus 5.5 · high effort

What changes

The signature's error name. The fix is in atproto 0.3.1 (knotless.dev/chadtmiller.com/atproto, pull at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3n33xfty5rw2v): space_auth::sign_request and verify_request now refuse with BadSpaceSignature. This workspace now requires 0.3.1.

The audience. space_api::credential now checks the audience the same way as @atproto/pds's spaceCredentialAuth and assertCredentialSpace:

  • An atproto-space-audience header that is missing or not a DID gets 401 BadSpaceSignature. This is checked before the signature.
  • An audience that isn't the repo being read gets 401 BadSpaceAudience. This is checked once the signature holds and the credential isn't revoked.
  • Before, both cases got 400 BadSpaceAudience, and the audience was compared before the signature was checked.

Why

In @atproto/space (0.0.0-spaces-alpha-20261113224550, and every alpha since 20261022), SpaceSignatureError has code = 'BadSpaceSignature'. @atproto/pds auth-verifier.js answers it as a 401 under that name, and api/com/atproto/space/util.js throws BadSpaceAudience as an AuthRequiredError (401). A client that tells these refusals apart by name got names and statuses no other host gives.

How it was checked

just t -p group-host --test spaces passes, 14 tests. reads_only_with_a_credential_the_authority_issued now covers each case:

  • signed for another repo;
  • the audience changed after signing;
  • no audience;
  • an audience that isn't a DID;
  • the wrong key;
  • no signature.

Shortcomings

One more mismatch is left: a credential for another space of the same authority gets 401 BadJwtSub here, because we pass sub to the token check. The reference's PDS doesn't pass it; its handler answers 400 InvalidCredential.

Approved

This pull makes space_api::credential return 401 BadSpaceSignature for a failed signature, and for an audience header that is missing or not a DID. That DID check now runs before the signature check. An audience that is a DID but isn't the repo being read now gets 401 BadSpaceAudience. That check runs only after the signature and the revocation check pass. The ordering and status codes match what the description says the reference PDS does. I could not check that against @atproto/pds. The atproto 0.3.1 bump and the Cargo.lock change are consistent with it. The test covers each case, including the signed-for-another-repo case, which the old test did not. I did not run the tests or read the checks. I found nothing that needs changing.

Merged as 89f8aba