Skip to content

Confine build-plan to the checkout, check installer sums, open only web pages - #120

Merged
ramonmalcolm10 merged 1 commit into
mainfrom
audit-hardening
Dec 2, 2026
Merged

ramonmalcolm10 merged 1 commit into
mainfrom
audit-hardening

Conversation

@ramonmalcolm10

Copy link
Copy Markdown
Contributor

Three hardening items from the 2026-12-02 security audit.

1. build-plan follows symlinked folders out of the checkout

  • cmd/homeport/buildplan.go:118 read the checkout through os.DirFS(dir). buildplan.read and the root-directory check (buildplan/buildplan.go:488-490, :1004-1019) lstat only the last path component, and DirFS follows a link earlier in the path. A repository committing a -> / with a root directory under a/ made the planner, which runs as root on builders, read host files.
  • Fix: planBuild opens os.OpenRoot(dir) and passes root.FS() (go.mod is 1.27.4), the same as buildcache and artifact/bundle already do. Local homeport deploy / build-plan on a normal project is unchanged; a local project folder holding a link to outside it now gets "not found" for files read through that link.
  • Test: TestSymlinkedFoldersInTheRepositoryAreNotFollowed (checkout whose a links to an outside folder holding app/package.json, bun.lock, homeport.yaml; root directory a/app).
    • red: read through a symlinked folder: {Kind:binary Framework:Bun ... Root:a/app ... Run:./server ...}
    • green: --- PASS. go test ./... passes.
  • Reaches builders only after a CLI release and the owner moving the builders' FLEET_CLI_* pin.

2. install.sh installs unchecked binaries when the checksum step can't run

  • install.sh:47-59 skipped verification silently when checksums.txt failed to download, had no line for the archive, or neither sha256sum nor shasum existed.
  • Fix: each case now stops with a message saying why. No opt-out variable.
  • The repo has no install.sh test; verified against a local fake release (stub curl serving files from a temp dir, stub mv, PATH limited to the tools needed; no network):
    • red (before): nochecksums, noline, nosha all printed installed homeport ..., exit 0; badsum refused.
    • green (after): good installs; nochecksums -> could not download .../checksums.txt to verify the download — refusing to install; noline -> checksums.txt has no checksum for homeport_1.0.0_darwin_arm64.tar.gz — refusing to install; nosha -> need sha256sum or shasum to verify the download ...; badsum -> checksum mismatch; all exit 1.

3. openBrowser hands API-supplied addresses to open/xdg-open unchecked

  • cmd/homeport/app.go:278-286, called from login.go:44 and domains.go:269, :308: a file:// path, an app scheme, or a leading - (an option to open) reached the opener.
  • Fix: openBrowser opens only https, or http on loopback/localhost (needed: the device-login tests and a local API run on http://127.0.0.1). That rule was already checkBase's for HOMEPORT_API; it is now one shared webAddress. Refusal returns an error naming the address, and the three callers already print "Open in a browser" when opening fails.
  • Test: TestOnlyAWebPageIsOpened (stub open/xdg-open on PATH records what it is handed).
    • red: the stub received file:///etc/passwd, vscode://open?file=x, -a Calculator, http://example.com/device, https:///no-host, javascript:alert(1).
    • green: --- PASS; only the https and loopback http addresses reach the opener.

…eb pages

build-plan read the checkout through os.DirFS, which follows a symlinked
folder anywhere: a repository committing a -> / with a root directory under
it made the planner (root, on builders) read host files. It now reads
through os.OpenRoot(dir).FS(), so no path leaves the app folder.

install.sh skipped checksum verification without a word when checksums.txt
could not be fetched, had no line for the archive, or no sha tool existed.
Each of those now stops the install with a message saying why.

openBrowser handed API-supplied addresses straight to open/xdg-open, so a
file:// path, an app scheme or a leading "-" reached the opener. It now
opens only https, or http on this computer (the rule checkBase already
applied to HOMEPORT_API, now shared as webAddress); callers already say the
address for the person to open when opening fails.
@ramonmalcolm10
ramonmalcolm10 merged commit 4102c3e into main Dec 2, 2026
9 of 10 checks passed
@ramonmalcolm10
ramonmalcolm10 deleted the audit-hardening branch December 2, 2026 23:12
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