Skip to content

fix: 4 security issues from code audit#334

Merged
laulpogan merged 1 commit into
mainfrom
security/fix-intro-filter-and-health-validation
Jun 17, 2026
Merged

fix: 4 security issues from code audit#334
laulpogan merged 1 commit into
mainfrom
security/fix-intro-filter-and-health-validation

Conversation

@HermanShermanBot

Copy link
Copy Markdown
Contributor

Security fixes from code audit

Addresses 4 issues found during a security review of the wire codebase.

HIGH

  • handle_intro filter logic (relay_server.rs:1684) — Filter used && instead of ||, allowing events with mismatched kind/type combinations to pass validation. A kind=1100 event with any type value, or a kind≠1100 event with type="pair_drop", would slip through. Changed to require both conditions.

MEDIUM

  • Invite token entropy (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).
  • responder_health_set path validation (relay_server.rs:2013) — Added is_valid_slot_id() check before constructing file paths from the slot_id URL parameter. Bearer token check existed but defense-in-depth was missing.
  • Macaroon constant-time comparison (macaroon.rs:62) — Replaced != with a constant-time byte comparison to prevent timing side-channels on signature verification.

Testing

  • All changes compile cleanly (cargo check)
  • CodeScene reviewed both files — no new code smells introduced
  • Pre-existing complexity/duplication flags on relay_server.rs are unchanged

Files changed

  • src/relay_server.rs — +14/-4
  • src/macaroon.rs — +14/-1

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)
@HermanShermanBot HermanShermanBot force-pushed the security/fix-intro-filter-and-health-validation branch from c5c55f7 to b80b59d Compare June 17, 2026 03:58
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying wireup-landing with  Cloudflare Pages  Cloudflare Pages

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

View logs

@laulpogan laulpogan merged commit 0040dd2 into main Jun 17, 2026
13 checks passed
@laulpogan laulpogan deleted the security/fix-intro-filter-and-health-validation branch June 17, 2026 04:07
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>
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.

2 participants