Skip to content

feat(rules): name Cloudflare JavaScript Detections in the perf/bad-caching ETag note #605

Closed

Description

@nc9

Background

#600 adds a note to perf/bad-caching when most pages missing an ETag or Last-Modified came through Cloudflare. The note is headers-only: it says Cloudflare may have removed the ETag, because the rule cannot tell which rewriting feature, if any, was on.

Cloudflare JavaScript Detections is documented to "strip ETags from HTML responses where JSD is injected" (docs), and Bot Fight Mode turns it on. It is the one ETag-removing feature that leaves a reliable marker in the page, but the marker is an inline script referencing /cdn-cgi/challenge-platform/ (the CF_CHALLENGE pattern in packages/utils/src/fingerprint.ts already matches it). Inline scripts are not in the collected scriptSrcs the streaming engine hands site rules, so the rule cannot see it today.

What it would take

  • A new collected per-page signal (for example edgeMarkers: string[]), computed once per page from the DOM by a shared helper in @squirrelscan/utils/cdn, reusing the existing pattern. No regex over unbounded raw HTML.
  • That changes the rule-cache format, so the first audit of each site after the upgrade runs every rule fresh, once. Say so in the CHANGELOG.
  • perf/bad-caching then names JavaScript Detections in its note when the Cloudflare pages missing a validator carry the marker.

Worth doing only if reports show the headers-only note is not enough for users to find the cause.

Acceptance Criteria

  • When at least half of the pages missing a validator are behind Cloudflare and carry the JavaScript Detections inline script, the bad-caching-validators note says JavaScript Detections was found on those pages
  • Pages behind Cloudflare without the marker keep the current headers-only note
  • The marker is detected the same way on the streaming engine and the v1 engine (squirrel analyze)
  • A page that only mentions /cdn-cgi/challenge-platform/ in visible text, not in a script, does not count
  • Detection stays linear on a large adversarial page (a test with a 1 MB page finishes in under 100 ms)
  • The CHANGELOG states the rule-cache format change, and docs/rules/perf/bad-caching.mdx describes the new note

Activity

  1. added
    enhancement
    P3
    size: M
    rules
    on Oct 9, 2026
  2. nc9 commented on Oct 11, 2026

    @nc9
    ContributorAuthor

    Checked on 0.0.108 with local fixtures on a public host name, three pages sent with Server: cloudflare and CF-RAY, no ETag or Last-Modified:

    • Pages over 10 KB with the JavaScript Detections inline script (/cdn-cgi/challenge-platform/scripts/jsd/main.js) near the end, and pages without it, get the same headers-only note on bad-caching-validators: 3/3 pages lack an ETag or Last-Modified validator. 3 of them came through Cloudflare, which may drop the ETag .... So the current behaviour in the issue is accurate.
    • Small pages (under 10 KB) carrying the same inline script get no note at all. They are classified as WAF challenge pages, Detected 3 challenge/interstitial page(s) via Cloudflare; these pages were excluded from page-level rule scoring., because challenge-platform in the first 10 KB plus a Cloudflare server header counts as a challenge interstitial (packages/waf-detect/src/challenge.ts and CHALLENGE_INTERSTITIAL_PATTERNS in packages/waf-detect/src/providers.ts). Any marker detection for this issue has to agree with that classifier.

    origin/main is unchanged in packages/rules/src/performance/bad-caching.ts and in the waf-detect files above.

  3. added theissue type on Oct 28, 2026
  4. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    Shipped in v0.0.145 (533fd7f2 c3506213), verified against main: every acceptance criterion is met. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145

    nik

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

    P3enhancementrulessize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions