Skip to content

fix(auth): bind each local write to its exact proof - #187

Draft
marcus-pousette wants to merge 1 commit into
fix/auth-outbound-read-guardfrom
fix/atomic-local-auth-proof-handoff
Draft

marcus-pousette wants to merge 1 commit into
fix/auth-outbound-read-guardfrom
fix/atomic-local-auth-proof-handoff

Conversation

@marcus-pousette

@marcus-pousette marcus-pousette commented Jul 11, 2026 •

Copy link
Copy Markdown
Collaborator

Roadmap: Source material for #255 and #256.
Status: Legacy auth model, not a merge candidate. Port the exact operation/grant binding to OperationAuth.ownerGrantId; do not merge the OpAuth.proofRef stack wholesale.

Critical issue

An operation signature did not bind its proofRef. A relay could replace that reference with another token for the same key, and the verifier could search other candidate tokens when the reference was missing or unusable. That allowed the same signed operation to be reinterpreted under different authority.

A local operation created without retained proof material could also be signed later during reconciliation, after the original write boundary.

One strict contract

Every authenticated operation carries exactly:

  • a 64-byte Ed25519 signature
  • a 16-byte capability-token reference

The token reference is selected before signing and is part of the sole treecrdt/op-sig/v1 input. Verification resolves only that referenced token.

Only the local_write authorization purpose may create a new proof. Reconcile and subscribe paths may reuse an exact cached/stored proof, but cannot mint one after the operation was committed.

What changes

  • Make OpAuth and LocalWriteAuthProof complete, required types.
  • Return proof bytes directly from authorizeLocalOps.
  • Remove requireProofRef, candidate-token fallback, and the optional proof-extractor adapter.
  • Validate exact widths at protobuf, store, and backend boundaries.
  • Use NOT NULL plus length constraints in fresh SQLite/Postgres proof tables.
  • Cryptographically check retained proof material against the exact operation before reuse.
  • Make signed conformance scenarios authorize local writes when they are created; scoped-filter rejection remains unsigned because it fails before reconciliation.

Fast paths

  • Verification performs one referenced-token lookup instead of scanning candidates.
  • Authorization selects/signs once and hands the same bytes to the backend commit.
  • Exact cached/stored proofs are reused without re-signing.
  • Auth-disabled writes create no auth session or proof row and remain on their direct path.

Clean-slate choice

There is one wire/signature/store format. There is no old signature verifier, optional reference, nullable schema, migration, or downgrade path. Development proof data from the earlier format must be recreated.

Verification

  • auth test suite
  • sync protocol test suite
  • SQLite proof-material test suite
  • relevant SQLite/Postgres/interface TypeScript builds
  • formatting and diff checks

Stack

Stacked on #191. #192-#196 consume this exact-proof contract.

@marcus-pousette
marcus-pousette marked this pull request as draft July 11, 2026 22:35
@marcus-pousette

Copy link
Copy Markdown
Collaborator Author

Temporarily marked draft while rebasing this proof-handoff foundation off the superseded #182/#183 branches and onto the lean #188–#191 auth stack. The proof contract/exact-body validation remain; preWriteState/scoped-write dependencies and obsolete tests are being removed before it is marked ready again.

@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from e39a074 to 1462d42 Compare July 11, 2026 23:01
@marcus-pousette
marcus-pousette changed the base branch from fix/auth-children-filter-redaction to fix/auth-outbound-read-guard July 11, 2026 23:01
@marcus-pousette
marcus-pousette marked this pull request as ready for review July 11, 2026 23:01
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from 1462d42 to d62a09a Compare July 11, 2026 23:02
@marcus-pousette marcus-pousette added bug Something isn't working area:auth Authorization, capabilities, proofs, signatures, crypto, and privacy area:api Public interfaces, bindings, events, and cross-backend contracts labels Jul 12, 2026
@marcus-pousette marcus-pousette changed the title fix(auth): expose atomic local proof handoff fix(auth): expose local proofs for atomic backend commits Jul 12, 2026
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from 7e254df to fde4928 Compare July 12, 2026 12:32
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from d62a09a to 2b042a9 Compare July 12, 2026 12:34
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from fde4928 to 76db022 Compare July 13, 2026 14:07
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from 2b042a9 to 58c0e71 Compare July 13, 2026 14:07
@marcus-pousette marcus-pousette changed the title fix(auth): expose local proofs for atomic backend commits fix(auth): return proofs for atomic backend commits Jul 13, 2026
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from 58c0e71 to 2a4f4b4 Compare July 13, 2026 14:12
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch 2 times, most recently from 72cf530 to 7ac402b Compare July 13, 2026 15:06
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from 2a4f4b4 to a1f0048 Compare July 13, 2026 15:14
@marcus-pousette marcus-pousette changed the title fix(auth): return proofs for atomic backend commits fix(auth): bind each local write to its exact proof Jul 13, 2026
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch 2 times, most recently from c61c8b8 to 9d2b7e0 Compare July 13, 2026 15:30
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from 7ac402b to dbc37dc Compare July 13, 2026 15:50
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from 9d2b7e0 to 9c800f1 Compare July 13, 2026 15:51
@marcus-pousette
marcus-pousette force-pushed the fix/auth-outbound-read-guard branch from dbc37dc to f019796 Compare August 19, 2026 08:52
@marcus-pousette
marcus-pousette force-pushed the fix/atomic-local-auth-proof-handoff branch from 9c800f1 to 7f1c87a Compare August 19, 2026 08:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api Public interfaces, bindings, events, and cross-backend contracts area:auth Authorization, capabilities, proofs, signatures, crypto, and privacy bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant