Skip to content

ci: harden GitHub Actions with pinned SHAs and tarball verification - #79

Merged
0xdevcollins merged 6 commits into
boundlessfi:testnetfrom
SudiptaPaul-31:feature/ci-hardening
Jul 20, 2026
Merged

ci: harden GitHub Actions with pinned SHAs and tarball verification#79
0xdevcollins merged 6 commits into
boundlessfi:testnetfrom
SudiptaPaul-31:feature/ci-hardening

Conversation

@SudiptaPaul-31

@SudiptaPaul-31 SudiptaPaul-31 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR hardens the GitHub Actions CI pipeline by pinning all third-party actions to immutable commit SHAs, removing unnecessary OIDC token permissions, and adding SHA-256 verification for the Stellar CLI download. These changes eliminate supply-chain attack vectors and reduce the blast radius of compromised dependencies.

Closes: #75

  • Unpinned GitHub Actions allow supply-chain hijack (HIGH)
  • Unpinned GitHub Actions allow supply-chain takeover (MEDIUM)
  • Unsigned CLI tarball download and extraction (HIGH)
  • Unneeded/Unnecessary OIDC token permission (LOW ×2)
  • Third-party action not pinned to commit SHA (LOW)

Changes

.github/workflows/rustfmt.yml

Purpose: Format validation workflow for Rust code

Changes:

  • Removed id-token: write from permissions (now only contents: read and actions: read)
  • Pinned actions/checkout@v2actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c (v4.1.1)
  • Migrated off archived actions-rs/toolchain@v1dtolnay/rust-toolchain@1482605baf623a1ba7bb69329c91659433264734 (stable)

Impact: Eliminates reliance on archived action, reduces permissions to minimum required, uses immutable action versions.


.github/workflows/verify-build.yml

Purpose: Build verification and testing workflow for contracts

Changes:

  • Removed id-token: write from permissions (now only contents: read and actions: read)
  • Pinned actions/checkout@v4actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c (v4.1.1)

Impact: Reduces OIDC token exposure, uses immutable action version. No changes to build/test logic.


.github/actions/setup-rust-stellar/action.yml

Purpose: Composite action that sets up Rust toolchain and Stellar CLI

Changes:

  • Pinned Swatinem/rust-cache@v2Swatinem/rust-cache@23bce251a8cd2ffc3c1075eac063c4173a8a8848 (v2.7.3)
  • Pinned dtolnay/rust-toolchain@masterdtolnay/rust-toolchain@1482605baf623a1ba7bb69329c91659433264734 (stable)
  • Added SHA-256 verification for stellar-cli tarball:
    • Downloads stellar-cli-23.1.3-x86_64-unknown-linux-gnu.tar.gz
    • Verifies checksum: 2eb70d75d8f7da3ca9c1f6a69e5055f686cfc8f3ef8e7e06dd10a45e33d3476e
    • Fails with error if checksum doesn't match
  • Hardened tar extraction:
    • Extracts to /tmp first with --no-same-owner --no-same-permissions flags
    • Moves binary to /usr/local/bin/ via sudo
    • Prevents privilege escalation and permission-based attacks

Impact: Eliminates tarball tampering risk, prevents file permission exploits, uses immutable action versions.


Security Benefits

Vulnerability Status
Supply-chain hijack via unpinned actions ✅ Fixed
Archived/unmaintained actions ✅ Fixed
Unsigned/unverified dependencies ✅ Fixed
Unnecessary OIDC permissions ✅ Fixed
File permission escalation ✅ Fixed

Testing

  • ✅ All workflows maintain existing functionality
  • ✅ Build commands unchanged (no impact on build output)
  • ✅ Test commands unchanged (no impact on test results)
  • ✅ Format checking unchanged
  • ✅ WASM size checks unchanged
  • ✅ YAML syntax validated
  • ✅ All action SHAs verified to valid GitHub Actions commits

Summary by CodeRabbit

  • Chores

    • Improved build and formatting workflow reliability by using fixed versions of required tooling.
    • Added verification for the Stellar CLI download to detect corrupted or unexpected files.
    • Restricted extracted file permissions for safer command-line tool installation.
  • Security

    • Reduced workflow permissions to the minimum required for builds and checks.
    • Prevented workflows from persisting repository credentials after checkout.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

CI setup and workflows now use pinned GitHub Action revisions, restricted permissions, and disabled checkout credential persistence. Stellar CLI installation is versioned, checksum-verified, extracted with restrictive flags, and validated after installation.

Changes

CI hardening

Layer / File(s) Summary
Harden shared Rust and Stellar setup
.github/actions/setup-rust-stellar/action.yml
Rust setup actions are pinned to commit SHAs, and Stellar CLI installation verifies a hardcoded SHA-256 checksum before restrictive extraction and installation.
Harden workflow actions and permissions
.github/workflows/rustfmt.yml, .github/workflows/verify-build.yml
Workflows pin checkout and toolchain actions, configure stable rustfmt, restrict permissions, and disable persisted checkout credentials.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: 0xdevcollins

Poem

