Repository navigation
fix(rules): cap bad-caching validators at warn and note a Cloudflare-stripped ETag (#600) - #606
Merged
Merged
Conversation
…ders #600 detectCdnFromHeaders takes a Headers or the header map rules see and asks waf-detect's header table, so Cloudflare (cf-ray, server: cloudflare, cf-cache-status) has one definition. Exported as @squirrelscan/utils/cdn. Signed-off-by: Nik Cubrilovic <[email protected]>
…stripped ETag #600 bad-caching-validators now warns instead of failing: a page with no lifetime and no validator already counts against bad-caching-freshness, which is unchanged. When the check warns and at least half of the pages missing a validator came through Cloudflare, the message adds a note that Cloudflare may drop the ETag from HTML it rewrites (Email Address Obfuscation, Automatic HTTPS Rewrites, Replace insecure JavaScript libraries, JavaScript Detections) and lists the fixes, and details carries cloudflarePages. Tests pin weak ETags as validators for identity, gzip, br and zstd, the cap, and the note thresholds. Signed-off-by: Nik Cubrilovic <[email protected]>
…coding #600 fetchPage stores ETag and Last-Modified verbatim on identity, gzip, br and zstd responses, and requests pages with a browser Accept, so an origin that drops the ETag for HTML is recorded without one. Signed-off-by: Nik Cubrilovic <[email protected]>
The rule page says the validators check never fails, that weak ETags count, how to tell with two curl requests whether Cloudflare removes the ETag, the fixes, and quotes the note template. CHANGELOG entry under Unreleased. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
marked this pull request as ready for review
October 9, 2026 12:10
|
Review of PR 606 (perf/bad-caching Cloudflare note). No (high) or (critical) findings. I read the diff and checked the wiring but did not run the tests.
Positives:
🤖 Generated with Claude Code |
This was referenced Oct 9, 2026
Closed
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #600
What changed
perf/bad-cachingno longer fails a site whose HTML lost its ETag at the edge, and it says when Cloudflare is the likely cause.New helper
@squirrelscan/utils/cdn:detectCdnFromHeaders(headers)returns"cloudflare"ornull. It takes aHeadersor the header map rules see, rehydrates throughrecordToHeaders, and callsdetectWafFromHeaders, so Cloudflare (cf-ray,server: cloudflare,cf-cache-status) still has one definition, in waf-detect's header table.bad-caching-validatorscaps atwarn. It never fails now. A page with no lifetime and no validator already counts againstbad-caching-freshness, which is unchanged (status, thresholds, message).Cloudflare note. When the validators check warns and at least half of the pages missing a validator came through Cloudflare, the message ends with:
K of them came through Cloudflare, which may drop the ETag from HTML it rewrites with Email Address Obfuscation, Automatic HTTPS Rewrites, Replace insecure JavaScript libraries or JavaScript Detections (Bot Fight Mode). Add no-transform to the HTML Cache-Control, turn those features off, or also send Last-Modifieddetails.cloudflarePagescarriesKfor JSON consumers. The note never changes a status. It sits in the message because the LLM report prints only check messages. No new stored field, no rule-cache format change.Docs:
docs/rules/perf/bad-caching.mdxsays the validators check never fails, that weak ETags count, shows twocurlcommands that tell an Accept-gated removal apart, lists the fixes (with theno-transformcaveats) and quotes the note template. CHANGELOG entry under[Unreleased].Tests
packages/rules/tests/bad-caching.test.ts: validators warn, never fail (0% and 40%);max-age=0with no validator still fails freshness; a weak ETag undermax-age=0, must-revalidatepasses both checks for identity, gzip, br and zstd; the exact note message;server: cloudflarealone; no note without Cloudflare; exactly half fires and under half does not; the denominator is missing pages, not all pages; Cloudflare pages that kept a validator do not count; a passing check (and the 60% boundary) carries no note; freshness message unchanged.packages/utils/tests/cdn.test.ts: each Cloudflare header alone, case-insensitiveserver,Headersinput, other CDNs, mixed providers, and header valuesHeaderswould reject.packages/crawler/tests/validator-headers.test.ts:fetchPagestores weak and strong ETags plus Last-Modified verbatim on identity, gzip, br and zstd responses, and an origin that drops the ETag forAccept: text/htmlis recorded without one, which pins that squirrel requests pages the way a browser does.Verification
bun teston the three files above: 50 pass.golden-baseline.test.tsonce: 6 pass.tsgo --noEmitinpackages/utils,packages/rules,packages/crawler: clean.make validateindocs/: all checks passed.squirrel audit https://docs.squirrelscan.com -m 5 --refresh --no-publish -f llmfrom source. The finding reads5/5 pages set no caching policy (no freshness lifetime and no validator); 5/5 pages lack an ETag or Last-Modified validator. 5 of them came through Cloudflare, .... The rule still reportsstatus="fail"because freshness fails, as intended.Notes
cf-rayis not in the stored response headers, so in a real audit the rule identifies Cloudflare byserver: cloudflareorcf-cache-status. Cloudflare sendsserver: cloudflareon every response we measured.x-cdn: Imperva, filed as bug(waf-detect): x-cdn: Imperva is not recognised as Imperva #604.meta.solutionis unchanged, so the private generated rule catalog does not need regenerating for this.errorCountdrops by one.Skill
No change needed to the squirrelscan agent skill. Findings link to the rule docs, and the docs carry the fix.