Repository navigation
feat(installer): enforce HTTPS-only, TLS 1.2+ and a redirect cap on every curl in install.sh - #212
Merged
Merged
Conversation
4 tasks
…very curl curl follows a redirect from https to plain http by default and negotiates whatever TLS version the local build still allows. The downloaded binary is checksum-verified against the manifest, but the release-metadata fetches and the bash re-exec have nothing behind them but the transport itself. Every curl the script runs now carries --proto '=https' --proto-redir '=https' --tlsv1.2 --max-redirs 3, held in one CURL_TLS_ARGS array: fetch_with_retry, both fetches in get_latest_version, and the failure-report POST. --proto and --proto-redir are separate settings and one does not imply the other, so the initial scheme and every redirect hop are pinned independently. The POSIX-sh re-exec at the top repeats the flags inline because it runs above the bash-only preamble that defines the array. All four options predate curl 7.34 (2013), below every platform we support. The contract test grows a scan that fails on any curl call site which neither spells the flags out nor inherits them from CURL_TLS_ARGS, pinned to the five sites that exist so a refactor hiding one cannot pass vacuously. It also drives fetch_with_retry, get_latest_version (both the R2 endpoint and the GitHub API fallback) and report_error against a curl test double, which is what proves the flags reach a real argv rather than only the source text. The two report_error tests move from a plaintext loopback server to that same double: --proto '=https' refuses http, and a TLS stand-in would need a CA the child curl trusts, which the SecureTransport curl macOS ships does not read from CURL_CA_BUNDLE. That would have passed in CI and failed on half the development machines. Closes #165 Signed-off-by: Nik Cubrilovic <[email protected]>
… test Review of the first commit found the scan and the harness weaker than they looked, and two comments saying things that are not true. The scan let five shapes of unhardened curl through, each confirmed against a crafted script: a path-qualified `/usr/bin/curl`, a second curl on a line whose first one is hardened, a curl after a `command -v curl` probe on the same line, a curl on a line that merely mentions a hardened array, and an array whose later assignment drops the flags. It now walks every match on a line, judges each on the text from its own curl onward, scopes the probe skip to the match instead of the whole line, and requires every assignment of an argv array to qualify. The four call-site shapes are pinned as their own cases. The harness shimmed curl everywhere, so a typo like `--tlsv.1.2` would have passed the whole suite and every other pre-merge gate: `bash -n` does not know curl's option names, and the install-test workflow runs only on release and fetches install.sh from main rather than from the tree under test. One test now hands the real flag set to the real curl against a closed loopback port. Also: the settle loop accepted a half-written record, so a slow detached POST could parse as an argv with no --data; it now waits for the record separator, and the shim writes the whole record through a single redirect. The harness spread the ambient environment into the child, which put a GITHUB_TOKEN into get_latest_version's auth header and therefore into the argv that a failing expect() prints, so it now clears that and the endpoint seams. The third detached-POST test was missing the 15s budget its two siblings carry. The comment claiming all four options predate curl 7.34 was wrong: --tlsv1.2 landed in 7.34. The comment offering SQUIRREL_ERROR_ENDPOINT as a test seam no longer holds either, since curl now refuses a plain-http override. Closes #165 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
feat/165-install-sh-curl-tls
branch
from
September 6, 2026 23:02
6332822 to
1d5ab86
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #165
Summary
curl follows a redirect from https to plain http by default and negotiates whatever TLS version the local build still allows. The downloaded binary is checksum-verified against the manifest, but the release-metadata fetches and the bash re-exec have nothing behind them but the transport itself.
Every curl the script runs now carries
--proto '=https' --proto-redir '=https' --tlsv1.2 --max-redirs 3, held in oneCURL_TLS_ARGSarray:fetch_with_retry, both fetches inget_latest_version, and the failure-report POST inreport_error.--protoand--proto-redirare separate settings and one does not imply the other, so the initial scheme and every redirect hop are pinned independently. The POSIX-sh re-exec at the top of the script repeats the flags inline, because it runs under/bin/shabove the bash-only preamble that defines the array.install.ps1is untouched: the sibling issue #166 is covered by #207.Tests
scripts/install-contract.test.tsgrows a static scan that fails on any curl call site which neither spells the flags out nor inherits them fromCURL_TLS_ARGS, plus runtime tests that drivefetch_with_retry,get_latest_version(both the R2 endpoint and the GitHub API fallback) andreport_erroragainst a curl test double, which is what proves the flags reach a real argv rather than only the source text. One further test hands the flag set to the real curl against a closed loopback port, so a typo like--tlsv.1.2cannot pass the suite.Two existing
report_errortests move from a plaintext loopback server to that same double.--proto '=https'refuses http, and a TLS stand-in would need a CA the child curl trusts, which the SecureTransport curl macOS ships does not read fromCURL_CA_BUNDLE; that would have passed in CI and failed on half the development machines. Their payload assertions are unchanged, now read off the recorded--data.Verification
Acceptance criteria, each checked:
--proto '=https' --proto-redir '=https'; the scan fails if one does not--tlsv1.2; the real curl accepts it--max-redirs 3; real release assets take exactly 1 hopEnd-to-end installs, all exit 0 and the installed binary reports
0.0.90:bash install.shand the pipedcat install.sh | bashformubuntu:24.04(glibc, curl 8.5.0/OpenSSL) as a non-root test useralpine:latest(musl, curl 8.22.0/OpenSSL) as a non-root test usercurl | bashre-exec) anddash /install.sh(takesexec bash "$0")Redirect depth against the real endpoints under the hardened flags, confirming the cap of 3 is not tight:
install.squirrelscan.com/releases/stableinstall.squirrelscan.com/install.shapi.github.com/repos/…/releasesMutation-tested: seven separate mutations each turn the suite red, including dropping a flag from the array, dropping the array reference at each of the four bash call sites, unhardening the sh re-exec, adding an unhardened path-qualified curl, and typoing a flag name.
Reviewed
An adversarial review pass produced the second commit: the scan was letting five shapes of unhardened curl through, the harness could parse a half-written record, and it spread the ambient environment into the child, which put a
GITHUB_TOKENinto an argv that a failing assertion would print. All fixed, with the scan's blind spots now pinned as their own test cases.Two follow-ups found in the same pass are deliberately out of scope here:
npm/scripts/postinstall.jsfollows redirects by unbounded recursion with no cap (filed as #213), andinstall.ps1has the same gap (#166 / #207).Not covered
test-install.ymldoes not gate this PR: it isworkflow_call/workflow_dispatchonly, and it fetchesinstall.shfrommainon raw.githubusercontent.com rather than from the tree under test. The platform matrix above was run by hand instead.Checklist
Signed-off-byline (git commit -s).