Skip to content

fix(tech-detect): Imperva matches X-CDN: Imperva as well as Incapsula #646 - #872

Merged
nc9 merged 1 commit into
mainfrom
fix/646-imperva-xcdn
Oct 16, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/646-imperva-xcdn

Conversation

@nc9

@nc9 nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Closes #646.

What changes

pub#643 taught waf-detect that X-CDN: Imperva means Imperva. tech-detect's Imperva fingerprint still matched Incapsula only, so the two disagreed on the same response.

  • The fingerprint moves out of the generated set (fingerprints/generated.ts) into the curated SECURITY_FINGERPRINTS (fingerprints/security.ts).
    • The generated set comes from packages/tech-detect/data/research-fingerprints.json, which is gitignored and in neither repo, so a fix made there could not survive a regeneration.
    • The generator skips any id the curated set defines (scripts/generate-tech-fingerprints.ts, CURATED includes SECURITY_FINGERPRINTS), so a regeneration now keeps the curated entry and does not re-add the old one.
  • X-CDN now matches /\b(?:Incapsula|Imperva)\b/i. The X-Iinfo and /_Incapsula_Resource detectors, the id, the name and the icon are unchanged.
  • Not in scope: in a local audit, technology detection only sees the headers the crawler stores, and X-CDN is not one of them, as the issue thread notes. That is filed as tech-detect in a local audit only sees a fixed header subset, so header-only fingerprints never match #871.

Tests

  • packages/tech-detect/tests/imperva-xcdn-646.test.ts: X-CDN: Imperva and X-CDN: Incapsula are detected, X-CDN: Fastly is not, and the entry is in the curated set and not the generated one. Fails before the change.
  • Re-ran fingerprints.test.ts (no duplicate ids) and untrusted-meta.test.ts.
  • tsgo is clean for tech-detect, and test-suites.ts --check and the detect-secrets hook pass.
  • Codex (gpt-6-astra) found no issues.

Docs and skill

  • No docs page lists individual fingerprints. There's a CHANGELOG entry under Unreleased, Fixed.
  • The squirrelscan agent skill needs no change.

@nc9
nc9 force-pushed the fix/646-imperva-xcdn branch 2 times, most recently from e50de9e to caf5a34 Compare October 16, 2026 15:24
@nc9
nc9 marked this pull request as ready for review October 16, 2026 15:24
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of PR 872 (Imperva X-CDN fingerprint moved to the curated set).

No (high) or (critical) findings. The fingerprint moves from generated.ts to security.ts. index.ts spreads SECURITY_FINGERPRINTS, so it is still loaded, and the other detectors are unchanged.

  • (nit) security.ts: the new pattern /\b(?:Incapsula|Imperva)\b/i is slightly stricter than the old unanchored Incapsula. A value like Incapsula-edge still matches because - is a word boundary. xIncapsula no longer matches, which is fine and arguably better.
  • (nit) imperva-xcdn-646.test.ts: the second test asserts the id is absent from GENERATED_FINGERPRINTS. That will fail if a later regeneration emits the id again, and the comment says regeneration skips ids defined in the curated set. I did not check the generator script, so it is worth confirming that skip behaviour.
  • (nit) The test only checks X-CDN values. A case for the X-Iinfo header or the /_Incapsula_Resource script URL would show those detectors survived the move.

The CHANGELOG entry reads well. Tests cover the new behaviour. I did not run them.

@nc9

nc9 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Review triage (caf5a34): no change pushed.

  • (nit) stricter \b(?:Incapsula|Imperva)\b: intended, as the review says.
  • (nit) regeneration skip: confirmed. scripts/generate-tech-fingerprints.ts collects every curated id, SECURITY_FINGERPRINTS included (lines 71-78), and skips a generated entry whose id is already taken (seen, line 132), so a regeneration cannot re-emit imperva-incapsula into generated.ts.
  • (nit) X-Iinfo / /_Incapsula_Resource cases: the moved fingerprint is the one under test; its other detectors moved verbatim. Leaving it to keep this PR to one push.

…646

The fingerprint moves from the generated set to the curated security
set: the generated set's research data is not in the repository, so a
fix there could not survive a regeneration, which skips ids the curated
set defines. X-CDN now reads Imperva or Incapsula, matching waf-detect.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/646-imperva-xcdn branch from caf5a34 to 92694a2 Compare October 16, 2026 15:54
@claude

claude Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review of #872 (Imperva X-CDN fingerprint moved to the curated set)

No high or critical findings. The change is small and correct. I read the diff and confirmed in fingerprints/index.ts that SECURITY_FINGERPRINTS is spread before GENERATED_FINGERPRINTS. I did not run the tests.

  • (low) security.ts: the new X-CDN pattern is /\b(?:Incapsula|Imperva)\b/i, while the old one was an unanchored Incapsula. The word boundaries are stricter and sensible. Values like Imperva-1 still match, but a value like ImpervaCDN no longer does. That seems fine, but it is a small behaviour change you may want to mention in the changelog.
  • (nit) imperva-xcdn-646.test.ts: the test only passes html: "" and headers. A case for the X-Iinfo header or the /_Incapsula_Resource script URL would show the other two detectors survived the move. This is optional.
  • (nit) The second test checks that GENERATED_FINGERPRINTS lacks the id. If the research source is later regenerated and re-adds it, the test fails. That is probably what you want. Leave a comment saying so, so a failing run is not mistaken for a bug.

Tests and changelog entry look good.

@nc9
nc9 merged commit b022e86 into main Oct 16, 2026
15 checks passed
@nc9
nc9 deleted the fix/646-imperva-xcdn branch October 16, 2026 16:16
nc9 added a commit that referenced this pull request Oct 29, 2026
…s on hostile page) #1244 (#1245)

Closes #1244.

Detection scans every stored page with every fingerprint, so a pattern with an unbounded run after a repeatable literal is quadratic on a page that repeats the literal and never closes it. `requirejs` took about 70 s on 1 MB of `<script ` repeats (1 MB flood now 114 ms for the whole fingerprint set).

Beyond `requirejs` (the issue), a scan of every html and script-url pattern, each run on 100 KB to 200 KB (the test now uses 200 KB with a 250 ms budget) built from its own leading literal, found 14 more that took seconds: bulma, foundation-sites, semantic-ui, materialize-css, animate-css (`<link[^>]+href="[^"]*/x.css`), plausible and fathom (`data-domain=.*plausible`), facebook-pixel, rudderstack, didomi, ensighten, yotpo (`.*` / `.+` in URLs), dynatrace-rum (`[_a-z0-9]*`), userway. All now have bounded windows (200 to 600 chars; the link patterns also require whitespace before `href`).

Where: `data/research-fingerprints.json`, the input of `scripts/generate-tech-fingerprints.ts`, is not in the repo (the last generated.ts change, #872, also edited it by hand), so the fixes are edits to `generated.ts` and to `analytics.ts` / `ads.ts`. Anyone regenerating from an extern
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.

tech-detect: the generated Imperva fingerprint only matches X-CDN: Incapsula

1 participant