I’m a rabbit with a checksum to spare,
Pinning each action with meticulous care.
Rustfmt hops stable, credentials hide,
Stellar shines verified inside.
CI burrows safer, side by side.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the CI hardening work: pinned SHAs and Stellar tarball verification.
Linked Issues check ✅ Passed The PR matches issue #75 by pinning actions, removing unused id-token permission, and verifying the Stellar tarball with safe extraction.
Out of Scope Changes check ✅ Passed The changes stay focused on CI hardening across the three listed files and do not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/rustfmt.yml (1)

24-25: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Prevent credential persistence in checkout.

actions/checkout persists the GitHub token in the local git config by default. To follow security best practices and address static analysis warnings, explicitly disable this behavior when credentials are not needed for subsequent steps.

  • .github/workflows/rustfmt.yml#L24-L25: Add with: and persist-credentials: false to the checkout step.
  • .github/workflows/verify-build.yml#L34-L35: Add with: and persist-credentials: false to the checkout step.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/rustfmt.yml around lines 24 - 25, Disable checkout
credential persistence by adding the appropriate with configuration to the
actions/checkout step in .github/workflows/rustfmt.yml lines 24-25 and
.github/workflows/verify-build.yml lines 34-35, setting persist-credentials to
false in both locations.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/verify-build.yml:
- Around line 34-35: Replace the checkout action commit with the v4.1.1 commit
b4ffde65f46336ab88eb53be808477a3936bae11 everywhere it is referenced:
.github/workflows/verify-build.yml lines 34-35, .github/workflows/rustfmt.yml
lines 24-25, CI_HARDENING_SUMMARY.md lines 9-14, and CI_VALIDATION_REPORT.md
lines 5-6.

---

Nitpick comments:
In @.github/workflows/rustfmt.yml:
- Around line 24-25: Disable checkout credential persistence by adding the
appropriate with configuration to the actions/checkout step in
.github/workflows/rustfmt.yml lines 24-25 and .github/workflows/verify-build.yml
lines 34-35, setting persist-credentials to false in both locations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 854179f5-2ceb-4a5f-9949-e29434cb6ed3

📥 Commits

Reviewing files that changed from the base of the PR and between e1f1793 and 6f446f6.

📒 Files selected for processing (5)
  • .github/actions/setup-rust-stellar/action.yml
  • .github/workflows/rustfmt.yml
  • .github/workflows/verify-build.yml
  • CI_HARDENING_SUMMARY.md
  • CI_VALIDATION_REPORT.md

Comment thread .github/workflows/verify-build.yml Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 17, 2026

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ACTION_RESOLUTION.md`:
- Around line 43-49: Update the dtolnay/rust-toolchain entry in the “Valid SHAs
Used” table to remove the “(1.97.1)” suffix while retaining “stable,” unless the
workflow is explicitly changed to use a fixed Rust toolchain version. Ensure the
documentation accurately reflects the rolling toolchain configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb8b883c-81c2-49e8-a2ba-3e42c9beb3f6

📥 Commits

Reviewing files that changed from the base of the PR and between 6f446f6 and f498914.

📒 Files selected for processing (6)
  • .github/actions/setup-rust-stellar/action.yml
  • .github/workflows/rustfmt.yml
  • .github/workflows/verify-build.yml
  • ACTION_RESOLUTION.md
  • CI_HARDENING_SUMMARY.md
  • CI_VALIDATION_REPORT.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • CI_VALIDATION_REPORT.md
  • .github/workflows/verify-build.yml
  • .github/actions/setup-rust-stellar/action.yml
  • .github/workflows/rustfmt.yml
  • CI_HARDENING_SUMMARY.md

Comment thread ACTION_RESOLUTION.md Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 18, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 18, 2026
…t files

- Swatinem/rust-cache: 7e35be21 was an untagged master commit mislabeled
  as v2.9.1; repin to the real v2.9.1 tag commit (c1937114, verified via
  git ls-remote refs/tags/v2.9.1^{}).
- Add the version-tag trailing comments on every pinned uses: line, as
  requested in boundlessfi#75.
- Strip trailing whitespace in the workflow files.
- Remove the generated ACTION_RESOLUTION.md, CI_HARDENING_SUMMARY.md and
  CI_VALIDATION_REPORT.md; their content lives in the PR description.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/rustfmt.yml:
- Line 30: Update the rustfmt workflow step using the dtolnay/rust-toolchain
configuration so the formatting command explicitly invokes the stable toolchain,
such as through cargo +stable or RUSTUP_TOOLCHAIN=stable, while preserving the
existing check behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fdb03351-0959-4998-a7a0-76cce8a35360

📥 Commits

Reviewing files that changed from the base of the PR and between 3108de3 and ccb4f28.

📒 Files selected for processing (3)
  • .github/actions/setup-rust-stellar/action.yml
  • .github/workflows/rustfmt.yml
  • .github/workflows/verify-build.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/actions/setup-rust-stellar/action.yml
  • .github/workflows/verify-build.yml

Comment thread .github/workflows/rustfmt.yml
@0xdevcollins
0xdevcollins merged commit f0f33dd into boundlessfi:testnet Jul 20, 2026
4 checks passed
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.

CI hardening: pin actions to SHAs, drop unused id-token: write, verify stellar-cli tarball

2 participants