Skip to content

fix(engine): local link checks list walls and timeouts as unverified, not broken #800 - #804

Merged
nc9 merged 5 commits into
mainfrom
feat/local-link-checks-unverified
Oct 15, 2026
Merged

nc9 merged 5 commits into
mainfrom
feat/local-link-checks-unverified

Conversation

@nc9

@nc9 nc9 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #800.

A link checked from your own machine that meets a wall is now unverifiable, not broken. That covers a logged-out audit, and a link the cloud checker did not answer in time. Before this, a logged-out audit's broken external link list was mostly links that work in a browser.

What changes

Engine (external-checker.ts). These local answers come back wafBlocked and keep their status. They name a vendor when detectWaf finds one, and say unknown when it doesn't:

  • 401, 403, 405, 406 and LinkedIn's 999, whether or not a firewall can be named. Before, a bare 403 and all the others counted as broken.
  • A 503 that is a challenge page: cf-mitigated: challenge, or what detectWafChallengePage reads as one. A plain 503 stays broken, and a 503 with Retry-After stays rate limited.
  • A timeout. It has no status and no error, and it is not cached, so the next audit asks again.

The site's own refusals stay broken:

  • an object store's 403 for a key it will not list, which is how a deleted download answers:
    • by its headers: S3 x-amz-request-id or server: AmazonS3, GCS x-guploader-uploadid;
    • or by its XML error body (<Code>AccessDenied|NoSuchKey</Code>), for CloudFront in front of S3 with the headers stripped. The CDN's own HTML block page is still a wall.
  • an HTTP authentication prompt: WWW-Authenticate naming Basic, Digest, Negotiate or NTLM, anywhere in the header;
  • a 405 whose Allow header leaves out GET.

Cache handling:

  • Unverifiable verdicts are never cached, local walls, timeouts and the cloud bulk checker's unverifiable answers alike. The next run asks again, and a signed-in run asks the cloud link checker, as the notice promises.
  • A cached 401, 403, 405, 406, 999 or timeout written before 2026-11-16 was stored as broken by an older client, so it is checked again. A wall status cached after that date is a real answer (a cloud-confirmed broken 403, say) and is used as it is.
  • Stale-wall behaviour before 2026-11-16, accepted:
    • Until that date, every cached entry with a wall status counts as stale and is asked again on each run: a site's own refusal (S3 403, HTTP auth), a cloud-confirmed broken 403, a legacy-backend 403. That costs requests, not correctness. A local wall is no longer cached, so it can never overwrite the cloud's entry.
    • One visible effect: a signed-out run before 11-16 re-checks a cloud-confirmed broken 403 locally and shows it as unverifiable.
    • The cutoff assumes this release ships well before 11-16. An entry an older client writes after that date is trusted until its TTL ends, 7 days by default.
  • A real answer in the cache (404, 200 and so on) is still used as it is.

Rules. links/broken-external-links and links/dead-links now exempt any wafBlocked link, not only a 403. Those links are listed under waf-blocked-external-links ("status unverifiable"), the same list the cloud link checker's unverifiable links already go into.

CLI. A signed-out audit with unverifiable external links prints this once after the audit:

⚠ 5 external links could not be verified from this machine (bot protection or a timeout), so they are listed as unverified, not broken. Sign in with squirrel auth login to check them with squirrelscan's cloud link checker.

A saved account the audit could not use this run (too few credits, a spend cap below the minimum, an outage) gets "An audit that can use the cloud (signed in, with enough credits) checks them…" instead. A signed-in audit, or one with no such links, prints nothing.

Still broken: 404, 410, a plain 5xx, a domain that does not exist, a refused connection, an invalid certificate.

Docs and CHANGELOG. rules/links/broken-external-links and rules/links/dead-links say which local answers are unverifiable. CHANGELOG has an entry under Changed.

Tests

  • packages/audit-engine/tests/local-link-walls-800.test.ts (12), against real local servers. After the rebase onto pub#802, the link cache is only used under a public-only policy, so the cache cases go through the bulk checker and cached answers rather than the loopback server. One cacheableVerdict() now decides both cache writes. A raw socket serves the 999. It covers:
    • every wall status, and a named vendor;
    • a 503 challenge versus a plain 503, and a Retry-After 503 that stays rate limited;
    • a timeout that is unverifiable;
    • an object store's 403 (by headers, and by XML body behind a CDN), a Basic-auth 401, a Bearer, NTLM 401 and a POST-only 405 staying broken, while the CDN's HTML block page stays a wall;
    • a HEAD 405 followed by a GET 404 being a 404;
    • 404, 410, 500 and a refused connection staying broken;
    • walls, timeouts and the bulk checker's unverifiable answers never being written to the cache;
    • stale cached walls and timeouts being asked again, a wall cached after the cutoff being used as it is, and a cached 404 being kept.
  • Timeouts are 2 s in every test except the stall, so a loaded machine can't turn a prompt answer into a timeout.
  • packages/rules/tests/local-link-walls-800.test.ts (3): both rules list walls and timeouts as unverifiable and count only the 404.
  • apps/cli/tests/audit/local-link-notice-800.test.ts (3): the notice, its singular, the variant for an account that couldn't be used, and no notice when signed in or when nothing is unverified.
  • fetch-deadline.test.ts: a 403 whose body stalls is now unverifiable. That test pinned the old "plain 403 = broken" ambiguity.

