Skip to content

ci: pass workflow inputs through env in bump-gitstream-core [skip ci] - #605

Merged
Gil-elhayani-security merged 1 commit into
developfrom
sec/LINSEC-2148-workflow-inputs-via-env
Nov 23, 2026
Merged

Gil-elhayani-security merged 1 commit into
developfrom
sec/LINSEC-2148-workflow-inputs-via-env

Conversation

@Gil-elhayani-security

@Gil-elhayani-security Gil-elhayani-security commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

In bump-gitstream-core.yml, workflow inputs and values derived from them were written into run: scripts with ${{ }} expressions. This PR passes them through env: and reads them as regular shell variables, in line with GitHub's hardening guidance for Actions.

No behaviour change for normal inputs. Only .github/workflows/bump-gitstream-core.yml is touched.

Changes

  • inputs.version, inputs.reviewer and inputs.description are passed through step-level env: (INPUT_VERSION, REVIEWER, PR_DESCRIPTION).
  • ${{ env.VERSION }}, ${{ env.BRANCH_NAME }}, ${{ env.REVIEWER_ARG }} and ${{ env.LABEL_ARG }} inside run: are replaced with $VERSION, $BRANCH_NAME, $REVIEWER_ARG and $LABEL_ARG. They were already environment variables (set through $GITHUB_ENV).
  • The gh pr create --title argument moves from single to double quotes (backticks escaped) so $VERSION expands.

Step names and the Output PR URL step are unchanged.

Recommendation (not in this PR): validate the input format

This PR is kept to the minimal change. As a follow-up, I recommend adding a format check in the first steps, so the workflow fails early when a value is not in the format we expect, instead of carrying it into $GITHUB_ENV, the branch name and the gh pr create arguments:

      - name: Set version to ENV
        env:
          INPUT_VERSION: ${{ inputs.version }}
        run: |
          if ! [[ "$INPUT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
            echo "Invalid version, expected a format like 2.1.230" >&2
            exit 1
          fi
          ...

      - name: Set reviewer
        env:
          REVIEWER: ${{ inputs.reviewer || github.actor }}
        run: |
          if ! [[ "$REVIEWER" =~ ^[0-9A-Za-z-]+$ ]]; then
            echo "Invalid reviewer, expected a GitHub username" >&2
            exit 1
          fi
          ...

Why it is worth adding:

  • VERSION and BRANCH_NAME are written to $GITHUB_ENV one per line, so the value should be a single line with version characters only.
  • $REVIEWER_ARG is expanded unquoted on purpose (it holds --reviewer <name>), so the reviewer should be a single word.

The patterns above are a suggestion; adjust them if pre-release versions or team reviewers (org/team) need a different format.

Testing

Not executed: the workflow only runs on workflow_dispatch and opens a real bump PR. Suggested check before merge: run "Bump gitstream-core" from this branch with the current gitstream-core version and close the PR it opens.

Ticket: LINSEC-2148

🤖 Generated with Claude Code

✨ PR Description

Purpose: Enhance security and stability in bump-gitstream-core.yml by passing workflow inputs via environment variables.

Main changes:

  • Replaced direct ${{ inputs }} and ${{ env }} expansion in shell scripts with environment variables
  • Updated Create PR step to use PR_DESCRIPTION env var for description file
  • Migrated git push and gh pr create to use shell variables for arguments

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

Pass inputs.version, inputs.reviewer and inputs.description to the
run scripts through step-level env variables, and read the values
already stored in GITHUB_ENV as shell variables instead of ${{ env.* }}
expressions.

LINSEC-2148

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MishaKav
MishaKav requested a balanced review from Copilot November 23, 2026 12:45

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed OSS Licenses high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@linearb linearb Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ PR Review

The PR moves workflow inputs from inline ${{ }} expressions into env:, which removes direct script injection in the run: bodies. However, the values are still written unvalidated into $GITHUB_ENV and into an unquoted argument list, so injection paths remain.

2 issues detected:

🔒 Security - Unvalidated, potentially multi-line input is appended to the `$GITHUB_ENV` file, allowing environment variable injection. 🛠️

Details: INPUT_VERSION is written straight into $GITHUB_ENV with echo. A multi-line version value (for example 1.0.0\nNODE_OPTIONS=--require ./x.js or LD_PRELOAD=...) adds arbitrary environment variables to every later step. Those steps include npm install, npm run all and the step that uses CI_USER_GIT_TOKEN. The PR description presents this as hardening, yet this path to code execution in later steps is still open.

File: .github/workflows/bump-gitstream-core.yml (47-48)

🛠️ A suggested code correction is included in the review comments.

🔒 Security - User-controlled input is embedded in an env var that is later word-split into command-line arguments, without validation.

Details: REVIEWER is stored as --reviewer $REVIEWER in $GITHUB_ENV with no validation. It is later expanded unquoted as $REVIEWER_ARG in gh pr create. A reviewer value containing spaces or newlines adds extra gh flags, such as --base, --head or --body, or breaks the env file. A newline in the value can also inject extra env vars via $GITHUB_ENV.

File: .github/workflows/bump-gitstream-core.yml (59-61)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how

Comment on lines +47 to +48
echo "VERSION=$INPUT_VERSION" >> "$GITHUB_ENV"
echo "BRANCH_NAME=bump-gitstream-core-to-$INPUT_VERSION" >> "$GITHUB_ENV"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security - GITHUB_ENV injection via input: Validate INPUT_VERSION against a strict semver regex and fail before writing to $GITHUB_ENV. Alternatively, skip $GITHUB_ENV for these values and pass them via step-level env: from inputs.version.

Suggested change
echo "VERSION=$INPUT_VERSION" >> "$GITHUB_ENV"
echo "BRANCH_NAME=bump-gitstream-core-to-$INPUT_VERSION" >> "$GITHUB_ENV"
if [[ ! "$INPUT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "::error::Invalid version: must be a valid semver string"
exit 1
fi
echo "VERSION=$INPUT_VERSION" >> "$GITHUB_ENV"
echo "BRANCH_NAME=bump-gitstream-core-to-$INPUT_VERSION" >> "$GITHUB_ENV"
Is this review accurate? Use 👍 or 👎 to rate it

If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over

@linearb linearb Bot added the 1 min review label Nov 23, 2026
@MishaKav MishaKav changed the title ci: pass workflow inputs through env in bump-gitstream-core ci: pass workflow inputs through env in bump-gitstream-core [skip ci] Nov 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

No active review issues are recorded for the workflow input-handling changes.

No open issues 🎉

What changed in this PR

This PR hardens the gitstream-core dependency bump workflow by passing inputs through environment variables rather than interpolating them directly into shell scripts, while preserving behavior for normal inputs.

Changes:

  • Passes version, reviewer, and description inputs through step-level environment variables.
  • Uses shell variables in npm, Git, and PR creation commands, with updated quoting for package, branch, and title arguments.
File Description
.github/​workflows/​bump-gitstream-core.yml Replaces direct input interpolation with environment-variable access in shell commands.

Review effort: Balanced

@MishaKav MishaKav left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 💪

@Gil-elhayani-security
Gil-elhayani-security merged commit 1d7d72c into develop Nov 23, 2026
20 checks passed
@Gil-elhayani-security
Gil-elhayani-security deleted the sec/LINSEC-2148-workflow-inputs-via-env branch November 23, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants