#6700

fix(hopper): refuse downloads redirected to another origin

DraftDextheking1wants to merge intofrom

Summary

Fix: downloadHopperPackage now refuses a response whose final URL is on a different origin than the requested URL, so Hopper downloads can no longer be redirected to an unvalidated host. Draft PR; readiness declarations left for the human owner.

Problem and expected behavior

Setup validates Hopper download URLs up front (the Linux release parser requires the package URL origin to be exactly https://www.hopperapp.com; the macOS path requires a fixed HTTPS prefix), but downloadHopperPackage (src/application/HopperDownload.ts) called fetch with the default redirect behavior and never checked response.url. A redirect from the validated origin silently delivered the release metadata, the PGP public key, or the package itself from another host. SECURITY.md describes package URLs as restricted to the official origin; that held only for the initial URL. Expected: the origin restriction covers the response that is actually consumed. Package substitution was and remains blocked independently (pinned-fingerprint OpenPGP verification plus launcher SHA-256 on Linux, codesign designated requirement on macOS); this closes the documented-control gap, not a code substitution hole.

Change and scope

After the fetch, the final response URL's origin is compared with the requested URL's origin; a mismatch cancels the body and returns the existing refused result. Same-origin redirects are unaffected. One helper (isExpectedOrigin) plus a new unit test file. No caller changes.

Evidence and regression coverage

  • Tests added or updated: new src/application/HopperDownload.test.ts stubs fetch and covers both directions: a redirect that stays on the requested origin returns the bytes; a redirect to another origin is refused with no bytes.
  • Base reproduction or other evidence: executed with two local HTTP servers: the base fetch call shape followed a 302 cross-origin and returned the second origin's body with status 200.
  • User-visible CLI/MCP output (if applicable): a cross-origin redirect now makes the download fail with the existing not-ok result, so setup reports the download as unavailable instead of consuming it.
  • Remaining proof gaps: the real Hopper endpoint was not contacted; the mechanism was verified locally only.

Validation performed

  • npx vitest run src/application/HopperDownload.test.ts src/application/LinuxHopper.test.ts - 55 passed
  • npx vitest run src/application/AppBundleExecutable.test.ts - passed (sibling suite in the same tree)
  • node scripts/run-typescript.mjs --noEmit - clean
  • npx oxfmt --check and npx oxlint on the changed files - clean (an initial complexity warning in downloadHopperPackage was resolved by extracting the helper)
  • Note: tests/boundary/setup/linuxHopperPublisherVerification.test.ts shows 19 failures in my sandbox on the base revision as well (missing system fixture tooling); identical before and after this change.

Compatibility, safety, and release

  • Breaking changes or migration steps: if Hopper's delivery ever legitimately redirects to a different origin, downloads would start failing closed until the expected origin is updated. The documented contract already restricts downloads to the official origin, so this enforces the stated behavior.
  • Real Hopper/Ghidra, browser, or OS coverage: Hopper itself was not run; the download helper and its consumers are covered by unit tests.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: strengthens the download origin control to match SECURITY.md. No new network destinations, no process changes.

Contract and boundary impact

  • Semantic owner and earliest changed stage: see above.
  • Contribution scope fit and linked maintainer decision: ordinary fix within an existing boundary; not applicable.
  • CLI and MCP/tool-catalog contract: unchanged.
  • Provider, bridge, target-format, or platform compatibility: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Activity

8
greptile-apps[bot]1mo ago

Confidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous downgrade regression is fixed.

Summary

Hopper downloads now refuse redirects that leave the requested origin before contacting the destination.

  • Hopper downloads stop when a redirect leaves the original origin.

Reviews (3) · Last reviewed commit: "Check redirect protocol before origin so..." · Reviewed by Greptile

CassieFox2317d ago

TL;DR: I ran the two test files on head 7f1a7a8d32 on three Node versions, and all 9 tests passed each time. With HopperDownload.ts swapped back to the merge base 3233992733, the 3 new tests failed on all three versions. From reading the diff, the PR also changes an old test, so a hop from www.hopperapp.com to downloads.hopperapp.com is now refused.

CheckNode 22.23.4Node 24.22.1Node 26.12.1
Head 7f1a7a8d32pass: 2 files, 9 testspass: 2 files, 9 testspass: 2 files, 9 tests
Red run (old HopperDownload.ts)fail: 3 failed, 6 passedfail: 3 failed, 6 passedfail: 3 failed, 6 passed
  • The red run used the same head and test files, with src/application/HopperDownload.ts from 3233992733 (the code without the fix).
  • In the Node 24.22.1 log, the 3 failures are refuses a redirect to another origin without requesting it, refuses a later hop that leaves the requested origin and refuses a cross-origin redirect before sending the redirected request and releases its body.
  • So the new tests fail without the fix and pass with it.
  • From reading the code, HopperDownload.ts cancels each redirect body at line 97, before the origin check at line 108: if (next.origin !== expectedOrigin) return undefined;.
  • The PR changes an existing test in tests/process-global/hopperDownloadRedirect.test.ts. An origin is the scheme, host and port together.
  • At 3233992733 the test was preserves HTTPS relative and cross-origin redirects under one request deadline. It followed a redirect from www.hopperapp.com to https://downloads.hopperapp.com/final.
  • At 7f1a7a8d32 the test is preserves HTTPS same-origin redirects under one request deadline, and the redirect goes to https://www.hopperapp.com/final.
  • So a hop from www.hopperapp.com to downloads.hopperapp.com, which the old test accepted, is now refused.
  • One idea: check whether Hopper's real download URL ever redirects to another host. That URL is www.hopperapp.com:443/downloader/public/, from HopperReleaseFeed.ts line 19. If it does, setup would refuse the download.
  • CI on 7f1a7a8d32: CI and PR title wait for a maintainer to approve them (action_required).
  • PR readiness has 3 successful runs and 1 failed run, and its commit status is success.
  • Validate author declaration has 3 successful check runs and 1 failed one. Greptile Review passed.
  • The head is 1,025 commits behind main b81da90354. GitHub says the PR is mergeable, and its merge state is blocked.

Not run

  • Hopper's real download server, so I did not check where its redirects go.
  • npm run check:fast.
  • A merge with current main, b81da90354.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 7f1a7a8d32 / 3233992733 (merge base with main)
  • Red run: 7f1a7a8d32 with src/application/HopperDownload.ts from 3233992733
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1, exit 0, for both trees
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- src/application/HopperDownload.test.ts tests/process-global/hopperDownloadRedirect.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

benjaminkincses17d ago

Checked the live feed just now. Current releases are 6.6.2, served from https://www.hopperapp.com:443/downloader/public/. Fetched the real macOS dmg and Linux deb URLs, both return 200 with zero redirects, same URL. downloads.hopperapp.com appears nowhere in prod code, only in the two test files, and the host returns an empty reply today. So the www to downloads hop the old test accepted is not real vendor behavior, and refusing it does not break real downloads as observed. Caveat: this is a point-in-time check. If the vendor ever starts redirecting to another host, setup would refuse the download, but the feed pins the filename to the www origin, so that would be a vendor-side change to deal with then.

This pull request is a draft

Merging is unavailable until it is marked ready for review.