Skip to content

Start URL redirects (bit.ly etc.): resolve the chain and audit the destination, with consent for cross-domain (--follow-redirect / prompt); today it scores the shortener #1281

Closed

Description

@nc9

Auditing a link-shortener URL (or any start URL that redirects to another registrable domain) audits the shortener's own page and reports it as a normal completed audit with a score:

squirrel audit https://bit.ly/<code> -C surface --max-pages 2 --offline --passive -f json -o r.json
# Auditing https://bit.ly/<code> / New crawl: https://bit.ly / Audited 1 pages
# r.json: status "completed", meta.baseUrl "https://bit.ly", totalPages 1, score.overall 37

A cloud run (--render-mode all --ephemeral, v0.0.141) gives the same result: completed, base URL https://bit.ly, 1 page, score 37.

#1224 settled that --offline doesn't follow an off-site seed redirect, by design, and that the run should disclose "Seed redirected off-site to ..., not followed". Neither JSON report has that note or names the destination, and the score is presented as the site's. In a ~38k-site batch of product launches, 629 launch URLs (1.6%) redirected to another domain. The batch only got the right audit because it resolved redirects itself before calling the CLI.

Proposed behaviour (decided with the maintainer, 2026-10-29)

Nobody who types squirrel audit bit.ly/x wants a score for bit.ly. Resolve the start URL's redirect chain before crawling, and make the final URL the audit target, with the user's consent when it changes site:

  • Same-site redirects (http→https, apex↔www, a path change on the same registrable domain): follow silently; the final URL is the target.
  • Cross-domain redirects (shorteners, launch domains forwarding to the product, moved domains): need consent, because they change which site gets crawled.
    • Interactive TTY: prompt bit.ly/x redirects to https://example.com/pricing. Audit example.com instead? [Y/n].
    • Non-interactive (agents, CI): --follow-redirect (and [crawler] follow_redirect = true in squirrel.toml). Without it, don't audit the redirector. Exit with a distinct status redirected whose report names the final URL and the exact command to re-run.
    • -y does not imply it: -y approves credit spend, and agents pass it routinely. Following an off-site redirect is a separate consent, since it may be a third-party site.
    • MCP run_audit: reuse the confirmation_required handshake and show the final URL with the estimate; confirm: true plus follow_redirect: true proceeds.
    • Known shorteners (bit.ly, t.co, lnkd.in, …) may get lighter prompt copy, but still need consent.
  • Credits are estimated against the final site, after resolution.
  • Every hop and the destination go through the existing egress/SSRF guards (no private IPs; --offline egress rules apply to crawling, but the seed chain is resolved with one request per hop). Cap the chain at 5 hops; a loop or the cap reports redirected with the chain so far.
  • The report records the original URL and the full chain. The crawl scope is the destination's domain. In the cloud, the website row belongs to the final domain, with the original URL kept as an alias, so bit.ly/x never becomes a dashboard website.

Acceptance Criteria

  • A same-site seed redirect is followed without a prompt, and the report's base URL is the final URL.
  • A cross-domain seed redirect prompts on a TTY. Accepting audits the destination (report records the original URL and chain); declining exits with status redirected naming the final URL.
  • Non-interactive without --follow-redirect: no crawl of the redirector and no score. Exit with the redirected status (its own exit code, documented) and a report naming the final URL and the re-run command. With --follow-redirect: the destination is audited.
  • -y alone does not follow an off-site seed redirect; a test pins it.
  • MCP run_audit returns confirmation_required with the final URL for a cross-domain seed, and proceeds only with explicit follow consent.
  • The credit estimate uses the destination site.
  • Each hop passes the egress/SSRF guard (test: a redirect to a private IP is refused and reported). Chain capped at 5 hops; loops are reported.
  • In the cloud, the website is created under the final domain, with the original URL stored as an alias.
  • The text, markdown, LLM and JSON outputs carry the original URL and chain. Docs (docs/cli/audit.mdx, MCP docs, exit-code table) and shell completions are updated in the same PR, and the agent skill is checked for a needed change.
  • A test covers a shortener-style seed (301 to another domain) offline and online, plus a same-site http→https→www chain.

Activity

  1. added
    bug
    on Oct 29, 2026
  2. added theissue type on Oct 29, 2026
  3. changed the title [-]Auditing a shortener URL (bit.ly etc.) audits the shortener: 'completed', score 37, base URL bit.ly, no off-site redirect disclosure[/-] [+]Start URL redirects (bit.ly etc.): resolve the chain and audit the destination, with consent for cross-domain (--follow-redirect / prompt); today it scores the shortener[/+] on Oct 29, 2026
  4. added
    size: L
    on Oct 29, 2026
  5. nc9 commented on Oct 30, 2026

    @nc9
    ContributorAuthor

    Checked against main (23a34c1, v0.0.144). Ticked what holds (the resolver, consent, exit code 4, outputs, docs). Open: the cloud criterion (a website alias or stored original URL) is not implemented; the audit URL is the destination and the original appears only in report meta. No test asserts the credit estimate uses the destination in the MCP audit_website path, and the only end-to-end run is --offline, so there is no online-mode e2e.

    nik

  6. nc9 commented on Oct 31, 2026

    @nc9
    ContributorAuthor

    Re-checked against main after v0.0.148 (the redirect estimate, registration and online-mode e2e landed). Met locally: following a same-site redirect silently, the cross-domain prompt and exit 4 with the re-run command, -y alone not following, the MCP confirmation_required outcome, the SSRF guard on each hop and the cap of 5, and the shortener e2e offline and online. Open: the criterion that the credit estimate uses the destination holds only by ordering (the estimate takes no site input) and no test asserts it; the hosted alias for the original URL is not in this repo; the agent skill check is a process item; and the http to https to www chain is a resolver unit test, not an e2e. Leaving this open for those.

    nik

  7. added 2 commits that reference this issue on Nov 4, 2026
  8. nc9 commented on Nov 11, 2026

    @nc9
    ContributorAuthor

    The CLI side is on main: resolver, consent, --follow-redirect, exit 4 with the re-run command, the per-hop egress guard, the 5-hop cap, and the estimate/registration/billing on the destination (audit-website-billing.test.ts). End-to-end chain, cap and loop tests are in the next release. What is left is the hosted website record (final domain plus alias), tracked privately; this closes when that ships.

    nik

  9. nc9 commented on Nov 12, 2026

    @nc9
    ContributorAuthor

    Not closed after v0.0.179 (https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.179). The local flow (same-site follow, TTY prompt, exit 4, -y, MCP confirmation, egress guard, hop cap) shipped with tests. Still open: the cloud website created under the final domain with the original URL as an alias (private), and the agent-skill check. The change that shipped is db66007.

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclisize: L

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions