glsec

Rules / GL024

GL024 Shell pipe without set -o pipefail

Severity: warn
OWASP: CICD-SEC-7 – Insecure System Configuration

What glsec checks

glsec flags jobs that use shell pipes (|) in their scripts without enabling pipefail. By default, a pipeline's exit code is the exit code of the last command in the chain. If any earlier command fails, the failure is silently discarded and the job continues.

This is especially dangerous in security-sensitive contexts:

Analogous to ansible-lint's risky-shell-pipe rule.

Trigger example

build:
  script:
    - curl https://install.example.com/tool.sh | bash   # if curl fails, bash runs on empty input
    - generate-config | tee config.yml                  # if generate-config fails, job still passes

Safe alternatives

Set once at the top of the script:

build:
  script:
    - set -o pipefail
    - generate-config | tee config.yml
    - curl https://install.example.com/tool.sh | bash

Set as part of a combined shell options header:

build:
  script:
    - set -euo pipefail
    - generate-config | tee config.yml

Set inline per line:

build:
  script:
    - set -o pipefail && generate-config | tee config.yml

Set in before_script to apply to all jobs using the same template:

.base:
  before_script:
    - set -o pipefail

build:
  extends: .base
  script:
    - generate-config | tee config.yml

Notes

Documentation for glsec 1.23.0. Source of this page · Rule implementation