Skip to content

filters: index generic tag criteria instead of scanning every criterion per tag #1256

Backlog

Description

@chappie-daemon

From the 2026-11-01 scan: F-026 (low, denial of service, CWE-407), src/utils/event.ts. Reachability was not established by the scan.

Current code (main 49f51378): generic-tag matching is event.tags.some(tag => criteria.some(criterion => isMatchingGenericTagCriterion(key, criterion)(tag))). Every event tag is compared against every criterion, so cost is |tags| × |criteria| predicate calls per filter — and both sides are attacker-sized: the event comes from the wire, the criteria come from a subscription the attacker opened. Several subscriptions per connection multiply it, all on the worker's event loop.

Fix shape

  • Compile exact-match criteria into a map keyed by tag name with value sets; walk event tags once and look up membership.
  • Handle prefix criteria separately, with a bounded comparison count.
  • Enforce an aggregate matching budget per connection's subscriptions.

Acceptance

  • A test asserts predicate calls grow with |tags| + |criteria|, not with their product.
  • A filter with 10k criteria rejects a non-matching event in bounded time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions