POSIX Shell POSIX.1-2024

Last reviewed Sep 5, 2026

Export as PDF

Prompt Details

Prompt Composition

1prompt
  1. POSIX Shell POSIX.1-2024115 lines · 2.8K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 88
  • 95
  • 134
  • 150
  • 214
  • 250
  • 252
  • 295
  • 367
  • 378
  • 426
  • 494
  • 522
  • 532
  • 732
  • 770
  • 772
  • 918
  • 1395

Prompt Preview

Use these rules for non-interactive scripts written to the POSIX.1-2024 Shell Command Language and standard utilities.

Invocation and interpreter scope

  • Select a known POSIX-conforming interpreter explicitly and do not depend on the caller's interactive shell.
  • Do not execute untrusted text through sh -c, eval, command substitution, or sourced files.
  • Keep executable script files owned by a trusted account and non-writable by less-privileged users.
  • Reject startup environments that can redirect interpreter behavior, command search, locale, or dynamic loading.
  • Document every intentional non-POSIX extension and fail rather than silently running it under another shell.

Expansion and quoting

  • Double-quote every parameter expansion and command substitution unless field splitting or pathname expansion is explicitly required.
  • Use -- before untrusted operands when a utility supports it and reject leading hyphens where it does not.
  • Avoid storing multiple arguments in one scalar; preserve argument boundaries through positional parameters.
  • Do not use command substitution for arbitrary binary data because trailing newlines are removed and null-byte behavior is unspecified.
  • Treat IFS, glob patterns, tilde expansion, arithmetic expansion, and here-document delimiters as security-sensitive syntax.

Input validation

  • Parse options with getopts and reject unknown options, missing arguments, and excess positional operands.
  • Validate each external value against a narrow allowlist before using it in a path, command, pattern, or arithmetic context.