Repository navigation
Conversation
nc9
force-pushed
the
fix/install-sh-hardening-168
branch
4 times, most recently
from
October 31, 2026 13:42
af08676 to
e0a6589
Compare
…nd HOME guards, noexec temp fallback #168 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/install-sh-hardening-168
branch
from
October 31, 2026 19:47
e0a6589 to
c09c5e6
Compare
Merged
Contributor
Author
|
Landed in v0.0.152 as nik |
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 #168 (part of #164).
All six items, in
install.sh, with a new end to end test file that runs the whole installer against a shimmed curl,uname,mktempandchmodand a fake release binary, in a throwaway HOME and TMPDIR.022before anything is created (umaskOR 022, so a stricter077is kept, not loosened). Tested with an inherited0000(bin dir and binary not group or world writable, the binary itself runs under022) and with0077(kept).size(jq, or a newjson_get_nested_numberfor the grep fallback) is compared with the downloaded byte count before the checksum:Size mismatch: the download is N bytes, the release manifest says M. A manifest with no size, or one that is not a whole number, skips it (older releases).kill -0thenwait: a plainwaitlost a second signal on stock macOS bash 3.2 and left the installer spinning. A signal is the user stopping the run, so no failure report is sent, which keeps Ctrl-C out of the installer worker's alerts; private #3703 tracks the worker side.)INT,TERMandHUPexit 130, 143 and 129 through the existing EXIT trap, which now also names the cause in the report. Tested for all three with the whole process group signalled mid-download (as a terminal does): the exit code, no temp directory left, and the failure report POST namingdownload_binary. The download runs in the background and is waited on, so a signal sent to the installer PID alone is handled at once and the curl child is killed. (SIGINT already behaved on this shell; TERM and HUP fail on the old script.)SQUIRREL_BIN_DIRthat is only whitespace or lexically resolves to/(/,//,/.,/..,/usr/..) aborts before anything is downloaded. An empty value still means "not set" (a CI step with an empty variable should not start failing); documented.HOMEstops with "HOME is not set" (needed even whenSQUIRREL_BIN_DIRis set; message, docs and test now say so) and how to fix it, notHOME: unbound variable.run_self_install; exit 126 with "Permission denied" is the shell failing to exec, so the installer stages the binary under~/.squirrel/tmp/install.XXXXXXand retries once, cleaning that directory on exit. If that also fails it stops with a message naming noexec, the two directories andTMPDIR=as the way out, reported under its own stepself_install_noexec. Detection is exit 126 with a non-executable file, not the English text, so it works in any locale. If the staging dir cannot be created the message says that (stepself_install_stage), not noexec. A binary that fails for another reason (exit 3) is not mistaken for it.Tests:
scripts/install-hardening-168.test.ts(36; at least 16 fail on the previousinstall.sh), two source-text assertions inscripts/install-contract.test.tsupdated forrun_self_install(139 pass),install-path-setup(29 pass).bash -nandshellcheck -S warningclean. Docs: a "What the installer protects" section indocs/quickstart.mdxand theSQUIRREL_BIN_DIRrow. CHANGELOG under Unreleased / Changed. Skill: no change needed.nik
Known and not done: the grep fallback for the manifest size reads
1.5e9as1; a failed copy into the staging directory is reported as the noexec cause; a signal in the first ~100 ms, before the traps are installed, can leave a 0-byte temp file and sends no report; a symlink to/is not followed by the SQUIRREL_BIN_DIR check (the docs say names, not links); the tests do not pin the! -xhalf of the noexec check or that detection ignores the language.