Skip to content

ci: add actionlint to catch workflow script injection on PRs - #1030

Merged
pdettori merged 1 commit into
rossoctl:mainfrom
Ladas:fix/add-actionlint-ci
Mar 19, 2026
Merged

pdettori merged 1 commit into
rossoctl:mainfrom
Ladas:fix/add-actionlint-ci

Conversation

@Ladas

@Ladas Ladas commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

PR #933 introduced a command injection vulnerability in e2e-hypershift-pr.yaml by parsing ${{ github.event.comment.body }} in a bash run: block. CodeQL passed because it only scans Python, not workflow YAML. The vulnerability was only caught by OpenSSF Scorecard post-merge on main (alert #188).

Gap in CI

Check Scans workflow injection? Runs on PR? Blocks merge?
CodeQL No (Python only) Yes Yes
Scorecard Yes (Dangerous-Workflow) No (main only) No
Bandit No (Python only) Yes Yes
No check catches workflow injection on PRs

Fix

1. actionlint (reliable)

Add actionlint as a blocking PR check in security-scans.yaml:

  • Detects expression injection (${{ github.event.* }} in run: blocks)
  • Validates workflow syntax
  • Reports inline on PR via reviewdog
  • Fails the check on errors (fail_on_error: true)

2. Scorecard on PRs (experimental)

Add pull_request trigger to the existing Scorecard workflow:

  • Runs Dangerous-Workflow analysis on PRs (catches injection patterns)
  • Disables OpenSSF API publishing on PRs (no OIDC token in PR context)
  • Marked as TODO/experimental — if it causes issues with fork PRs or permissions, we can disable it and rely on actionlint alone

What this catches

Both checks would have flagged this unsafe pattern:

# UNSAFE — injectable via crafted comment body
run: |
  COMMENT="${{ github.event.comment.body }}"

The safe alternative:

# SAFE — comment body accessed in JavaScript context
uses: actions/github-script@v8
with:
  script: |
    const body = context.payload.comment.body;

Test plan

  • actionlint check appears in PR checks and passes
  • Scorecard check appears in PR checks and passes
  • Verify actionlint would flag ${{ github.event.comment.body }} in a shell run: block

PR rossoctl#933 introduced a command injection vulnerability that CodeQL missed
(it only scans Python, not workflow YAML). Scorecard caught it post-merge
but by then the vulnerability was on main.

Changes:
- Add actionlint as blocking PR check (detects expression injection in
  run: blocks, validates workflow syntax, reports inline via reviewdog)
- Add pull_request trigger to Scorecard (runs Dangerous-Workflow analysis
  on PRs, disables OpenSSF API publishing since no OIDC on PR context)

Both checks would have caught the injection in rossoctl#933 before merge.

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@Ladas
Ladas force-pushed the fix/add-actionlint-ci branch from 2b0eed3 to b2f2823 Compare March 18, 2026 08:57

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Addresses a real security gap (alert #188): CodeQL misses workflow YAML injection, Scorecard only runs post-merge. The actionlint addition is well-targeted — expression injection detection is exactly what's missing. The Scorecard-on-PR addition is appropriately marked experimental. All checks pass, actions are SHA-pinned, DCO signed-off.

Areas reviewed: CI/GitHub Actions, Security
Commits: 1, signed-off ✓
CI status: All passing (E2E HyperShift pending — requires maintainer trigger, expected)

with:
fail_on_error: true
# Only report issues on lines changed in the PR (not pre-existing)
filter_mode: diff_context

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion: Missing pull-requests: write permission for reporter: github-pr-review. Without it, reviewdog can't post inline PR annotations when actionlint finds issues — the job will still fail and block the PR, but contributors won't see why without digging into the Actions log.

Consider adding:

permissions:
  contents: read
  pull-requests: write

@pdettori
pdettori merged commit f207cf5 into rossoctl:main Mar 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants