Skip to content

fix: pass SNAPSHOT as env var to prevent shell injection (RSPEED-3360) - #18

Closed
Lifto wants to merge 1 commit into
mainfrom
fix/rspeed-3360-snapshot-env-var
Closed

fix: pass SNAPSHOT as env var to prevent shell injection (RSPEED-3360)#18
Lifto wants to merge 1 commit into
mainfrom
fix/rspeed-3360-snapshot-env-var

Conversation

@Lifto

@Lifto Lifto commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Fixes shell injection vulnerability in the extract-server-image task (RSPEED-3360, CWE-78, CVSS 6.4).

Problem

The SNAPSHOT pipeline parameter was interpolated directly into a bash script via Tekton variable substitution inside a heredoc. Since Tekton performs $(params.*) replacement textually before the shell runs, an attacker who can influence the SNAPSHOT value could inject a literal newline followed by EOF to terminate the heredoc early and append arbitrary shell commands.

Fix

Pass SNAPSHOT via steps[].env[].value: $(params.SNAPSHOT) and reference it as "$SNAPSHOT" inside the script, following Tekton security guidance on variable substitution.

Before:

script: |
  cat << 'EOF' | jq -r '.components[0].containerImage' ...
  $(params.SNAPSHOT)
  EOF

After:

env:
  - name: SNAPSHOT
    value: $(params.SNAPSHOT)
script: |
  echo "$SNAPSHOT" | jq -r '.components[0].containerImage' ...

Testing

This pipeline has no local test harness — it runs on Tekton in the CI cluster. The fix is a mechanical substitution (heredoc interpolation → env var), and the pipeline behavior is unchanged: SNAPSHOT JSON is still parsed by jq to extract the container image URL.

Post-merge validation: We will monitor the next CI run that triggers this pipeline and revert if the change causes failures.

Jira: RSPEED-3360

Pass the Tekton SNAPSHOT parameter via step env instead of
interpolating it directly into the script body. This prevents
heredoc termination injection (CWE-78, CVSS 6.4) where a
crafted SNAPSHOT value could escape the heredoc and execute
arbitrary commands in the CI container.

Before: $(params.SNAPSHOT) interpolated into bash heredoc
After:  $(params.SNAPSHOT) passed as env var, referenced as "$SNAPSHOT"
@Lifto
Lifto requested a review from a team as a code owner July 21, 2026 16:08
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: rhel-lightspeed/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: b758ee64-bd10-4ca6-995e-2462b4e381c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rspeed-3360-snapshot-env-var

Comment @coderabbitai help to get the list of available commands.

@samdoran

Copy link
Copy Markdown
Member

Duplicate of #14.

@samdoran samdoran closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants