Skip to content

Harden CI/CD workflows: fix secret exposure, script injection, and pin all actions to SHA#762

Open
jprakash-db wants to merge 1 commit intomainfrom
jprakash-db/security-update
Open

Harden CI/CD workflows: fix secret exposure, script injection, and pin all actions to SHA#762
jprakash-db wants to merge 1 commit intomainfrom
jprakash-db/security-update

Conversation

@jprakash-db
Copy link
Contributor

@jprakash-db jprakash-db commented Mar 26, 2026

Summary

This PR addresses 2 CRITICAL and 4 HIGH supply chain security findings identified during a comprehensive CI/CD security audit of all GitHub Actions workflows. These fixes are required before the workflows can be safely re-enabled.

Critical Fixes

  • Eliminated pwn request in code-coverage.yml — Removed explicit ref / repository checkout of fork PR code that ran in a context with azure-prod secrets (DATABRICKS_TOKEN, DATABRICKS_HOST). An external attacker could have exfiltrated secrets by opening a malicious PR.
  • Fixed script injection in code-coverage.yml${{ github.event.pull_request.body }} was interpolated directly into run: shell steps, allowing arbitrary command execution via crafted PR descriptions. Moved all attacker-controllable expressions to env: blocks.

High Fixes

  • Moved dco-check.yml off self-hosted runners — Was using databricks-protected-runner-group on pull_request trigger, meaning any fork PR could execute code on internal infrastructure. Switched to ubuntu-latest.
  • Restricted publish-test.yml to main branch — Was triggering on on: [push] for all branches, publishing to Test PyPI on every push. Now restricted to push: branches: [main].
  • Pinned all 33 GitHub Action references to full SHA digests — Every uses: reference across all 8 workflows was using mutable tags (@v1, @v2, @v4, etc.) vulnerable to upstream tag mutation or account compromise. All now use immutable commit SHAs with version comments.
  • Added explicit least-privilege permissions: blocks — 7 of 8 workflows had no permissions: declaration (defaults can be overly broad). All now declare contents: read (and pull-requests: write only where needed for PR comments).

Files Changed (8 workflow files)

File Changes Applied
.github/workflows/code-coverage.yml Pwn request fix, script injection fix, SHA pinning
.github/workflows/dco-check.yml Self-hosted runner removal, SHA pinning, permissions
.github/workflows/publish-test.yml Branch restriction, SHA pinning, permissions
.github/workflows/code-quality-checks.yml SHA pinning, permissions
.github/workflows/integration.yml SHA pinning, permissions
.github/workflows/daily-telemetry-e2e.yml SHA pinning, permissions
.github/workflows/publish.yml SHA pinning, permissions
.github/workflows/publish-manual.yml SHA pinning, permissions

Test Plan

  • Verify YAML syntax is valid on all 8 workflow files
  • Confirm no remaining ${{ github.event.* }} expressions inside run: blocks (all moved to env:)
  • Confirm no remaining unpinned action references (all use full SHA with # tag comments)
  • Confirm dco-check.yml uses ubuntu-latest (no self-hosted runner references)
  • Confirm publish-test.yml only triggers on push to main
  • Confirm all workflows have explicit permissions: blocks
  • Re-enable workflows and verify they trigger correctly on a test PR

This pull request was AI-assisted by Isaac.

Copilot AI review requested due to automatic review settings March 26, 2026 06:39
@jprakash-db jprakash-db changed the title Updated the security Harden CI/CD workflows: fix secret exposure, script injection, and pin all actions to SHA Mar 26, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens GitHub Actions workflow security by pinning third-party actions to immutable commit SHAs and setting explicit job token permissions to reduce default privilege.

Changes:

  • Pin GitHub Actions used across CI/publish workflows to specific commit SHAs (instead of floating tags like v4/v5).
  • Add explicit permissions: blocks (primarily contents: read) to workflows to follow least-privilege.
  • Adjust a few workflow behaviors (notably the Test PyPI publish trigger and some shell env usage in coverage).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.github/workflows/publish.yml Add least-privilege permissions and pin actions by SHA for production publish.
.github/workflows/publish-test.yml Restrict trigger to main, add permissions, and pin actions by SHA for Test PyPI publish.
.github/workflows/publish-manual.yml Add permissions and pin actions by SHA for manual production publish.
.github/workflows/integration.yml Add permissions and pin actions by SHA for integration test workflows.
.github/workflows/dco-check.yml Add permissions, change runner, and pin actions by SHA for DCO enforcement.
.github/workflows/daily-telemetry-e2e.yml Add permissions and pin actions by SHA; pin artifact upload action.
.github/workflows/code-quality-checks.yml Add permissions and pin actions by SHA across unit/lint/type checks.
.github/workflows/code-coverage.yml Pin actions by SHA and refactor override/summary steps to use env vars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


permissions:
contents: read
pull-requests: write
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The workflow posts a PR comment via github.rest.issues.createComment, which requires the issues: write permission on GITHUB_TOKEN. With only pull-requests: write granted here, the comment step may fail with a 403. Add issues: write (and keep/remove pull-requests based on what actions-dco needs).

Suggested change
pull-requests: write
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

^ please address

Comment on lines +2 to +5
on:
push:
branches:
- main
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This changes the Test PyPI publish workflow trigger from running on every push to running only on pushes to main. Since the PR description doesn’t mention this behavior change, please confirm it’s intended (it will stop publishing from non-main branches).

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this is fine

runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
runs-on: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

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

why this?

Copy link
Contributor

@vikrantpuppala vikrantpuppala left a comment

Choose a reason for hiding this comment

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

couple of comments

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.

4 participants