Review

  • Opus delta (41840a2..d787dbe): safe to merge, no HIGH or MEDIUM. Its two LOWs are fixed in d0480bb: the S3 XML error body behind a CDN, and HTTP auth schemes anywhere in the header.

  • Opus round 1 (2b7c1d4..41840a2). Fixed in d787dbe:

    • HIGH: local walls and the bulk checker's unverifiable answers were cached for 7 days, so the next signed-in run never reached the cloud;
    • MEDIUM: stale-verdict provenance, now a cutoff date;
    • MEDIUM: a missing object's 403 from an object store hid as unverifiable;
    • LOW: HTTP auth and POST-only 405s, test flake risk, missing tests, and notice and docs wording.
  • Kept as they are:

    • the rule's description and its blocked by WAF message. The private rule catalog quotes them, so a change there would ride every gitlink bump for a wording nit.
    • A host that never completes the TCP handshake stays unverifiable, the same as the cloud checker's "unreachable", and may be worth a later connect probe.

Gates

  • tsgo: clean for apps/cli, packages/rules and packages/audit-engine.
  • oxlint and oxfmt: clean on the changed CLI files.
  • detect-secrets: clean on the changed files.
  • Docs: tangly check --strict passes.
  • Existing tests, all green:
    • engine external-checker: fetch-deadline, 766, 2759 ×2, 770, 753, undecoded probes, link-checks-not-run e2e, refused-fetches e2e, broken-resources, link-probe-safety, 726 e2e, streaming-pre-rules golden, asset-egress, site-query link rules golden;
    • rules: rate-limited-links, link-checks-not-run, 2759, dead-links, fold;
    • CLI: adapter-waf, dead-links-unanswered-753, cloud-spend.
  • golden-baseline: its determinism case timed out once under machine load and passes on its own (46 s). It doesn't read external links.
  • Smoke: bun run src/cli.ts audit <localhost fixture> --external-links, signed out with a throwaway HOME. The fixture links to 401, 403, 405, 406, 404, 410, 200 and one stalled link. Result: 5 unverifiable, 2 broken external link(s): 1 with 404, 1 with 410, and the notice printed once.

Agent skill (squirrelscan/skills): no change needed. The report's rule ids and check names are unchanged.

nc9 added a commit that referenced this pull request Oct 15, 2026
…5 stay broken #800

Review round 1 on #804: walls and timeouts, local or from the cloud bulk
checker, are not cached, so a signed-in run asks the cloud next time. An
object store's 403 (S3, GCS), an HTTP auth prompt and a 405 that allows no
GET stay broken. Stale wall verdicts are re-checked only when cached before
2026-11-16. Tests: Retry-After 503, HEAD 405/GET 404, cache cases, 2 s
timeouts except the stall. Notice and docs wording.

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added a commit that referenced this pull request Oct 15, 2026
…te's own refusal #800

Delta review on #804: CloudFront in front of S3 can strip S3's headers, so
a 403 whose body is <Code>AccessDenied|NoSuchKey</Code> stays broken; a
401 naming Basic, Digest, Negotiate or NTLM anywhere in WWW-Authenticate
stays broken. The CDN's own HTML block page is still a wall.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 marked this pull request as ready for review October 15, 2026 06:35
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review of #804. I read the diff and the surrounding rule code but did not run the test suite.

The change is coherent and matches the description. Walls and timeouts are now unverifiable and are never cached. The realRefusal carve-outs for S3/GCS, HTTP auth and 405 with an Allow header are sensible. No blocking issues found.

  • (medium) external-checker.ts (BOT_WALL_STATUSES handling): every 401/403/405/406/999 is now unverifiable, including ones from a plain origin with no WAF. A genuinely removed page behind an auth-ish 403 is therefore never reported as broken from a logged-out audit. The PR documents this trade-off, but it is a recall loss. Consider keeping the "unknown" provider distinguishable in the report so users can triage these.
  • (medium) external-checker.ts (WALL_VERDICT_CUTOFF_MS): the hard-coded 2026-11-16 date depends on the release shipping before then. Today is 2026-10-15, so until the cutoff every cached wall entry is re-checked on every run, which costs requests. After the cutoff, a pre-fix client that writes an entry is trusted for its full TTL. Please add a TODO or issue to remove the constant, and a test with a fake clock on both sides of the cutoff if one is not already there.
  • (low) broken-external-links.ts:298: timeouts now land in the waf-blocked-external-links check, whose message reads "blocked by WAF" and whose label shows "(unknown)". For a timeout or a bare 403 this is misleading. Use wording like "unverifiable (bot wall or timeout)".
  • (low) dead-links.ts: a timeout now has status: null and error: null, so it is dropped from checked. It is not counted as checked and not listed as unverifiable by this rule. Confirm that is intended, since the broken-external-links rule does list it.
  • (low) external-checker.ts: the 503 challenge path builds a detectWafChallengePage input by hand, and html is null when the body read failed. That is fine, but a test for a 503 with a failed body read would pin the behaviour.
  • (nit) The XML-body check /<Code>(?:AccessDenied|NoSuchKey)<\/Code>/ is case-sensitive and could be tightened, but it is fine for S3.

Test coverage is good: engine, rule and CLI notice tests were added.

nc9 added 5 commits October 15, 2026 17:48
… not broken #800

A link checked from the user's machine that answers 401, 403 (vendor named
or not), 405, 406, LinkedIn's 999 or a 503 challenge page, or runs out of
time, is unverifiable: listed under waf-blocked-external-links, never broken.
404, 410, a plain 503, a refused connection stay broken. Timeouts are not
cached; a cached wall or timeout from before is asked again. Both link rules
exempt any wafBlocked link, not only a 403. A signed-out audit with
unverified links prints a notice pointing at sign-in.

Signed-off-by: Nik Cubrilovic <[email protected]>
…5 stay broken #800

Review round 1 on #804: walls and timeouts, local or from the cloud bulk
checker, are not cached, so a signed-in run asks the cloud next time. An
object store's 403 (S3, GCS), an HTTP auth prompt and a 405 that allows no
GET stay broken. Stale wall verdicts are re-checked only when cached before
2026-11-16. Tests: Retry-After 503, HEAD 405/GET 404, cache cases, 2 s
timeouts except the stall. Notice and docs wording.

Signed-off-by: Nik Cubrilovic <[email protected]>
…te's own refusal #800

Delta review on #804: CloudFront in front of S3 can strip S3's headers, so
a 403 whose body is <Code>AccessDenied|NoSuchKey</Code> stays broken; a
401 naming Basic, Digest, Negotiate or NTLM anywhere in WWW-Authenticate
stays broken. The CDN's own HTML block page is still a wall.

Signed-off-by: Nik Cubrilovic <[email protected]>
…ache #800

After the rebase onto pub#802 the link cache is used only under a
public-only egress policy, so the cache tests use the bulk checker and
cached answers, not the loopback server. One cacheableVerdict() decides both
cache writes (throttled, refused and unverifiable verdicts are never cached).

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/local-link-checks-unverified branch from d0480bb to 63536b1 Compare October 15, 2026 06:50
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review of PR 804 (pub#800: walls and timeouts listed as unverifiable, not broken). I read the diff and traced wafBlocked through the rules. I did not run the tests.

  • (medium) packages/audit-engine/src/external-checker.ts (AbortError branch): a timeout now returns wafBlocked: true with provider "unknown". The flag now means "unverifiable", which covers more than a WAF. The rule still labels these items (unknown) under "blocked by WAF - status unverifiable" (broken-external-links.ts ~L298). A user will see "blocked by WAF" for a link that simply timed out. I'd either add a separate reason field, or reword the message and label (for example "unverifiable (bot wall or timeout)"). Other wafBlocked consumers (adapter.ts, cloud.ts, the sqlite storage) may also assume a WAF, so check them.
  • (medium) external-checker.ts, the 503 path: when the challenge check fails, the code falls through to the old handling. A plain 503 stays broken, which matches the stated intent. But detectWafChallengePage is passed only server, cf-cache-status and x-cache. That is a narrow header set, so detection of non-Cloudflare 503 challenge pages relies mostly on the body. A test with a real challenge body at 503 and without cf-mitigated would make that visible.
  • (low) external-checker.ts, realRefusal: the S3 and GCS checks treat any 403 carrying x-amz-request-id as a real refusal. Some AWS-fronted services (API Gateway, WAF on CloudFront) also emit that header on bot blocks. This is conservative, since the link stays broken, so it could cause false positives. Worth a comment saying the tradeoff is deliberate.
  • (low) external-checker.ts, WALL_VERDICT_CUTOFF_MS: this is a hardcoded date (2026-11-16) that nothing will remove later. Please add a TODO or issue reference to delete it. After the cutoff, a legitimately cached 403 or timeout from an old client is trusted again.
  • (low) The bulk path now skips caching all wafBlocked results, not only the 403s as before. Every audit will re-request every walled link, which adds latency and load on repeat audits of sites with many such links. The tradeoff is intended and documented, but it is worth knowing about.
  • (nit) external-checker.ts: the detectWafChallengePage import line is long and will probably fail the formatter. Run the repo formatter.
  • (nit) local-link-notice.ts: the notice always says "bot protection or a timeout", even when every unverified item is a cloud-checker result. That case is not reachable when signed in, but it is a bit fragile.

Positives: the notice helper is cleanly separated and tested, cacheableVerdict centralises the cache rule, the rules and docs are updated together, and there are tests for the stale-cache path and the object-store, auth and 405 exceptions. No security problems spotted.

@nc9
nc9 merged commit 4b005fd into main Oct 15, 2026
15 checks passed
@nc9
nc9 deleted the feat/local-link-checks-unverified branch October 15, 2026 07:14
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.

Local link checks: list bot-walled answers and timeouts as unverified, not broken; suggest signing in

1 participant