Skip to content

feat(rules): detect open redirects in redirect-shaped params (repo#1936) - #1881

Merged
nc9 merged 1 commit into
mainfrom
boat/open-redirect-1936
Nov 17, 2026
Merged

nc9 merged 1 commit into
mainfrom
boat/open-redirect-1936

Conversation

@nc9

@nc9 nc9 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Adds security/open-redirect, a quiet probing rule next to the GraphQL probes, inside the shared probe budget and the --probe levels from packages/config/src/probe.ts. Implements squirrelscan/repo#1936 (private issue; it closes when the gitlink bump lands).

What it does

  • Candidates: same-origin URLs whose query has a redirect-shaped param (next, url, redirect, redirect_url, redirect_to, return, returnUrl, returnTo, return_path, dest, destination, continue, goto, r, matched ignoring case, _ and -). They come from crawled page URLs, internal links, and discovered GET endpoints and form actions (ctx.endpointSurface). Deduped on path + param name, at most 10 per run.
  • Never requested: a state-changing path (reuses isStateChangingPath, e.g. /logout?next=), a discovered call site that declares any non-GET method, or a robots-disallowed path below aggressive.
  • Probe: GET with only that param set to https://squirrelscan-redirect-probe.invalid/. If that is not redirected off-site, a second GET with //squirrelscan-redirect-probe.invalid/ follows. Settings: credentials: "omit", redirect: "manual"; the body is never read. .invalid never resolves.
  • Finding: only a 3xx whose Location resolves to the canary host. A redirect to the same origin, a redirect to another (allowlisted) host, a 4xx or a 200 echo is not a finding.
  • Reporting: findings name the page (origin + path, never the query string) and the param. Nothing is logged.
  • Below active (or with no ctx.probe): no request is sent, and the rule records one skipped check (probing-passive) saying to run with --probe active. When the budget runs out, or every probe errors, the rule records a skipped check, never a pass.

Acceptance criteria (repo#1936)

  • Identifies redirect-shaped params in crawled URLs/forms: open-redirect candidate selection tests (same-origin only, deduped, name matching), and the page-url/link sources in the rule tests. Forms reach the rule through endpoint discovery's GET form actions.
  • Probes each with an offsite sentinel and reports when Location goes off-origin: test a vulnerable param is flagged with the page and the param, from the absolute form.
  • Both bypasses tested: the absolute form in the test above; protocol-relative in the protocol-relative bypass is tried when the absolute form is refused; /\host in classifyRedirect.
  • On-origin or rejected values are not flagged: test an allowlisted redirect, a same-origin-only redirect, a rejection and a 200 echo are not flagged.
  • Not followed, capped, per fix(rules): content/reading-level skips code blocks (repo#1639) #1931 policy: the redirect is never followed (a real local server sees no request to the Location target), probes are capped per run, an exhausted budget sends nothing more and is not a pass, state-changing paths and non-GET call sites are never requested, below the active level: no request, and a not-checked result. A mutation check that switched the request to redirect: "follow" failed 4 of the 13 tests.

Gates

  • packages/rules: bun run typecheck clean. packages/audit-engine and packages/utils typecheck clean. oxlint (CLI config) on the new files: clean.
  • bun test packages/rules/tests/open-redirect.test.ts: 13 pass.
  • Rules suites run in batches of five: 704 + 104 + 65 + 73 pass, 0 fail. These cover the rule-check declarations, the docs count/page/table tests, the GraphQL and probe-budget tests, opt-in, ignore, private-target and discovery-probes.
  • packages/audit-engine: streaming-rules-canonical-golden.test.ts 1 pass (findings 109735 -> 109736, rules 328 -> 329, one skipped row because the gate is passive). golden-finding-messages-229.test.ts 3 pass after UPDATE_GOLDEN=1; the diff is one skipped line.
  • docs/: make validate: tangly strict passed, links ok, glossary ok, rule-checks ok, 62 pass.

Docs

New docs/rules/security/open-redirect.mdx, plus updates to the security hub row and count (25), the rules index card, the README and docs/index.mdx Security rows, the probing rules table in configuration/security.mdx, the offline note in cli/audit.mdx, the nav, and CHANGELOG (Unreleased > Added).

Agent skill

No change needed: the skill reads rule output generically and documents --probe already. The new rule appears through the existing rules listing.

@nc9
nc9 marked this pull request as ready for review November 14, 2026 23:13
@nc9
nc9 force-pushed the boat/open-redirect-1936 branch 3 times, most recently from 8fdccf3 to d6e7ed9 Compare November 15, 2026 03:56
@nc9

nc9 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Review requirement (2026-11-15, from #1920): a probe answered with 429, a 401/403 bot challenge, an HTML challenge page (cf-mitigated, Cloudflare or WAF challenge markers), 5xx or a timeout must make the target UNVERIFIED. The rule then reports not checked or incomplete, never passed. Only a genuine 404, or a non-challenge answer, counts as not exposed. Please add a stub test for a 429 and for a 403 HTML challenge.

Add security/open-redirect, a site-scoped quiet probing rule that runs at
--probe active or above inside the shared probe budget. It finds same-origin
URLs whose query carries a redirect-shaped parameter (next, url, redirect,
return, returnTo, returnUrl, dest, continue, r and the like) in crawled page
URLs, internal links and discovered GET endpoints, and sends GET requests
with that parameter set to https://squirrelscan-redirect-probe.invalid/ and
then //squirrelscan-redirect-probe.invalid/. It warns only when a 3xx
Location resolves to that host. Redirects are never followed and bodies are
never read; state-changing paths (isStateChangingPath) and non-GET call
sites are never requested; robots.txt is respected below aggressive; at
most ten parameters per run. Findings name the page and the parameter, not
the query string. Passive runs record one skipped check and send nothing.

Docs: rule page, security hub, rules index, README and docs/index.mdx
tables, probing config table, CHANGELOG. Canonical golden and finding
messages pin one more skipped row (329 rules).

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the boat/open-redirect-1936 branch from d6e7ed9 to e46f704 Compare November 17, 2026 02:26
@nc9
nc9 merged commit 33e4872 into main Nov 17, 2026
16 checks passed
@nc9
nc9 deleted the boat/open-redirect-1936 branch November 17, 2026 05:53
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.

1 participant