Repository navigation
feat(rules): add reliability/broken-forms for forms that lose submissions - #734
Conversation
|
Reviewed Overall this is a careful rule. It never sends a POST, because the
Test coverage: |
…ions #707 Two faults lose form submissions with no visible error: a field with no name is never sent, and an action that answers 404, points at a staging or localhost host, or is mailto: never reaches a handler. The rule is site-scoped. Unnamed controls are reported per form, split by whether the form has a real action (warn) or not (info). Action checks reuse the crawl's status for same-site URLs (a crawl 404/410 is an error), report dev hosts and mailto: without a request, and send at most one HEAD (then GET on 405/501 or a network failure) per uncrawled endpoint, through the shared probe budget. A 404 to that probe warns that the endpoint may accept POST only. Third-party actions are checked only when external link checking is on. No POST is ever sent, and passive probing says the action was not checked. - Dev hosts the audit is itself on are not leaks: a localhost, private-IP or tunnelled site reports none; a preview deployment still reports localhost and private-IP actions. - Probes send squirrel's User-Agent and Accept only (no cookies, no custom headers), are fetched undecoded with the body cancelled, follow no redirect, and go through the @squirrelscan/utils/public-egress guard, pinned to the vetted address: same-site probes stay on the site's hosts, and only the site's own origin may resolve privately (a public site's subdomain or another port on its host must resolve publicly); third-party probes go to public addresses only (unless the site itself is private); never link-local or metadata. A refused probe spends no budget. - At most 25 endpoints per audit and 10 per site are probed, the site's own first; query variants of one endpoint share one probe. - Labels cut site text at 120 characters and percent-encode the characters that would form a markdown link; item ids and meta are cut at 2 KB. - On an http site, same-site http actions are judged from crawl status only, never probed; on an https site they are left to security/form-https. - The rule is built by createBrokenFormsRule({ resolve }) so tests inject DNS; brokenFormsRule uses the system resolver. Golden gate: +1 finding and +1 tally row (info "No forms detected" on the synthetic site); healthScore.overall stays 51. Signed-off-by: Nik Cubrilovic <[email protected]>
0c7a63d to
b29af25
Compare
|
Review of No blocking problems. The probe path is well hardened: HEAD/GET only, no cookies, redirects not followed, undecoded body, egress guard, per-site and total caps, and markdown-safe labels.
Test coverage: the PR adds |
Summary
Adds
reliability/broken-forms(#707). Two faults lose form submissions with no visible error, and nothing in squirrel checked either before this rule:name. The browser never submits it, so a visibly filled-in field is dropped. Warned when the form has a real action; reported as info when it has none, since a script may read the field.content/dev-leakageuses) andmailto:are warnings, reported without any request. A 5xx, network failure, or third-party 404/410 is a warning. 429, 503 withRetry-After, and WAF challenges are reported as unverified info, never as broken.Action checks run in this order. A
mailto:or dev-host action is classified from its URL alone. A same-site action the crawl fetched uses the crawl's status. Anything else is probed through the shared probe budget withHEAD, andGETonly whenHEADreturns 405/501 or fails at the network level. The probe method type is"HEAD" | "GET", so noPOSTis possible. Each endpoint is probed at most once, within the caps above. Third-party actions are checked only when external link checking ran. Under passive probing the result says the action was not checked.formactionon a submit button is checked the same way as the form'saction. A control's owner is resolved from itsform=attribute, falling back to its nearest<form>, sosubmit,button,reset,image, disabled and template-contained controls are never reported.Changes from the maintainer review (2026-10-12) and two Opus security passes:
claude/703-broken-resources) was deleted on feat(rules): add reliability/broken-resources and the Reliability category #703 #714's merge. 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, feat(rules): add security.txt and version-disclosure rules (#713) #717 and feat(rules): mobile/web-app-manifest checks the linked manifest and its icons (#710) #715, so no other PR's rule is carried here. It does not depend on feat(rules): add content/common-misspellings #709 #720 (content/common-misspellings), which is on hold.healthScore.overallstays 51.*.vercel.app,*.netlify.app), preview and dev actions are its own but localhost and private-IP actions are still reported. Tests audit a localhost site with a relative action and a preview site.fetchUndecoded(no compression bomb inflated, #2717), squirrel'sUser-AgentandAcceptonly, no cookies and none of the audit's custom headers (as the GraphQL probes), no redirects followed, body cancelled. Every probe goes through@squirrelscan/utils/public-egress, pinned to the vetted address: same-site probes stay on the site's host and subdomains and may resolve privately only on the site's own origin (a public site's subdomain or another port must resolve publicly), third-party probes go to public addresses only (unless the audited site is itself private), never link-local or metadata. This replaces the originalglobalThis.fetchcall, which a background SSRF scan flagged. A refused probe spends no budget and reads as not checked.form-action-not-found-to-probe); a 404/410 the crawl itself fetched stays an error.toSample); item ids and meta are cut at 2 KB. The unnamed-field warning says a script may still read the field.security/form-https.[Unreleased]/### Added.Agent skill: yes, the squirrelscan agent skill (squirrelscan/skills) should learn the new rule; the maintainer files that as a private issue. The Reliability count (1 -> 2) is left for the maintainer's batched docs PR.
Closes #707
Verification
The rule and test files are oxfmt- and oxlint-clean. New tests cover: a localhost site's relative action, preview sites, probe headers and
credentials: "omit"/redirect: "manual"/ undecoded, pinning (connects to the vetted IP, Host is the name), private and metadata targets never requested (including a same-site name resolving to the metadata address), the caps and endpoint sharing, the IPv6-literal site, the probe-404 warning, and markdown-link injection in labels.Acceptance checklist
action="#"with an unnamed field gives info, not warn (test).form=othercontrols are not reported against their own form; an unnamed control withform="contact"outside the form is reported againstform#contact(test).POST; passive probing sends no request for an uncrawled action and says so (test).staging.example.com,localhostandmailto:actions each warn (test).Retry-After, and WAF challenges are unverified info, never broken (test).http:action on an HTTPS page is left tosecurity/form-https(test, public host).docs/rules/reliability/broken-forms.mdx, wired into nav and the Reliability index;make -C docs validatepasses.Deviations to review
http://localhostactions are both warned here (dev host, per the issue's fixture) and reported bysecurity/form-https(insecure submission). The issue's two boxes conflict on this one case. This PR follows the fixture.HEAD/GETprobe with the same verdict table. The external link checker lives inaudit-engine, whichpackages/rulescannot import. When the checker already has a row for the URL (site.externalLinks), that row is used. The issue body asks for "the same checker", which this does not meet exactly.Checklist
Signed-off-byline (git commit -s).