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

zat.dev/zds

atproto pds · mirror of https://tangled.org/zat.dev/zds

0
0
118 lines · 6.4 KB Raw History
# account recovery, blob MIME and dynamic collection review

Reviewed November 16, 2026, against v0.14.14 (`9d26564`). The implementation
commits are `455e20b`, `0450293` and `c339095`; the review fix is `62825ae`.
This is a focused change review, not a whole-server security audit.

## findings and regressions

Reset codes initially survived an email change, allowing a code delivered to
the previous inbox to reset the account. Email changes now remove reset and
confirmation codes in the same transaction. Code issuance checks the current
email while holding the storage lock, closing the concurrent issuance window.
Regression coverage includes stale issuance, redemption and rollback when code
deletion fails.

Invalid reset requests initially paid the password-hashing cost. They now check
the code before hashing, then check again in the transaction that consumes it.
The second check preserves expiry and one-use behavior during races. Existing
HTTP coverage also checks concurrent redemption, replay, wrong-purpose codes,
failed-audit rollback, password changes and session revocation.

The review checked detected MIME types reaching both authorization and storage,
streamed byte preservation, declaration replacement/removal, fixed explicit
collection grants, authority isolation and token refresh. Existing defaults
stored as explicit collections cannot be distinguished retroactively; those
clients need reauthorization.

## generated cases

Zig 0.17.0 and Hegel `4b2bc83a5750bb872524bb97ccb0f6c45a1c3d24` run the optional
campaign in `tools/fuzz/account_spaces.zig`. Seeds 17, 42 and 99 each run 100
cases for each of three properties: 900 exploration cases total. MIME cases
combine arbitrary prefixes, truncated inputs and structured signatures with
untrusted headers. State machines exercise declaration changes and password
recovery against small independent models. Every recovery history exercises a
stale inbox code; counters also distinguish successful resets and expiry steps.

Mutation calibration runs in a disposable checkout and restores each mutation:
trusting the MIME header, skipping dynamic defaults, and retaining old-inbox
codes. Compilation failures do not count as behavioral detection. Commands,
logs and replay blobs are retained locally in
`bench/results/account-spaces-review/`; shrinking/replay counts are separate
from the exploration total above.

All three mutants were behaviorally detected on seeds 17 and 42 (6/6).
The stale-inbox replay `AXicY2IAAi5GBgQFAAEFABk=` passes on the fixed source
with `-Dfuzz-filter='campaign password'`. This replay is separate from the 900
exploration cases.

The campaign uses real SQLite, scheduling and entropy with synthetic identities
and cached declarations. It is not a crash/restart or deterministic-I/O campaign.
Live DNS changes, cache-miss network failures, partial upload transport failures
and cross-PDS workflows remain outside these generated tests. HTTP smokes cover
transaction rollback and concurrent reset consumption separately.

## performance method

ReleaseFast probes measure MIME recognition, invalid/valid password recovery,
cached declaration parsing plus grant expansion/matching, and loopback HTTP
at concurrency eight. HTTP comparisons use the same harness and independent
disposable state for v0.14.14 and the candidate. Compilation is excluded; final
comparisons run sequentially after compiler activity ends. The client itself
contributes Python thread, connection and JSON overhead.

Cached authorization excludes DNS and remote fetch latency. Password results
include the existing PBKDF2 policy and durable SQLite transaction; they do not
compare different password-hashing policies across servers.

On the development Mac, the focused probes measured:

| work | measured cost |
| --- | ---: |
| MIME recognition, 1,000,000 mixed inputs | 7 ns/op |
| cached dynamic expansion + match, 10,000 checks | 727 ns/op |
| invalid reset code, 10,000 attempts | 2.83 µs/op |
| code issuance + successful reset, 20 transactions | 10.96 ms/op |

Three paired HTTP runs (median of run summaries):

| workload | v0.14.14 req/s | candidate req/s | baseline / candidate p95 |
| --- | ---: | ---: | ---: |
| getSession, 500 requests | 5,953 | 5,966 | 2.03 / 2.03 ms |
| 128 KiB PNG upload, 128 requests | 4,044 | 4,067 | 3.03 / 2.97 ms |
| invalid reset, 500 requests | absent | 5,437 | — / 2.21 ms |
| alternating reset/read, 500 requests | absent | 5,661 | — / 2.14 ms |

The small upload sample's candidate p99 was 4.15 ms versus 3.45 ms. Two larger
512-upload pairs, reversing execution order, put baseline p99 at 3.77–4.67 ms
and candidate at 3.75–3.80 ms; p95 ranges overlap (2.99–3.03 versus 2.75–3.13 ms).
No consistent regression was observed. These short, local probes do not establish
production capacity or sustained-load tails.

## contract and dependency decisions

The official PDS at `56201be4acdcb4333f2da430ce62f6e9a42aa79d` and Tranquil at
`b95f999e639fbf392ffe9c21a84a38b21704536c` were inspected for reset and upload
behavior. ZDS follows detection-before-header fallback, but its bounded common
signature detector is not the full `file-type` or `infer` format registry.
Unknown formats intentionally retain the caller's Content-Type; sniffing does
not validate a complete media file. No equivalent upstream benchmark exists at
these exact seams, and no cross-implementation performance parity is claimed.
Broader format-registry parity and cold-cache HTTP timing remain follow-up work.

The [Spaces proposal](https://github.com/bluesky-social/proposals/tree/b54ec6853bab77edd4fd373804a480633094b324/0016-permissioned-data)
requires evaluating default collections against the declaration. ZDS retains a
five-minute document cache, fails writes closed on failed resolution, and keeps
explicit collection grants fixed. Its scope storage/resolution and account
transactions remain PDS-local policy. The MIME fallback is upload glue, not an
AT Protocol wire primitive; Zat is unchanged.

Password changes immediately revoke direct access sessions, stronger than the
reference's refresh-only invalidation. Separately managed OAuth grants, app
password credentials and passkeys remain intact. ZDS's 256-byte password bound
is stricter for non-ASCII input than the reference's JavaScript length check.

Brooke's RPC-audience fix remains in ancestry as
`40a58b7209fa0eba47e0906e101a31620dc9f548`, authored by
`Brooke <me@abcbrookie.com>`. The RPC scope benchmark and regressions remain intact.