fix: 4 security issues from code audit#334
Merged
Merged
Conversation
HIGH: handle_intro filter logic (AND→OR) — events with mismatched kind/type combos could slip through validation. MEDIUM: - Invite tokens: 3 bytes → 8 bytes (48-bit → 64-bit keyspace) - responder_health_set: add is_valid_slot_id() before path construction - Macaroon verify: constant-time sig comparison (prevent timing leak)
c5c55f7 to
b80b59d
Compare
Deploying wireup-landing with
|
| Latest commit: |
b80b59d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://40c6dec0.wireup-landing.pages.dev |
| Branch Preview URL: | https://security-fix-intro-filter-an.wireup-landing.pages.dev |
laulpogan
added a commit
that referenced
this pull request
Jun 17, 2026
…#334 follow-up) (#335) #334 fixed a HIGH boolean bug in the unauthenticated /v1/handle/intro filter (the `&&`-chain accepted a kind=1100 event of ANY type, and a wrong-kind event whose type happened to match) but added no test, so the exact bypass could silently come back. Lock it: - Extract the accept rule as a pure `intro_event_allowed(kind, type_str)` — `kind == 1100 && (type_str == "pair_drop" || type_str == "agent_card")` — and call it from the handler (no behavior change; just testable). - Regression test asserts the full accept/reject matrix, with the two #334 bypass classes called out explicitly: (a) kind=1100 + any other type rejected, (b) wrong-kind + matching type rejected. Pure refactor + test only; the live filter logic is byte-equivalent to #334's fix. 601 lib tests green, clippy clean. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security fixes from code audit
Addresses 4 issues found during a security review of the wire codebase.
HIGH
relay_server.rs:1684) — Filter used&&instead of||, allowing events with mismatched kind/type combinations to pass validation. A kind=1100 event with anytypevalue, or a kind≠1100 event with type="pair_drop", would slip through. Changed to require both conditions.MEDIUM
relay_server.rs:1399) — Bumped from 3 random bytes (48-bit, ~16.7M keyspace, brute-forceable in hours at 1k req/s) to 8 bytes (64-bit, infeasible).relay_server.rs:2013) — Addedis_valid_slot_id()check before constructing file paths from theslot_idURL parameter. Bearer token check existed but defense-in-depth was missing.macaroon.rs:62) — Replaced!=with a constant-time byte comparison to prevent timing side-channels on signature verification.Testing
cargo check)Files changed
src/relay_server.rs— +14/-4src/macaroon.rs— +14/-1