devsecops.observer
← All labs

CI/CD input handling / Intermediate / 20–30 min

The commit message that became a command

A simulated CI step treats a commit message as shell code. Trace the boundary and restore literal handling of the untrusted input.

LAB IDdevsecops-02-ci-expression-injectionTRACK / devsecops.observer
Engineer investigating a secure delivery pipeline beside server equipment

The scenario

A harmless test message makes a local CI simulation print an unexpected marker. Repair the step so normal and special-character messages are printed literally rather than interpreted as shell code.

Mission objectives

  • Reproduce the unexpected output with the fixed test message.
  • Identify where the message enters generated shell code.
  • Preserve the message as data and verify multiple inputs without suppressing output.

Lab README

The commit message that became a command

A simulated CI runner inserts a commit message into a shell step. A harmless test message produces an unexpected marker. Repair the step so every message is printed literally, including messages containing shell syntax.

Before you begin

Use a disposable machine with Bash, Python 3 and Docker. Docker may download the Python image. This is a local simulation, not GitHub Actions. It uses only fixed synthetic messages and no credentials. Never substitute real messages or secrets into the deliberately vulnerable template.

The step runs in a read-only, unprivileged container without network access. The lab creates no persistent container, volume or host port. Docker retains the image for reuse.

Investigate

Run ./setup.sh to reproduce the symptom. Compare these two inputs:

./lab.sh normal
./lab.sh injection

Inspect step.sh and runner.py. The runner offers the same message as an environment variable. Change the step, not the runner or test cases. Keep printing the complete message. Run ./verify.sh after your change and ./teardown.sh when finished. Teardown does not reset edited files; re-extract the bundle to start over.

View Markdown source ↗

Get the lab

Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.

curl -fsSLO https://devops.download/labs/devsecops-02-ci-expression-injection.sh
less devsecops-02-ci-expression-injection.sh
bash devsecops-02-ci-expression-injection.sh
cd labs/devsecops-02-ci-expression-injection
./setup.sh

When you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.

Download the archive instead ↗

Need a nudge?

Hint #1

Compare the step template with the runner's replacement of the message placeholder.

Hint #2

The runner also provides the message as an environment variable. Quote its expansion in the shell step instead of placing message text in the script source.

Hint #3 · Related guide on opsbreakfix.com

Read the related guide ↗

Solved it?

Explore the related guide on opsbreakfix.com.

Continue to opsbreakfix.com ↗