Repository navigation
Description
Summary
Custom request headers ([crawler] headers, -H, and the cloud setting Custom request headers) usually carry credentials: Web Bot Auth signatures, CF-Access-Client-Secret, API keys. Today squirrel sends them on the first request to any asset on the audited host or on any subdomain of it. An audit of example.com sends them to cdn.example.com, help.example.com, user-content.example.com, or any other subdomain a page's assets point at. That covers scripts, preloaded chunks, stylesheets, images, fonts, PDFs, and web app manifests and their icons. The docs describe this behaviour (docs/configuration/crawler.mdx, headers: "assets on the audited host and its subdomains"). It dates from custom request headers (#25), which applied them to asset fetches as well as pages.
A subdomain is not always run by the same party. It can be hosted user content, a SaaS CNAME (status page, help desk, a shop on a subdomain), or a dangling CNAME that someone else has claimed. Each of these gets the audit's credentials.
On a redirect that changes origin, safeRedirectFetch already drops every header that is not allowlisted. The gap is the first request. The third-party status checks (reliability/broken-resources) never carry the headers, so they are fine.
Where this happens on main (527d4f8):
packages/audit-engine/src/adapter.ts:1035-1038and:1048-1050:resourceCheckOptionsandscriptFetchOptionscarrycustomHeaders. The CSS, image, font, PDF, sitemap, manifest and icon pools use the first; the script and preload pools use the second.adapter.ts:3588(isSameDomainResource) andpackages/parser/src/extractors/scripts.ts:53(isSameDomainScript): an asset goes into a headered pool when its host is the audited host or a subdomain of it.adapter.ts:813: manifest links go through the same check. Manifest icons are already held to the manifest's own origin (web-app-manifest.ts:134).
Found during the review of #715 (web app manifest). That PR kept the existing rule rather than making manifests the one asset kind treated differently.
Acceptance Criteria
- With a custom header set, an audit of
https://example.comrequests each asset kind onhttps://cdn.example.comwithout the custom header: script, preloaded chunk, stylesheet, image, font, PDF, web app manifest, and manifest icon. The same assets onhttps://example.comcarry it. There is a fixture test for each pool. - Only the audited origin carries the headers by default. That is the scheme, host and port of the start URL after its redirects, so an apex start URL that redirects to
wwwuseswww. Another port or scheme on the same host does not get the headers. - A user whose assets need the headers on another host (a signed CDN, Cloudflare Access on
assets.example.com) can name those hosts insquirrel.tomland with a CLI flag. Only the named hosts get the headers. Shell completions list the flag. - If a subdomain asset answers 401 or 403 to a request sent without the custom headers, it is reported as not checked, never as a broken resource. The message names the host, so the user knows which one to opt in.
- Cloud audits follow the same rule, and the cloud Custom request headers setting says which hosts receive the headers.
-
docs/configuration/crawler.mdx(headers),docs/dashboard/crawl-settings.mdxanddocs/guides/web-bot-auth.mdxdescribe the new scope and the opt-in. A CHANGELOG entry under behaviour changes says that subdomain assets no longer get the headers unless they are named.
Activity
fix(engine): custom headers go to the audited origin and named hosts …
fix(engine): probes follow redirects by hand and custom headers stay …