Skip to content

ci: fix artifact-injection RCE in workflow_run privileged consumer - #48

Merged
GirishKadirisani merged 1 commit into
qualcomm:mainfrom
hasiburr-qti:fix-workflow-rce-vulnerability
Sep 22, 2026
Merged

GirishKadirisani merged 1 commit into
qualcomm:mainfrom
hasiburr-qti:fix-workflow-rce-vulnerability

Conversation

@hasiburr-qti

Copy link
Copy Markdown
Contributor

Security fix — High Risk (AppSec)

This PR closes the artifact-injection RCE reported against the IMSDK_UAT_Compilation_PR workflow. The same vulnerability class was independently identified across qimsdk, camera-service, and gst-plugins-imsdk.

Attack path (now closed)

  1. Attacker forks the repo and injects a malicious build script into ci/build.sh
  2. The fork's pull_request event triggers IMSDK_UAT_Compilation (the producer), which uploads a pr-context artifact containing the fork's HEAD SHA
  3. The privileged consumer (workflow_run, secrets available) downloaded that artifact, trusted the SHA from it, checked out the fork commit, and ran ci/build.sh with S3_WEBAPP_TOKEN injected as an environment variable

Fixes applied

1. Fork gate with PRODUCTION environment approval
Two mutually exclusive gate jobs now precede all privileged work:

  • approve-fork: fork PRs pause here; a PRODUCTION-environment reviewer must inspect the fork diff and approve before init runs
  • approve-internal: same-repo PRs proceed immediately (no approval required)

2. Stop trusting the artifact SHA
pr-sha output now reads from github.event.workflow_run.head_sha — set by GitHub, not by the artifact. The artifact now carries only the PR number, which is harmless even if tampered.

3. Fix template-injection findings (zizmor)

  • approve-fork echo: HEAD_REPO passed via env:, referenced as ${HEAD_REPO} in the shell body
  • Report pending status: uses context.payload.workflow_run.head_sha (parsed event object) instead of a ${{ }} string literal
  • Report final status: SHA and build result moved to env: block and read via process.env inside the script body

4. Suppress dangerous-triggers warning
Added inline # zizmor: ignore[dangerous-triggers] on the on: line (zizmor requires the annotation on the same line as the finding). A block comment above the trigger documents all three active mitigations.

5. Guard report-status against spurious runs
Added needs.init.result != 'skipped' so no empty-SHA status API calls occur when the consumer correctly skips non-PR or fork-denied events.

Required follow-up actions (repo maintainers)

  • Create a PRODUCTION environment in repo Settings → Environments with required reviewers (the maintainers who should vet fork diffs)
  • Rotate S3_WEBAPP_TOKEN — treat it as compromised if any fork PRs ran against the old workflow
  • Rotate QUALCOMM_LINUX_PAT — same reason

🤖 Generated with Claude Code

…nsumer

The IMSDK_UAT_Compilation_PR workflow was vulnerable to remote code
execution via artifact injection (same class of issue reported against
qimsdk, validated by AppSec as High Risk).

Attack path (now closed):
- An attacker forks the repo and injects a malicious build script
- The fork's pull_request triggers the producer, which uploads a
  pr-context artifact containing the fork's HEAD SHA
- The privileged consumer (workflow_run, has secrets) downloaded that
  artifact, trusted the SHA from it, checked out the fork commit, and
  ran the build script with S3_WEBAPP_TOKEN injected as an env var

Fixes applied:

1. Fork gate with PRODUCTION environment approval
   Two new mutually-exclusive gate jobs replace the single unguarded
   init condition:
   - approve-fork: fork PRs pause here; a PRODUCTION environment
     reviewer must inspect and approve before any privileged work runs
   - approve-internal: same-repo PRs proceed immediately

2. Stop trusting the artifact SHA
   pr-sha output now reads from github.event.workflow_run.head_sha
   (set by GitHub, not by the artifact). The artifact now carries
   only the PR number, which is harmless.

3. Fix template-injection findings (zizmor)
   - approve-fork echo: value moved to env: block, referenced as
     ${HEAD_REPO} in the shell body — never via ${{ }} in run:
   - Report pending status: replaced "${{ steps.pr.outputs.sha }}"
     string literal with context.payload.workflow_run.head_sha
   - Report final status: pr-sha and build result moved to env: vars
     and read via process.env inside the script body

4. Suppress dangerous-triggers warning (zizmor)
   Added inline # zizmor: ignore[dangerous-triggers] annotation on
   the on: line. A block comment above documents the three mitigations
   that make this specific use of workflow_run safe.

5. Guard report-status against spurious runs
   Added needs.init.result != 'skipped' so no empty-SHA status API
   calls are made when the consumer correctly skips non-PR or
   fork-denied events.

The PRODUCTION environment must have required reviewers configured.
Maintainers should inspect the fork diff before approving.

Signed-off-by: Hasibur Rahman Mohammed <hasiburr@qti.qualcomm.com>
@GirishKadirisani
GirishKadirisani merged commit 6181d70 into qualcomm:main Sep 22, 2026
15 of 16 checks passed
@hasiburr-qti
Hasibur Rahman Mohammed (hasiburr-qti) deleted the fix-workflow-rce-vulnerability branch September 22, 2026 11:04
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