Skip to content

fix(git): carry NIP-OA delegation in auth event#2120

Merged
tlongwell-block merged 3 commits into
mainfrom
mari/git-nip-oa-auth
Jul 19, 2026
Merged

fix(git): carry NIP-OA delegation in auth event#2120
tlongwell-block merged 3 commits into
mainfrom
mari/git-nip-oa-auth

Conversation

@tlongwell-block

Copy link
Copy Markdown
Collaborator

Summary

  • include BUZZ_AUTH_TAG / nostr.authtag in the signed NIP-98 event emitted by git-credential-nostr
  • let the relay extract that signed NIP-OA tag for the existing owner-membership fallback
  • preserve the legacy x-auth-tag path for direct HTTP clients
  • fail closed when a configured auth tag is malformed

Git's credential-helper protocol only returns the Authorization credential; it cannot inject a separate x-auth-tag HTTP header. As a result, managed agents authenticated successfully as themselves but always reached the relay-membership check without their owner attestation.

Verification

  • bin/cargo fmt --all -- --check
  • bin/cargo check -p buzz-relay
  • bin/cargo test -p git-credential-nostr (8/8)
  • pre-commit hooks passed
  • pre-push non-Rust suites passed; the bare-cargo Rust hook is locally blocked because system rustc 1.89 is below sqlx 0.9's 1.94 MSRV. The same relay check and helper tests pass under the repo's Hermit rustc 1.95.

Co-authored-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
@tlongwell-block
tlongwell-block requested a review from a team as a code owner July 19, 2026 14:31
@tlongwell-block

Copy link
Copy Markdown
Collaborator Author

The transport mechanism is directionally correct: the auth tag is covered by the verified NIP-98 event signature and verify_auth_tag binds the owner attestation to that event's authenticated agent pubkey. However, this Git admission path accepts syntactically valid timestamp conditions without evaluating them.

buzz_sdk::nip_oa::verify_auth_tag validates the conditions grammar and signature, but does not enforce created_at<t / created_at>t. GitAuth then grants owner-membership fallback without comparing those conditions to the already freshness-checked NIP-98 event's created_at. This means an expired NIP-OA credential continues to grant Git relay admission while its owner remains a member. That conflicts with the admission semantics documented in docs/nips/NIP-AA.md (steps 4 and Auth tag expiry).

Please evaluate timestamp clauses against the verified NIP-98 event timestamp before owner-membership fallback, and add relay-side positive/negative tests (at minimum valid owner delegation, wrong-agent signature, expired/not-yet-valid conditions, and multiple auth tags). The helper tests currently prove serialization/signature coverage, but not the authorization decision.

tlongwell-block and others added 2 commits July 19, 2026 10:41
#2120 makes the git transport depend on extract_auth_tag_json to pull
the NIP-OA attestation out of the signed NIP-98 event, but the function
had no direct tests. Add three unit tests locking the behavior the git
admission path relies on: a single auth tag is returned verbatim as the
JSON string fed to verify_auth_tag, an absent tag yields None (direct-
member path), and duplicate auth tags yield None (NIP-OA fail-closed, so
a second forged tag cannot smuggle an alternate delegation past the gate).

Co-authored-by: Dawn (sprout agent) <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
Co-authored-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
@tlongwell-block
tlongwell-block merged commit c12257d into main Jul 19, 2026
32 checks passed
@tlongwell-block
tlongwell-block deleted the mari/git-nip-oa-auth branch July 19, 2026 15:29
morgmart added a commit that referenced this pull request Jul 19, 2026
* origin/main:
  fix(git): carry NIP-OA delegation in auth event (#2120)
  Add native Builderlab auth and community client (#2099)
  Open community creation signup from desktop (#2110)

# Conflicts:
#	desktop/src/features/settings/ui/SettingsPanels.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant