Skip to content

tech-detect: RequireJS fingerprint takes about 70 s on a 1 MB page of unclosed <script tags #1244

Closed

Description

@nc9

Summary

Technology detection runs every fingerprint over each stored page. On a hostile 1 MB page made of <script repeated 125,000 times, detection takes about 70 s of CPU. Measured one fingerprint at a time against that input, requirejs accounts for about 70.5 s of the 70.5 s total; every other pre-existing fingerprint takes about 1 ms or less.

The cause is the requirejs html pattern in packages/tech-detect/src/fingerprints/generated.ts: <script\b[^>]*\sdata-main\s*=\s*["'] has an unbounded [^>]*, so each unclosed <script scans to the end of the document (quadratic). The file is generated (scripts/generate-tech-fingerprints.ts, data in packages/tech-detect/data/research-fingerprints.json), so the fix belongs in the source data, then regenerate.

The existing ReDoS test in packages/tech-detect/tests/fingerprints.test.ts does not catch it: its adversarial inputs never contain a flood of unclosed <script tags.

Found while reviewing #1243 (new fingerprints there are bounded and gated; this one is pre-existing).

Acceptance Criteria

  • The requirejs html pattern is length-bounded (for example [^>]{0,300}) in the generator source data, and generated.ts is regenerated.
  • Every tech-detect fingerprint, run alone, takes under 250 ms on a 1 MB page made of <script repeated, and on 1 MB pages of repeated <script src=", <meta , <link and <img openers.
  • A regression test in packages/tech-detect/tests/ runs each fingerprint separately against those inputs and fails naming the slow fingerprint ids.
  • Detection of real RequireJS markup (<script data-main="js/main" src="require.js">) still matches.
  • CHANGELOG has one bullet under ## [Unreleased].

Activity

  1. added
    bug
    size: S
    performance
    on Oct 28, 2026
  2. WilliamK112 commented on Oct 29, 2026

    @WilliamK112
    Contributor

    I’ll take this. I’ll bound the RequireJS source pattern, regenerate the fingerprint output, and add the per-fingerprint adversarial-input regression described in the acceptance criteria, including the real RequireJS positive control.

  3. added theissue type on Oct 29, 2026
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

    bugperformancesize: S

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions