Threat model

August 5, 2026 ยท View on GitHub

base-bash-libs is loaded into a caller's Bash process. The trust boundary is therefore the source path and release artifact, the caller's environment and arguments, and every command or file operation performed after sourcing. This model describes the threats the framework reduces and the boundaries it does not control.

Assets and trust boundaries

  • caller secrets, environment variables, arguments, files, repositories, and generated output;
  • the Bash process and its exit status, traps, signal state, and logs;
  • vendored, bundled, Homebrew, and source-checkout release artifacts;
  • GitHub/network credentials and remote repositories used by optional helpers.

The framework trusts the maintainer-reviewed artifact, the Bash interpreter, the caller's selected working directory, and external commands. A sourceable library cannot sandbox itself from the caller or undo permissions already granted to the process.

Threats and mitigations

SurfaceThreatFramework mitigationCaller responsibility
Sourced code/importsAn untrusted or stale path executes code in-processpackage-relative imports, explicit paths, API manifests, immutable-consumption guidancepin a reviewed commit/artifact; never source an untrusted default branch
argv and parsingSpaces, empty values, option confusion, or accidental globbing alter behaviorarray-based argument helpers, exact option parsing, quoted path/argv contractsvalidate application-specific input and avoid eval
ConfigurationEnvironment/config values leak secrets or silently change behaviortyped config parsing, precedence/provenance, redaction, opt-in standard optionsclassify secrets, set least-privilege permissions, and review caller config
Paths/symlinksTraversal, symlink replacement, or wrong working directory changes a targetabsolute-root helpers, checked paths, explicit cleanup ownership, no implicit sudocontrol directory permissions, resolve security-sensitive symlinks, and avoid shared writable trees
Temporary files/deletionPredictable temp names or broad deletion destroys datamanaged temp paths, idempotent cleanup, marker-scoped edits, status-preserving trapskeep temp roots private and never pass untrusted deletion targets
SubprocessesInjection or lost exit status from external commandsbase_std_run, argv arrays, explicit command readiness, propagated statusesdo not concatenate untrusted shell syntax or assume an external command is safe
Logs/secretsTokens or credentials appear in diagnosticsredaction and safe logging helpers; no secret persistence by defaultmark sensitive values, avoid set -x, and secure log destinations
Signals/lifecycleCleanup masks the real status or runs twiceLIFO hooks, shared EXIT dispatcher, idempotent teardown, signal-aware app lifecyclemake application cleanup idempotent and avoid replacing library traps blindly
Network/retriesRetry storms, credential forwarding, or ambiguous remote statebounded retry helpers, timeout/status contracts, checked gh/Git wrappersconfigure network policy, scopes, backoff limits, and remote trust
Vendoring/bundlesTampered or non-reproducible copies enter productiondeterministic bundle checks, release metadata, checksums, SBOM/provenance gatesverify the exact checksum/attestation before installation
Release supply chainMutable tags, unpinned actions, or compromised tooling publishes bad codepinned workflows/images/tools, immutable release process, artifact preflightprotect maintainer credentials and verify downstream pins

Security invariants

The libraries must not enable strict mode in the caller, mutate unrelated global state, log secret values by default, escalate privileges, or silently convert a failed external command into success. These invariants are tested where possible and reviewed where Bash cannot provide a complete isolation guarantee.

Residual risk and reporting

Race conditions in a hostile shared filesystem, malicious Bash startup files, compromised interpreters or external commands, and malicious code deliberately sourced by the caller remain out of scope. Report suspected violations using SECURITY.md, with a minimal reproducer and the exact commit or artifact identity.