Skip to content

fix: 🔒 Avoid parsing comment body via shell - #1012

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
evaline-ju:injection-mitigation
Mar 17, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
evaline-ju:injection-mitigation

Conversation

@evaline-ju

@evaline-ju evaline-ju commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Comment body was being parsed directly in shell script, making this vulnerable to shell injections via /run-e2e commands

Fixes https://github.com/kagenti/kagenti/security/code-scanning/188

@evaline-ju

Copy link
Copy Markdown
Contributor Author

/run-e2e

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Mar 17, 2026
@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @evaline-ju
Commit: b5d86a5be8c4ef0e9a88e881a7f9c6cf3ceb2d37
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: b5d86a5be8c4ef0e9a88e881a7f9c6cf3ceb2d37
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@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.

Clean, focused security fix that eliminates a shell injection vulnerability in the E2E workflow. The approach — replacing bash parsing with JavaScript via actions/github-script — is the recommended GitHub Actions pattern. SHA pinning is consistent with the rest of the file, and the regex produces functionally equivalent results.

Areas reviewed: CI/GitHub Actions, Security
Commits: 1 commit, signed-off: ✅
CI status: All pass except E2E HyperShift (the workflow being modified — may be unrelated)

Verdict: APPROVE with one optional suggestion

@github-actions github-actions Bot removed the safe-to-test Maintainer reviewed - safe to run E2E tests label Mar 17, 2026
@github-actions

Copy link
Copy Markdown

New Commits Detected

The safe-to-test label has been automatically removed because new commits were pushed.

New HEAD: a40de54

For maintainers: Please review the new changes and comment /run-e2e to trigger E2E tests.

Security checklist

Before running E2E tests, verify the PR does NOT contain:

  • Changes to .github/workflows/ that bypass security
  • Changes to .github/scripts/ that could exfiltrate secrets
  • curl, wget, or nc commands to external URLs in scripts
  • Base64 encoding of environment variables
  • Printing secrets to logs (echo $SECRET)
  • Suspicious package installations

This is an automated security measure to prevent TOCTOU attacks

@evaline-ju

Copy link
Copy Markdown
Contributor Author

/run-e2e --extensions-ref test/kind-e2e-workflow

@github-actions github-actions Bot added the safe-to-test Maintainer reviewed - safe to run E2E tests label Mar 17, 2026
@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Started

Triggered by: @evaline-ju
Commit: a40de549c940ca60485eb328b8dc90141ec83849
Workflow Run: View logs

Tests are running on OpenShift 4.20.11. This typically takes 30-45 minutes.


To re-run tests after new commits, comment /run-e2e again.

@github-actions

Copy link
Copy Markdown

E2E HyperShift Tests Failed

Commit: a40de549c940ca60485eb328b8dc90141ec83849
Result: Tests failed - please check the logs
Workflow Run: View logs


To re-run tests after fixing issues, comment /run-e2e again.

@evaline-ju

Copy link
Copy Markdown
Contributor Author

e2e hypershift tests seem to be struggling, and also appear to be running old versions of the script anyway

@pdettori
pdettori merged commit 54d3f18 into rossoctl:main Mar 17, 2026
19 checks passed
Ladas added a commit to Ladas/kagenti that referenced this pull request Mar 18, 2026
The bash-based comment parser used ${{ github.event.comment.body }}
in shell context, which is vulnerable to command injection (same issue
fixed by rossoctl#1012 for --extensions-ref).

Rewrite the entire parser using actions/github-script (JavaScript)
where comment body is accessed via context.payload.comment.body safely.
Add strict regex validation for repo names and ref patterns.

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Ladas added a commit to Ladas/kagenti that referenced this pull request Mar 18, 2026
build.yaml: Move github.ref_name into env var to prevent shell injection
via crafted git tags (e.g., v$(malicious-command)).

cleanup-stale-hypershift-clusters.yaml: Move github.event.inputs.*
into env vars to prevent injection via workflow_dispatch inputs.

Both follow the pattern from rossoctl#1012: never interpolate user-controlled
GitHub context values directly into shell run: blocks.

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Ladas added a commit to Ladas/kagenti that referenced this pull request Mar 19, 2026
The bash-based comment parser used ${{ github.event.comment.body }}
in shell context, which is vulnerable to command injection (same issue
fixed by rossoctl#1012 for --extensions-ref).

Rewrite the entire parser using actions/github-script (JavaScript)
where comment body is accessed via context.payload.comment.body safely.
Add strict regex validation for repo names and ref patterns.

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
Ladas added a commit to Ladas/kagenti that referenced this pull request Mar 19, 2026
build.yaml: Move github.ref_name into env var to prevent shell injection
via crafted git tags (e.g., v$(malicious-command)).

cleanup-stale-hypershift-clusters.yaml: Move github.event.inputs.*
into env vars to prevent injection via workflow_dispatch inputs.

Both follow the pattern from rossoctl#1012: never interpolate user-controlled
GitHub context values directly into shell run: blocks.

Signed-off-by: Ladislav Smola <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Ladislav Smola <[email protected]>
@evaline-ju
evaline-ju deleted the injection-mitigation branch April 17, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Maintainer reviewed - safe to run E2E tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants