Repository navigation
fix(waf-detect): read vendor cookie names, name a bot vendor over its CDN, stop calling CloudFront AWS WAF #750 - #751
Conversation
… CDN, stop calling CloudFront AWS WAF #750 - Cookie names (values never read) identify Cloudflare, DataDome, HUMAN, Kasada, Akamai Bot Manager, Imperva and AWS WAF; a block page that sets only the cookie is fingerprinted. - Every source (headers, cookies, body) is read and the most specific provider wins (PROVIDER_PRECEDENCE): DataDome behind Cloudflare is DataDome. Results carry `providers`, every provider with a signal; utils/cdn reads it, so a DataDome block still came through Cloudflare. - AWS WAF is its x-amzn-waf-action header, aws-waf-token cookie, token-host challenge script, or CloudFront's 'Request blocked' page (a Block action is a plain 403); not CloudFront / API Gateway / Lambda headers alone, so an S3 AccessDenied on CloudFront is not a WAF. - Kasada's x-kpsdk-* response headers count. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the diff:
Test coverage is good: cookie fingerprints, stacking, the AWS cases, a ReDoS timing check and a names-only assertion. The 50ms timing assertion could be flaky on loaded CI, so consider a looser bound. |
…a block #750 - isLikelyWafBlock reads headers and body only: Bot Manager, Imperva and Cloudflare set their cookies on every response of a protected site, so a genuine forbidden 403 there carries them too. Cookie attribution is medium. - The AWS WAF token-host pattern is anchored at a script src (CodeQL js/regex/missing-regexp-anchor; also linear). - Test that every WafProvider has a place in PROVIDER_PRECEDENCE; looser timing bound; single indexOf. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Triage of the review and the CodeQL alert on cc282d0, fixed in 5ec129c:
Tests: waf-detect 85 pass; CLI waf, adapter-waf and cloud-fetcher 82 pass; audit-engine waf, tech, soft-404 and broken-resources suites 46 pass; utils cdn 8 pass. |
|
Reviewed the diff. The approach is sound: cookie names only, no values; attribution by precedence;
|
|
Triage of the review on 5ec129c (all checks green). No change pushed, so CI does not run again:
|
Closes #750.
@squirrelscan/waf-detectnow names bot-protection vendors more accurately, for the CLI's bot-protection warning, the WAF technology entry and the external link check.Changes
Cookie names.
COOKIE_PATTERNScovers the vendors below. Values are never read:cookieNamesFromHeaderskeeps names only, viaHeaders.getSetCookie(). A response that sets only the vendor cookie is fingerprinted.__cf_bm,cf_clearance,__cflb,_cfuviddatadome_px3,_pxvid,_pxhd, ...KP_UIDz_abck,ak_bmsc,bm_sz,bm_svincap_ses_*,visid_incap_*,nlbi_*,reese84aws-waf-tokendetectWafFromCookies(names)serves callers that stored names only.Stacked vendors. Headers, cookies and body are all read, and the most specific provider wins (
PROVIDER_PRECEDENCE: bot vendors before the CDN they sit behind, Cloudflare last). A DataDome block served through Cloudflare is DataDome.providers: every provider with a signal, most specific first.utils/cdn.tsreadsproviders.includes("cloudflare"), so "came through Cloudflare" is unchanged.AWS. AWS WAF is now its
x-amzn-waf-actionheader, itsaws-waf-tokencookie, its*.token.awswaf.comchallenge script, or CloudFront's "Request blocked." error page (a Block action is a plain 403 with no WAF header).x-amz-cf-id,x-amzn-requestid,x-amz-apigw-id) no longer count. An S3 AccessDenied 403 on CloudFront is a real missing object, not a WAF.Kasada. The
x-kpsdk-*response headers count.Behaviour changes to know
detectWaf(headers, body)now always reads the body when given one. Before, it returned early on any high-confidence header. Only callers that pass a body see a difference, and for them the provider is more specific._px*cookies now showswaf-datadome(orwaf-perimeterx) instead ofwaf-cloudflarein the WAF technology entry. Cloudflare still appears as a CDN from tech detection.recordToHeaders) carryset-cookieas one joined string, so only the first cookie name is read there. That is a gap, not a false positive.Tests
packages/waf-detect/tests/cookies-and-stacking.test.ts:apps/cli/tests/utils/waf.test.ts(the AWS cases) andpackages/utils/tests/cdn.test.ts(Cloudflare is still the CDN under DataDome).CHANGELOG entry under Unreleased → Fixed. Docs: no page lists the detection signals (
external-links.mdxsays "Cloudflare, Akamai, etc."), so no docs change.Skills: no squirrelscan agent skill change needed.
Pairs with squirrelscan/repo#2790 (Perch records the vendor per host and URL). The private repo picks this up with its next gitlink bump.