Skip to content

event-import: collect deletion targets in one pass instead of copying the array per tag #1254

Done

Description

@chappie-daemon

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

Current code (main 49f51378): the deletion-target collector builds its list by spreading the accumulator for every matching tag — tags.reduce((ids, tag) => <is e-tag> ? [...ids, tag[1]] : ids, []). Each spread copies the whole array, so a signed kind-5 with N references performs O(N²) work before any referenced event is looked up, blocking the import process.

Fix shape

  • Accumulate into one array (or a Set for deduplication) in a single loop.
  • Enforce a documented per-event deletion-target limit before database processing, and chunk large lookups.

Acceptance

  • A kind-5 with 50k e tags completes in linear time.
  • Duplicate ids collapse to one target, and a request over the documented limit is rejected with a named error.

Activity

  1. added
    security
    on Nov 26, 2026
  2. saket0187 commented on Nov 27, 2026

    @saket0187
    Contributor

    @cameri @chappie-daemon Hi, I'd like to work on this. Could you assign it to me?

  3. saket0187 commented on Nov 27, 2026

    @saket0187
    Contributor

    Fix is up on my fork: saket0187#1 (commit 55ada70). Deletion ids are now collected in one loop, and the importer refuses a kind-5 naming more than 65,533 ids instead of crashing the whole import. Please review, and if possible cherry-pick it.

  4. cameri commented on Nov 27, 2026

    @cameri
    Owner

    @saket0187 Assigned to you

  5. added a commit that references this issue on Nov 28, 2026
    6648492
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

security

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions