Rule library
Browse Bash, POSIX sh, Zsh, Dockerfile, CI and PowerShell rules: explanations, severity, suggested safeguards and exact references in script review guides.
Instant-check rules and reference topics for the deeper AI review, with evidence limits and suggested safeguards. Reference topics are not additional browser checks. For ShellCheck codes see the ShellCheck reference.
rm -rf with a variable path
Severity: high
Recursive/forced rm using a variable path. If the variable is empty or unset, this can delete far more than intended.
Suggested safeguard: Guard the path: use "${dir:?dir is required}" and quote the expansion, e.g. rm -rf "${dir:?}/subdir".
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2115 referencePiping a download into a shell
Severity: high
Remote content is piped straight into a shell. A compromised or partially downloaded response executes with your privileges.
Suggested safeguard: Download to a file, verify it (checksum or signature), inspect it, then execute it as a separate step.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
eval with an expansion
Severity: high
eval is used with an expansion. Any attacker-controlled part of that string becomes executable code.
Suggested safeguard: Replace eval with an array, a case statement, or indirect expansion (${!name}) — none of which re-parse data as code.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2294 referenceWorld-writable chmod 777
Severity: medium
chmod 777 makes the target world-writable, so any local account can modify or replace it.
Suggested safeguard: Grant the narrowest mode that works — 755 for executables, 644 for data, 700 for private state.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
cd without a failure guard
Severity: high
cd without a failure guard. If the directory does not exist the script keeps running in the wrong working directory.
Suggested safeguard: Write cd "$dir" || exit 1 (or set -e plus a quoted path) so the script stops instead of operating on the wrong tree.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2164 referenceUnquoted variable expansion
Severity: medium
Unquoted variable expansion. Values containing spaces or glob characters get word-split and globbed before the command sees them.
Suggested safeguard: Wrap the expansion in double quotes: "$var" / "${arr[@]}".
Applies to: Bash, POSIX sh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2086 referenceLegacy backtick substitution
Severity: low
Legacy backtick command substitution. It nests badly and handles backslashes differently from the modern form.
Suggested safeguard: Use $(command) instead of `command`.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2006 referenceSingle-bracket test in Bash
Severity: low
Single-bracket [ ] test. It word-splits its operands, so an empty or spaced variable produces a syntax error at runtime.
Suggested safeguard: In Bash scripts prefer [[ ... ]], which does not word-split or glob its operands.
Applies to: Bash
Non-portable echo -e
Severity: low
echo -e is not portable — it is undefined in POSIX sh and behaves differently across shells and /bin/echo builds.
Suggested safeguard: Use printf '%b\n' "$value" for escape handling that behaves the same everywhere.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC3037 referencesudo inside a script
Severity: medium
The script invokes sudo. It will either prompt interactively in the middle of a run or silently require passwordless sudo.
Suggested safeguard: Check privileges up front (if [[ $EUID -ne 0 ]]) and fail with a clear message, rather than escalating mid-script.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
Predictable /tmp path
Severity: medium
Fixed path under /tmp. Predictable temp paths are a symlink-attack vector on shared machines and collide between concurrent runs.
Suggested safeguard: Create the file with mktemp (or mktemp -d) and remove it in a trap.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2129 referenceParsing ls output
Severity: low
Parsing the output of ls. Filenames containing spaces or newlines break the pipeline.
Suggested safeguard: Use a glob or find -print0 with a while IFS= read -r -d '' loop.
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2012 referenceread without -r
Severity: low
read without -r mangles backslashes in the input.
Suggested safeguard: Use read -r (and IFS= read -r line when preserving leading whitespace).
Applies to: Bash, POSIX sh, Zsh, Dockerfile, GitHub Actions workflow, GitLab CI config
SC2162 reference[[ ]] in a POSIX sh script
Severity: medium
[[ ]] is a Bash/Zsh keyword. dash, ash and BusyBox sh report "[[: not found".
Suggested safeguard: Use [ ... ] with quoted operands, or switch the shebang to bash.
Applies to: POSIX sh
Arrays in a POSIX sh script
Severity: medium
POSIX sh has no arrays; this line is a syntax error in dash.
Suggested safeguard: Use positional parameters (set -- a b c) or a newline-separated string.
Applies to: POSIX sh
function keyword in POSIX sh
Severity: medium
The function keyword is not POSIX.
Suggested safeguard: Define functions as name() { ...; }.
Applies to: POSIX sh
== inside [ ] in POSIX sh
Severity: medium
== inside [ ] is a Bash extension; POSIX test only knows =.
Suggested safeguard: Use a single = for string comparison.
Applies to: POSIX sh
source in POSIX sh
Severity: medium
source is a Bash builtin; POSIX sh uses the dot command.
Suggested safeguard: Replace source file with . ./file.
Applies to: POSIX sh
Here-string in POSIX sh
Severity: medium
Here-strings (<<<) are not POSIX.
Suggested safeguard: Use printf '%s\n' "$var" | cmd or a here-document.
Applies to: POSIX sh
$'...' quoting in POSIX sh
Severity: medium
ANSI-C quoting $'...' is not supported by every POSIX sh.
Suggested safeguard: Build the string with printf instead.
Applies to: POSIX sh
Bash-only builtins in a Zsh script
Severity: low
shopt, mapfile and readarray are Bash builtins and do not exist in Zsh.
Suggested safeguard: Use setopt for options and ${(f)"$(cmd)"} to split command output into lines.
Applies to: Zsh
Invoke-Expression on dynamic input
Severity: high
Invoke-Expression runs a string as code. Any untrusted part of it becomes executable — the PowerShell equivalent of eval.
Suggested safeguard: Call the command directly with splatted arguments (& $cmd @args) instead of building a string.
Applies to: PowerShell
Downloading and executing in one step
Severity: high
Remote content is downloaded and executed immediately, without verification.
Suggested safeguard: Save to a file, verify its hash or signature (Get-FileHash, Get-AuthenticodeSignature), then run it.
Applies to: PowerShell
ExecutionPolicy Bypass
Severity: medium
The script turns off the execution policy, removing a safety net against unsigned scripts.
Suggested safeguard: Sign the script or scope the policy narrowly (-Scope Process) and document why.
Applies to: PowerShell
Plain-text secret in ConvertTo-SecureString
Severity: high
A secret is converted from plain text, which usually means it is stored in the script or passed on the command line.
Suggested safeguard: Read secrets from a vault, Get-Credential or an environment variable set by your CI secret store.
Applies to: PowerShell
Errors silenced with SilentlyContinue
Severity: medium
Errors are silenced, so failures pass unnoticed.
Suggested safeguard: Use -ErrorAction Stop with try/catch and handle the specific failures you expect.
Applies to: PowerShell
Untrusted ${{ }} expression inside run
Severity: high
An attacker-controllable ${{ }} value is pasted into the shell script before it runs. A crafted PR title or branch name becomes shell code.
Suggested safeguard: Pass the value through env: (e.g. env: TITLE: ${{ github.event.pull_request.title }}) and use "$TITLE" in the script.
Applies to: GitHub Actions workflow
Base image without a pinned tag
Severity: medium
The base image uses :latest or no tag, so builds change silently when the upstream image is updated.
Suggested safeguard: Pin a version tag, ideally with a digest: FROM debian:12-slim@sha256:...
Applies to: Dockerfile
ADD with a remote URL
Severity: medium
ADD downloads the URL without verifying it.
Suggested safeguard: Use ADD --checksum=sha256:... or RUN curl with a checksum check.
Applies to: Dockerfile
apt-get install without cleanup
Severity: low
The apt package lists stay in the layer and bloat the image.
Suggested safeguard: End the same RUN with && rm -rf /var/lib/apt/lists/*.
Applies to: Dockerfile
apt-get install without -y
Severity: high
apt-get install waits for confirmation, which fails a non-interactive build.
Suggested safeguard: Add -y (and --no-install-recommends to keep the image small).
Applies to: Dockerfile
Container runs as root
Severity: medium
No USER instruction, so the container process runs as root.
Suggested safeguard: Create an unprivileged user and switch to it with USER app before CMD/ENTRYPOINT.
Applies to: Dockerfile
Missing shebang
Severity: medium
No shebang on the first line, so the interpreter depends on how the file is invoked.
Suggested safeguard: Add #!/usr/bin/env bash, #!/bin/sh or #!/usr/bin/env zsh as the first line.
Applies to: Bash, POSIX sh, Zsh
SC2148 reference/bin/sh shebang with Bash syntax
Severity: medium
The shebang says /bin/sh but the script uses Bash-only syntax, which fails where /bin/sh is dash.
Suggested safeguard: Change the shebang to bash or rewrite the constructs in POSIX form.
Applies to: POSIX sh
Missing strict mode
Severity: medium
Without set -e, -u (and pipefail in Bash/Zsh) the script continues after failed commands.
Suggested safeguard: Add set -euo pipefail (set -eu in POSIX sh) near the top.
Applies to: Bash, POSIX sh, Zsh
Unbalanced if/fi
Severity: high
The number of if and fi keywords differs, which is a syntax error.
Suggested safeguard: Close every if with a matching fi.
Applies to: Bash, POSIX sh, Zsh
Unbalanced do/done
Severity: high
The number of do and done keywords differs, which is a syntax error.
Suggested safeguard: Close every for/while/until body with done.
Applies to: Bash, POSIX sh, Zsh
Set-StrictMode not enabled
Severity: low
Without Set-StrictMode, typos in variable names silently evaluate to $null.
Suggested safeguard: Add Set-StrictMode -Version Latest and $ErrorActionPreference = 'Stop'.
Applies to: PowerShell
Alpine package versions and reproducibility
Severity: medium
An apk add command without an explicit package version resolves the version available in its configured repositories. For example, installing curl without a version pin can produce different versions between builds. The Dockerfile alone cannot verify which versions remain available or whether an example version is supported.
Suggested safeguard: When reproducibility is required, verify the repository and supported package version before specifying package=version. Use maintained repository snapshots where needed and plan security updates; do not copy an unverified example version into production.
Applies to: Dockerfile
Alpine package cache management
Severity: info
The apk add --no-cache option avoids retaining the package-index cache in the image. Its presence is a positive resource-management observation, not an error. This flag does not pin package versions, remove every temporary file or prove the final image size.
Suggested safeguard: Keep --no-cache for installs that do not need a persistent local index cache. Assess other artifacts separately and remove temporary files in the instruction that creates them; no change is needed solely because --no-cache is already present.
Applies to: Dockerfile
Placeholder download URLs and unvalidated script content
Severity: medium
An example.com download URL is a documentation placeholder, not a verified installer source. A Dockerfile that downloads and invokes a script without checking its contents or integrity provides no evidence that the installer is safe. The remote contents and their behavior cannot be verified from this file.
Suggested safeguard: Replace placeholders with the intended maintained source, review a fixed version and verify a trusted checksum or signature before invocation. Keep illustrative examples clearly separated from production Dockerfiles.
Applies to: Dockerfile
Package-index drift and reproducible installs
Severity: medium
An unversioned apt install can resolve different package versions as repositories change. Pinning only the base digest does not pin package indexes. This is build reproducibility, not proof that installing a package twice is unsafe.
Suggested safeguard: Use a supported repository snapshot and explicit package versions when reproducibility is required, while planning security updates. Keep apt-get update and install together; do not switch distributions as a substitute for version control.
Applies to: Dockerfile
Container health checks
Severity: low
A missing HEALTHCHECK means the image declares no health probe. EXPOSE does not prove the application is an HTTP service; an orchestrator may configure its own probe outside this file.
Suggested safeguard: If a probe is needed, choose a command and endpoint supported by the actual application and final image. Return nonzero on failure and configure interval, timeout and start period.
Applies to: Dockerfile
Failure propagation in RUN commands
Severity: medium
Shell-form RUN uses the configured shell (normally /bin/sh on Linux). A pipeline normally returns the last command status, so a failed download can be masked by a successful shell. Bash pipefail is not supported by every /bin/sh.
Suggested safeguard: Separate download, verification and execution with && or explicit failure guards. Only use pipefail after choosing a shell that supports it; do not blindly add set -euo pipefail to /bin/sh.
Applies to: Dockerfile
Build-context exclusions and secrets
Severity: medium
COPY . . can copy every non-excluded file from the build context. A Dockerfile alone cannot prove whether .dockerignore excludes credentials, repository metadata or local dependencies.
Suggested safeguard: Inspect the actual build context and .dockerignore. Exclude sensitive and unnecessary files, copy only required paths and use build secret mounts instead of copying credentials.
Applies to: Dockerfile
Base distribution and package-manager compatibility
Severity: medium
apt-get requires a compatible Debian-family base; apk requires Alpine. A floating image tag or image name alone cannot verify the actual distribution, installed commands or future contents.
Suggested safeguard: Verify the pinned base image documentation and match installation commands to that distribution. Do not recommend a distribution switch without checking libc and application compatibility.
Applies to: Dockerfile
Commands available in the final image
Severity: medium
Build and runtime dependencies differ. Packages installed in a discarded stage are not automatically present in the final image; undeclared base-image contents cannot be verified from the Dockerfile.
Suggested safeguard: Check each stage, COPY --from and runtime command. Install only required runtime dependencies in the final stage and verify their supported versions.
Applies to: Dockerfile
External script dependencies and portability
Severity: medium
The dependencies, shell syntax and behavior of a downloaded script cannot be verified without its contents. Supported curl flags do not establish that the remote script is portable or safe.
Suggested safeguard: Review the exact version of the script, verify its integrity, document its shell and command requirements and retain an auditable source. Treat any unprovided script contents as unknown.
Applies to: Dockerfile
Dependency layers and build caching
Severity: low
Copying dependency manifests before application source can preserve an installation layer when source changes. Remote downloads in RUN follow normal layer-cache rules; curl does not by itself force a download on every build.
Suggested safeguard: Copy manifests and lockfiles before npm ci, then copy application code. Keep cleanup in the layer that creates artifacts and use multiple stages only when the application needs them.
Applies to: Dockerfile
Optional recommended apt packages
Severity: low
apt-get may install recommended packages in addition to direct dependencies, increasing image size. Whether these packages are unnecessary depends on the application.
Suggested safeguard: Consider --no-install-recommends after checking required functionality. Keep update, install and package-list cleanup in the same RUN instruction.
Applies to: Dockerfile
Instruction order and documented build intent
Severity: info
WORKDIR sets the location for subsequent instructions. Manifest-first copying before npm ci is normally intentional for caching, not evidence of a defect. Missing comments alone do not establish a functional problem.
Suggested safeguard: Explain unusual instruction ordering when needed. Preserve valid manifest-first caching and distinguish optional readability advice from verified build failures.
Applies to: Dockerfile
Container signals and graceful shutdown
Severity: medium
Exec-form CMD or ENTRYPOINT avoids an extra shell and allows the process to receive container signals. The application’s handling of SIGTERM cannot be verified without its source; a health check does not prove graceful shutdown.
Suggested safeguard: Use exec-form startup where appropriate and verify the application handles termination and closes resources. Assess health probes separately from signal handling.
Applies to: Dockerfile