Skip to content

feat(installer): install.sh runtime hardening (umask, size check, signal traps, bin-dir and HOME guards, noexec tmp) #168

Closed

Description

@nc9

Part of #164.

A set of runtime hardening gaps in install.sh, grouped because each is a few lines and they touch the same code paths:

  1. umask: the script never sets one. A permissive inherited umask (e.g. 0000) produces a group/world-writable bin directory and binary on PATH. Set umask 022 before any mkdir or file placement.
  2. Size check: manifest.json ships a size per binary; install.sh never reads it. Compare the downloaded byte count against it before hashing: a truncated download then fails with a clear size-mismatch error instead of a checksum mismatch.
  3. Signal traps: only an EXIT trap is installed, and bash skips EXIT traps when killed by an untrapped fatal signal. Ctrl-C during a download leaks the temp directory. Add trap 'exit 130' INT, trap 'exit 143' TERM, trap 'exit 129' HUP so termination exits through the existing cleanup/reporting trap.
  4. Bin dir guards: refuse SQUIRREL_BIN_DIR values that are empty after expansion or /.
  5. HOME guard: fail early with an actionable message when HOME is unset instead of dying mid-run with unbound variable.
  6. noexec temp dirs: the downloaded binary is executed from $TMPDIR to run self install. On systems where /tmp is mounted noexec (hardened servers, some containers) that fails opaquely. Either stage under ~/.squirrel/tmp as a fallback when the exec fails with a permission error, or detect the mount option and report a clear error naming the cause.

Acceptance Criteria

  • directories and the binary created by the installer are never group/world-writable regardless of the inherited umask
  • a downloaded binary whose byte count differs from the manifest size is rejected with a size-mismatch error before hashing
  • Ctrl-C during the download leaves no temp directory behind and still fires the failure-report path
  • SQUIRREL_BIN_DIR=/ (or //, /., /..) or a whitespace-only value aborts with a clear error; a truly empty or unset value means "not set" and uses the default directory (so a CI step with an empty variable does not start failing)
  • running with HOME unset produces an actionable error message
  • on a noexec temp dir the install either succeeds via a fallback staging directory or fails with a message that names noexec as the cause

Activity

  1. added
    enhancement
    P2
    size: M
    security
    on Sep 1, 2026
  2. added theissue type on Oct 28, 2026
  3. nc9 commented on Oct 31, 2026

    @nc9
    ContributorAuthor

    Verified against main after v0.0.152 (install.sh hardening landed). Met and ticked: criteria 1, 2, 3, 5 and 6 (umask never leaves a group or world writable result, a size mismatch is rejected before hashing, Ctrl-C leaves no temp dir and still reports, HOME unset gives an actionable error, a noexec temp dir falls back or names noexec; 36 hardening tests pass). Open: criterion 4: SQUIRREL_BIN_DIR of /, //, /.. or whitespace aborts, but a truly empty value is treated as not set (a CI step with an empty variable should not start failing), as the PR body says. Read literally the criterion wants an empty value to abort, so either the criterion needs amending to the shipped rule or the code needs to change. Leaving this open for that decision.

    nik

  4. nc9 commented on Oct 31, 2026

    @nc9
    ContributorAuthor

    Shipped in v0.0.152 (3ce62188), verified against main. Criterion 4 now states the shipped rule: /-like and whitespace-only values abort, a truly empty or unset value means not set (documented in the PR and covered by tests), so every acceptance criterion is met. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.152

    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

    P2enhancementsecuritysize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions