Skip to content

feat(rules): mobile/web-app-manifest checks the linked manifest and its icons (#710) - #715

Merged
nc9 merged 1 commit into
mainfrom
claude/710-web-app-manifest
Oct 13, 2026
Merged

nc9 merged 1 commit into
mainfrom
claude/710-web-app-manifest

Conversation

@nc9

@nc9 nc9 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the site-scope rule mobile/web-app-manifest for the web app manifest the pages link (<link rel="manifest">).

  • Engine (packages/audit-engine): the page collector records each same-site manifest link and the theme-color metas of the pages that carry it. Each manifest is fetched once through the script fetcher's caps and timeouts. Each icon the manifest declares is checked through the resource checker's image-header read, so the real pixel size comes back. The script fetcher gains an opt-in anyContentType flag so the JSON body is kept. Its default is unchanged, so script callers keep their JS-only gate.
  • Rule (packages/rules/src/mobile/web-app-manifest.ts): one check per manifest URL, listing every linking page. Its status is the worst problem, and each problem is an item. Relative start_url and icon src resolve against the manifest URL.
  • Severity mapping: error for a 4xx/5xx manifest or a body that is not a JSON object. Warn for content type, missing name/short_name/start_url/display, a cross-origin start_url, missing 192px or 512px PNG, icon 4xx/5xx, declared-vs-real size mismatch, and a theme_color that matches no linking page. Info for no maskable icon and for no linked manifest at all. Info carries no score penalty.
  • Docs: docs/rules/mobile/web-app-manifest.mdx, a card on the mobile index, and a nav entry in docs/docs.json.

Not reported here, per the issue: missing apple-touch-icon or favicon (core/favicon), and theme-color differences between pages (social/asset-divergence).

Changes from the maintainer review (2026-10-12), and from two Opus security passes on the fetch:

  • Rebased onto main after feat(rules): add reliability/broken-resources and the Reliability category #703 #714, feat(rules): add links/broken-anchors for in-page anchor links #718 and feat(rules): add security.txt and version-disclosure rules (#713) #717. Golden gate re-rolled from main: findings 101740 -> 101741 and tally rows 305 -> 306 (info: the harness's empty assets carry no manifest data), pinned; healthScore.overall stays 51.
  • meta.severity is error, so a manifest that 404s or is not JSON reports as an error; warn-only results stay warnings. Docs table updated.
  • Site-controlled text in messages (manifest URL, start_url, content type, theme_color, icon URLs, origins) is cut at 120 characters.
  • A manifest or icon answered by a rate limit (429/430, 503 with Retry-After) or a WAF challenge is not checked, never a broken icon or an error.
  • Bot findings: manifests past the first 5 are counted in a web-app-manifest-unchecked note; icons on another origin and icons past the first 20 are counted as not checked; theme_color is compared only when both sides are hex; SVG sizes: "any" behaviour documented; at most 200 icon entries are read.
  • A relative manifest link resolves against <base href> (Angular), and non-http manifest links are dropped.
  • Egress: every manifest and icon hop is held to the site's host and subdomains (new allowHost in @squirrelscan/utils/public-egress, an egress option on the script fetcher): a same-site manifest that redirects to another host is not followed there and reads as not checked; link-local and metadata addresses are refused; private addresses are allowed only for the site's own origin (new allowPrivateTarget) or a site that is itself private, so a public site's subdomain or another port that resolves privately is not fetched. Custom headers go only to the site (as for the other same-site assets). The fetch runs only while the rule is enabled.
  • Fetch budget: a refused manifest fetch is recorded as an answer (as feat(rules): add reliability/broken-resources and the Reliability category #703 #714 does for the resource checker), and a manifest-pass HTTP answer is not a tarpit strike, so refused icons or missing manifests cannot mark the audited host as tarpitting. (The address fallback for ::1-only dev servers this review also found was backported into feat(rules): add reliability/broken-resources and the Reliability category #703 #714.)
  • CHANGELOG line under [Unreleased] / ### Added.

Agent skill: yes, the squirrelscan agent skill (squirrelscan/skills) should learn the new rule; the maintainer files that as a private issue. Per-category counts (Mobile 6 -> 7) are left for the maintainer's batched docs PR.

Closes #710

Verification

bun install --frozen-lockfile
(cd packages/rules && bun test tests/web-app-manifest.test.ts tests/broken-resources.test.ts)          # 49 pass, 0 fail
(cd packages/audit-engine && bun test tests/web-app-manifest-fetch.test.ts tests/broken-resources-fixture.test.ts tests/fetch-budget.test.ts tests/undecoded-probe-fetches.test.ts tests/asset-compression-capture.test.ts tests/fetch-deadline.test.ts)  # 56 pass
(cd packages/audit-engine && bun test tests/streaming-rules-canonical-golden.test.ts)                  # 1 pass
(cd packages/audit-engine && bun test tests/streaming-rules-golden.test.ts tests/streaming-pre-rules-golden.test.ts tests/resource-checker-416.test.ts tests/resource-checker-image-header.test.ts)  # 29 pass
(cd packages/utils && bun test tests/public-egress.test.ts tests/non-public-host.test.ts tests/url.test.ts)  # pass
(cd apps/cli && bun test tests/crawler/fetch-deadline.test.ts tests/crawler/script-fetcher-encoding.test.ts tests/crawler/undecoded-fetches.test.ts)  # 16 pass
tsgo --noEmit: utils, rules, audit-engine                                                              # clean
(cd docs && bun run check)                                                                             # tangly check --strict: all checks passed
detect-secrets-hook over the PR files                                                                  # clean

The new rule, engine and test files are oxfmt- and oxlint-clean (the packages have no format or lint script of their own).

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Acceptance checklist (#710)

  • Fixture: a page linking /site.webmanifest that returns 404 produces an error finding naming the manifest URL and the linking pages (rule test; engine test confirms the 404 status is kept)
  • Fixture: a manifest whose body is not valid JSON (or is an HTML page served with 200) produces an error finding (rule test)
  • Fixture: a valid manifest served as text/plain produces a content-type warning; application/manifest+json does not (rule test)
  • Fixture: missing name and short_name, missing start_url, and missing display each produce a warning naming the field (rule test)
  • Fixture: a manifest with no 512px PNG icon produces a warning; one with 192px and 512px PNG icons does not (rule test)
  • Fixture: an icon declared 512x512 whose file is 256x256 produces a warning showing both sizes; a 404 icon produces a warning naming its URL (rule test and engine test with a real 256px header)
  • Icon src and start_url are resolved against the manifest URL (helper test; engine test fetches /static/icon.png from "src": "icon.png" in /static/m.json)
  • Fixture: theme-color #000 with manifest #fff produces a warning; a light/dark pair where one matches does not (rule test)
  • A manifest with no maskable icon produces an info result, not a warning (rule test)
  • A site with no <link rel="manifest"> produces one info result and no score penalty (rule test for the info result; no penalty because packages/audit-engine/src/scoring.ts skips info and skipped checks, verified by reading the code, not by an end-to-end score run)
  • Ten pages linking the same manifest produce one finding listing those pages, and the manifest is fetched once (rule test; engine test counts one request across ten pages; collector test)
  • A missing apple-touch-icon is not reported by this rule (the rule never reads it)
  • The rule has a docs page under docs/rules/mobile/

Known limits, not blocking:

  • The manifest body is fetched through the script fetcher, which has no content cache, so the cache-reuse part of "caps, timeouts and cache apply" covers the icons only.
  • Behind an HTTP_PROXY, a pinned plain-http request may reach the proxy's default vhost (documented in the egress guard).
  • Icons resolve against the requested manifest URL, not the post-redirect URL.
  • The streaming site-data path is wired but not exercised end to end. The rule tests use hand-built manifest data; the engine tests use a local server, not HTML fixture files.

@claude

claude Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewed the diff only: I did not run the tests or typecheck. The design is sound. Each manifest is fetched once, fetching is bounded by WEB_APP_MANIFEST_FETCH_LIMIT and the icon cap, and the new anyContentType flag is opt-in. Findings:

  • (medium) packages/audit-engine/src/web-app-manifest.ts, fetchWebAppManifests: manifest links beyond the first 5 (sorted by URL) are dropped silently, so the rule can report 'valid' with no sign that others went unchecked. Consider an info item or a count when occurrences.size > WEB_APP_MANIFEST_FETCH_LIMIT.
  • (medium) web-app-manifest.ts: the same-site gate for the manifest is host-based (isSameDomainResource), but the fetch follows redirects through the script fetcher. I could not check whether it re-validates the redirect target. If it does not, a same-site manifest URL can redirect off-site, which breaks the 'never requested' claim in the module header and the docs. A test with a cross-host redirect would settle it.
  • (low) web-app-manifest.ts: icons on another origin, for example a CDN, are silently dropped from the fetch. The rule then skips size and status checks for them (if (!check) continue), and users get no indication. The docs mention the same-site limit, but the check output could say 'N icons not checked (other origin)'.
  • (low) packages/rules/src/mobile/web-app-manifest.ts: the manifest's own theme_color is compared as a plain string after hex-3 expansion. Equivalent forms such as rgb(), named colours, or a #rrggbbaa value with full alpha will false-warn. The mismatch is only a warning, but it is worth a note in the docs or a looser comparison.
  • (low) Rule: the 192/512 check keys on exact WxH strings from sizes and PNG-ness from type or the .png extension. An icon with a query string such as icon.png?v=2 is handled because the check uses pathname, but sizes: "any" SVG-only manifests will warn. That is arguably correct, but the docs should say so.
  • (low) readIcons is called in the rule and again in listWebAppManifestIconUrls, so the manifest is parsed twice per run. This is negligible for the sizes involved.
  • (nit) Mixed status vocabulary: worstStatus ranks fail, while the docs and PR text say 'error'. The two are consistent in the output, but one term would read better.
  • (nit) startUrl origin comparison: new URL(resolved).origin is computed three times. A local variable would be cleaner.
  • (nit) Test coverage: the rule tests (15) and the fetch tests (6) look good. Missing cases are an HTML 200 body in the fetch-level test, a manifest that exceeds the size cap (content null and the 'not checked' info path), and the over-limit manifest drop noted above.

I found no critical or high-severity issues.

@nc9

nc9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer review (2026-10-12)

Verdict: needs fixes (medium). I reviewed head b1f4a1f against main at 2dca3b9. Main CI is green at that sha, so the red checks come from this PR.

Acceptance criteria (#710)

11 of 13 are met, by packages/rules/tests/web-app-manifest.test.ts and packages/audit-engine/tests/web-app-manifest-fetch.test.ts.

AC1 and AC2 are only partly met. The check status is fail, but the report shows the finding as a warning, not an error. Fix 2 covers this.

Fixes

  1. The golden gate fails in both "Audit engine golden tests" and "CLI tests". The CLI job's apps/cli tests step passes. The job fails because its "Audit engine tests" step runs the golden file again.
    • File: packages/audit-engine/tests/streaming-rules-canonical-golden.test.ts.
    • expect(v1.findings.length).toBe(101736); (line 154): CI received 101737. mobile/web-app-manifest is site-scoped and adds one whole-crawl check. Raise the number by 1 and add a comment line in the existing style, for example // 101736 -> 101737: mobile/web-app-manifest is site-scoped and adds one whole-crawl check (#710). <its status on the fixture>.
    • expect(v1.perRuleTally.length).toBe(301); (line 176) fails next. Raise it by 1 and extend the tripwire comment.
    • Both numbers are relative to the main you rebase on. Other rule PRs edit the same two lines, so rebase and re-read them after each merge.
    • Verify with cd packages/audit-engine && bun test tests/streaming-rules-canonical-golden.test.ts. healthScore.overall must stay 51, or the comment must explain the change.
  2. Severity. Set meta.severity: "error"; it is currently "warning".
    • Around L391 of packages/report/src/grouping.ts, a rule's meta severity applies whenever one of its checks fails. That is why a manifest that returns 404 or isn't valid JSON is reported as a warning, when New rule: web app manifest (missing fields, broken icons, theme-color mismatch) #710 requires an error.
    • A rule whose checks only warn is downgraded to "warning" automatically, so nothing else changes.
    • Update the severity line and the table in the docs page.
  3. Rebase after feat(rules): add reliability/broken-resources and the Reliability category #703 #714 merges. packages/audit-engine/src/adapter.ts conflicts with it in these places:
    • PreFetchedAssets
    • SiteAssetOccurrences
    • emptySiteAssetOccurrences
    • the Effect.all record
    • the timeout fallback object
    • both assets destructures
  4. Site-controlled strings in messages. These go into messages raw and unbounded. Cap each at about 120 characters, and use canonical URLs where you can:
    • "start_url" ${startUrl} is not a valid URL, which is raw manifest text
    • served as ${type}, which is a raw header
    • theme_color ${themeColor}
  5. Icon status. A 429, a 503 with Retry-After, or a WAF 403 is reported as a broken icon today.
  6. Open findings from the review bot:
    • Medium: manifests after the first 5 are dropped without a word. Add a count or an info item.
    • Medium: confirm that a same-site manifest which redirects off-site is never fetched from the other host, or say so in the docs.
    • Low: icons on another origin are not checked and nothing says so. Add "N icons on another origin not checked".
    • Low: theme_color is compared as a plain string, so rgb() or named colours warn falsely. Loosen the comparison or document it.
    • Low: manifests whose icons are all SVG with sizes: "any" get a warning. Document this.
    • Nit: readIcons parses each manifest twice.

PR hygiene

  • CHANGELOG: add one line under ## [Unreleased] / ### Added, ending with squirrelscan/squirrelscan#710.
  • PR description: add a line saying whether the squirrelscan agent skill (squirrelscan/skills) needs a change.
  • Attribution:
    • Remove the Co-Authored-By: and Claude-Session: trailers from the commit, keeping Signed-off-by:.
    • Remove the "Generated with Claude Code" footers and the session URL from the PR body.
    • No attribution lines of any kind go in commit or PR text.
  • Docs: quote message templates with placeholders, never filled examples. No em-dashes.
  • Rule counts: leave the per-category counts in the README and docs tables (Mobile 6 to 7). The maintainer will update them in one docs PR after these rule PRs merge.

Merge order

This PR merges after #714, #718 and #717.

@github-actions

Copy link
Copy Markdown
Contributor

Auto-review did not complete

The claude-review job failed before posting a review. This PR has not been auto-reviewed. Run a review manually (/review) before merging.

  • Result: success / is_error=true after 1 turns, 0 permission denial(s), $0.00
  • Job log

Partial findings recovered from the session (incomplete, unverified, and NOT a merge signal):

Show partial review

You've hit your session limit · resets 10:10pm (UTC)

…ts icons #710

A site-scope rule for the web app manifest the pages link. The engine
fetches each same-site manifest once, through the script fetcher's caps
and timeouts, and checks each icon it declares with the resource
checker's image header read. The rule judges the result:

- error when the manifest answers 4xx/5xx or is not a JSON object (meta
  severity error, so the report shows it as one; warn-only results stay
  warnings)
- warn on a content type other than application/manifest+json or
  application/json, on missing name/short_name, start_url or display,
  on a start_url on another origin, on no 192px or 512px PNG icon, on
  an icon that answers 4xx/5xx, on a declared size that differs from
  the real one, and on a hex theme_color that matches no linking page's
  hex theme-color (rgb(), hsl() and named colours are not compared)
- info, not checked, when the manifest or an icon was throttled or
  answered by a WAF challenge, or redirects off the site; info counting
  icons on another origin, manifests past the per-site cap of 5, no
  maskable icon, and no linked manifest

Every manifest and icon hop is held to the site's host and subdomains by an
egress policy (new `allowHost` in @squirrelscan/utils/public-egress, and an
`egress` option on the script fetcher): a same-site manifest that redirects
elsewhere is not followed there, link-local and metadata addresses are
refused, and private addresses are allowed only for the site's own origin
(new `allowPrivateTarget`) or a site that is itself private: a public site's
subdomain, or another port on its host, that resolves privately is not fetched. The fetch runs only while the rule is enabled. Site-controlled text
in messages is cut at 120 characters; at most 200 icon entries are read.
A relative manifest link resolves against `<base href>`.

A refused manifest fetch is recorded in the fetch budget as an answer (as
tarpit strike, so refused icons or missing manifests cannot mark the audited
host as tarpitting.

Relative start_url and icon src resolve against the manifest URL. One
check per manifest URL, listing every page that links it. The script
fetcher gains an opt-in anyContentType flag so the JSON body is kept; its
default is unchanged.

Docs page under docs/rules/mobile/ and a nav entry.

Golden gate: +1 finding and +1 tally row (info: the harness's empty assets
carry no manifest data); healthScore.overall stays 51.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the claude/710-web-app-manifest branch from d706a29 to 3804a59 Compare October 13, 2026 00:44
@claude

claude Bot commented Oct 13, 2026

Copy link
Copy Markdown

Review of #715 (mobile/web-app-manifest). I read the engine changes (web-app-manifest.ts, script-fetcher.ts, the adapter.ts wiring). I did not read the rule file, the docs or the tests in detail, and I did not run the test suite.

The design is sound:

  • Fetches are same-site only, and every hop goes through the egress policy.
  • Manifests are capped at 5 per site and icons are bounded.
  • anyContentType is opt-in, so existing script callers keep their JS-only gate.
  • 429/WAF answers are not reported as broken.
  • An egress refusal is not retried and does not strike the fetch budget.

Findings:

  • (low) adapter.ts ~L1205: the manifest fetch reuses resourceCheckOptions, so customHeaders (Web Bot Auth or auth tokens from config.crawler.headers) are sent on the first request to any same-site subdomain, because allowHost accepts *.baseHost. The external probes strip customHeaders for this reason. Existing same-domain asset fetches may already behave this way. If so, this is consistent and fine. If not, send headers only when the URL's origin equals siteOrigin.
  • (nit) web-app-manifest.ts:141: icon.startsWith("http") followed by new URL(icon) is fine given listWebAppManifestIconUrls resolves URLs. Using /^https?:/ would match the check in absorbWebAppManifestLinks.
  • (nit) web-app-manifest.ts:15: the module header comment has one overlong line.
  • (nit) absorbWebAppManifestLinks runs two querySelectorAll passes per page for every page. This is cheap, but you could skip the meta pass entirely when there is no manifest link. It already returns early, so this is just confirming that.

No blocking issues found.

@nc9

nc9 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

On the review's low finding (custom headers reaching a same-site subdomain): the manifest and icon fetches send them no further than main's asset fetches already do. Redirects are handled more strictly. Code on main is at 7d772c1, and this PR's code is at 3804a59.

Main already sends custom headers to subdomain assets.

So on main, <script src="https://cdn.example.com/app.js"> on example.com already gets the custom headers on its first request.

What this PR adds, compared with that:

  • Manifest URLs: they are admitted by the same isSameDomainResource call (adapter.ts:810-815), so the set of hosts that get headers does not grow.
  • Icons: this is narrower than main's asset pools. An icon is fetched only on the manifest's own origin, never on another subdomain (web-app-manifest.ts:134-142).
  • Redirects: this is stricter than main's asset pools.
    • allowHost refuses any hop that leaves the site's host and subdomains (adapter.ts:1212-1223), so the request is never sent.
    • Main's pools follow such a redirect, after stripping headers.
    • On any change of origin, including one subdomain to another, safeRedirectFetch drops every header that is not allowlisted, custom headers included (safe-fetch.ts:48-52).

Limiting custom headers to the exact origin only for manifests and icons would make them the one asset kind treated differently from scripts, CSS, images and fonts. If the policy should be exact-origin, it needs one change across every asset pool, which is a behaviour change to #494 and should be its own issue. I'm leaving this PR as is.

@nc9
nc9 merged commit 527d4f8 into main Oct 13, 2026
15 checks passed
@nc9
nc9 deleted the claude/710-web-app-manifest branch October 13, 2026 02:15
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.

New rule: web app manifest (missing fields, broken icons, theme-color mismatch)

1 participant