Fix/security reliability workflow hardening - #1227
Open
james2177 wants to merge 4 commits into
Open
Conversation
Pin all third-party (non-actions/, non-github/) actions across all workflows to full commit SHAs with a version comment, matching the existing pattern used for aquasecurity/trivy-action and trufflesecurity/trufflehog. Mitigates supply-chain risk from a compromised maintainer account silently repointing a mutable tag (@v4, @v12, etc.) to malicious code. Pinned: dtolnay/rust-toolchain, hashicorp/setup-terraform, aws-actions/configure-aws-credentials, bridgecrewio/checkov-action, docker/setup-buildx-action, docker/login-action, docker/metadata-action, docker/build-push-action, slackapi/slack-github-action, actions-rs/toolchain, softprops/action-gh-release, orhun/git-cliff-action, peter-evans/create-pull-request, codecov/codecov-action, returntocorp/semgrep-action, gitleaks/gitleaks-action.
The release workflow's changelog job used the default GITHUB_TOKEN (contents: write) to commit and git push origin HEAD:main directly, bypassing branch protection and any review step for an automated bot. Replace the direct push with peter-evans/create-pull-request, which opens changelog-update/<tag> against main instead. protect-changelog.yml is updated with a documented, narrowly-scoped exception so only that bot-authored PR branch is allowed through; every other PR that touches CHANGELOG.md is still blocked as before.
ROLLBACK.md documented predictiq-terraform-state / prod/terraform.tfstate
and environments/prod.tfvars, none of which exist. The real backend
config (infrastructure/terraform/environments/{production,staging}/backend.hcl)
uses predictiq-terraform-state-production and
predictiq-terraform-state-staging with production/terraform.tfstate and
staging/terraform.tfstate keys, and the real tfvars file is
environments/production/terraform.tfvars. Following the runbook verbatim
during a real incident would have targeted a non-existent bucket/key.
Updates all state-bucket commands, tfvars paths, and prod resource-id
references so the runbook is copy-paste runnable against the real
infrastructure, and adds a bucket/key reference table per environment.
None of the 14 workflows set a job-level timeout, so a hung step (e.g. cargo install cargo-audit / soroban-cli, or a stuck Terraform apply) would run until GitHub's 360-minute default, wasting runner minutes and, for deploy.yml, blocking the DynamoDB state lock for other environments in the max-parallel: 1 matrix. Add timeout-minutes to every job across all workflows (default 20). The Terraform apply job in deploy.yml and the cargo-audit install jobs in dependency-scan.yml and test.yml are tightened to 15 since they're the jobs most likely to hang and most costly to block on. Note: test.yml has a pre-existing YAML issue unrelated to this change (clippy/oracle-quality-gate jobs are missing a `with:` key before `components: clippy` on the pinned dtolnay/rust-toolchain step); left as-is since it predates this branch and is out of scope for these issues.
|
@james2177 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses four medium-tier security and reliability issues found in .github/workflows/ and infrastructure documentation. Each fix is an isolated commit on fix/security-reliability-workflow-hardening.
Problem: Only aquasecurity/trivy-action and trufflesecurity/trufflehog were pinned to full commit SHAs. Every other third-party action across all 14 workflows was referenced by a mutable major-version tag (@v4, @v12, etc.) — a compromised maintainer account could silently repoint the tag to malicious code with zero diff visible in this repo.
What changed: Resolved the current commit SHA for each tag/branch via git ls-remote and re-pinned every third-party (non-actions/, non-github/) action, each with a trailing # vX comment for readability:
dtolnay/rust-toolchain, hashicorp/setup-terraform, aws-actions/configure-aws-credentials, bridgecrewio/checkov-action, docker/setup-buildx-action, docker/login-action, docker/metadata-action, docker/build-push-action, slackapi/slack-github-action, actions-rs/toolchain, softprops/action-gh-release, orhun/git-cliff-action, peter-evans/create-pull-request, codecov/codecov-action, returntocorp/semgrep-action, gitleaks/gitleaks-action.
actions/* and github/* actions were intentionally left on tags, per the issue's stated scope.
Verification: grep -rEn "uses: [a-zA-Z0-9.-]+/[a-zA-Z0-9.-]+@v[0-9]" .github/workflows now returns zero third-party matches.
Problem: release.yml's changelog job ran git commit + git push origin HEAD:main using the default GITHUB_TOKEN (contents: write), letting an automated bot push straight to main with no PR or review step — either requiring an undocumented branch-protection exception for github-actions[bot], or silently failing if protection is enforced.
What changed:
Problem: infrastructure/ROLLBACK.md's "Rollback via Terraform State" section referenced --bucket predictiq-terraform-state and --prefix prod/terraform.tfstate — neither of which exist. The
real backend config uses per-environment names.
What changed: Corrected every command in that section to match the actual backe
┌─────────────┬──────────────────────────────────────┬─────────────────────────
│ Environment │ Bucket │ Key │
├─────────────┼──────────────────────────────────────┼─────────────────────────
│ Staging │ predictiq-terraform-state-staging │ staging/terraform.tfstate │
├─────────────┼──────────────────────────────────────┼─────────────────────────
│ Production │ predictiq-terraform-state-production │ production/terraform.tfstate │
└─────────────┴──────────────────────────────────────┴─────────────────────────
Also fixed:
Problem: None of the 14 workflows set a job-level timeout. A hung step (cargo install cargo-audit/soroban-cli, or a stuck Terraform apply) would run until GitHub's 360-minute default — costly in runner minutes, and for deploy.yml's Terraform apply, it also holds a DynamoDB state lock, blocking every other environment behind it in the max-parallel: 1 matrix.
What changed:
Verification: grep -Lc timeout-minutes .github/workflows/*.yml returns no files.
Documentation
Added WORKFLOW_HARDENING.md at the repo root summarizing all four changes in one place, since each individual commit's diff is small (under 150 lines) and benefits from consolidatedcontext.
Known pre-existing issue (not fixed, out of scope)
While validating YAML syntax, found that test.yml's clippy and oracle-quality-gate jobs are missing a with: key before components: clippy on the dtolnay/rust-toolchain step — this is invalid YAML that predates this branch (present on main before any of these changes) and isn't part of the four issues being fixed here. Flagging it for a separate fix rather than foldingit into this PR's scope.
Testing
Per instructions, this PR was not built or run locally. Before merging, please:
Type of Change
Testing Done
Bundle Size
Checklist
docs/architecture.mdRelated Issues
Closes #1212
Closes #1213
Closes #1214
Closes #1215