Skip to content

Comments

Harden GitHub Actions workflows for security#52

Open
carlosmmatos wants to merge 3 commits intomainfrom
fix/gha-security-hardening
Open

Harden GitHub Actions workflows for security#52
carlosmmatos wants to merge 3 commits intomainfrom
fix/gha-security-hardening

Conversation

@carlosmmatos
Copy link
Contributor

Summary

This PR implements comprehensive security hardening for all GitHub Actions workflows based on a security audit. The changes follow GitHub's security best practices and address multiple critical, high, and medium severity issues.

Changes

Permissions Hardening

  • Added permissions: read-all at workflow level to all three workflows
  • Added explicit job-level permissions with least privilege principle
  • Reduced lint.yml permissions from 5 write scopes to 3 (removed actions, pull-requests, issues)

Action Pinning (Supply Chain Security)

  • Pinned actions/checkout to SHA 11bd71901bbe5b1630ceea73d27597364c9af683 (v4.2.2)
  • Pinned actionshub/chef-install to SHA 776a917c09d87c381d1d5342f83cd554223fa49c (v3.0.1)
  • Pinned nick-fields/retry to SHA ce71cc2ab81d554ebbe88c79ab5975992d79ba08 (v3.0.2)
  • Pinned sous-chefs/.github workflow to SHA 1bd0cd79d49e32c55efd9227776ad90afcb2d89b (2.0.1)

Critical Vulnerability Fix

  • Replaced pull_request_target with pull_request - The previous configuration could allow untrusted PR code to execute with access to repository secrets (race condition between label approval and force-push)

Environment Protection

  • Added environment: falcon-integration-testing to integration job
  • Secrets are now protected by environment approval gates

Additional Hardening

  • Added timeout-minutes: 60 to prevent hung jobs
  • Added Chef installation verification step
  • Used environment variables instead of direct matrix interpolation in shell commands
  • Added CODEOWNERS file requiring review for workflow and security-sensitive files

Required Manual Configuration

The following must be configured in GitHub repository settings:

  1. Create Environment: falcon-integration-testing

    • Enable required reviewers
    • Enable "Prevent self-review"
    • Limit deployment branches to main
  2. Move Secrets from repository to environment scope:

    • FALCON_CLIENT_ID
    • FALCON_CLIENT_SECRET
    • FALCON_CID
    • FALCON_CLOUD
    • FALCON_VERSION

Test Plan

  • Verify lint workflow runs successfully on PR
  • Verify integration tests run on push to main after merge
  • Verify environment protection prompts for approval
  • Verify CODEOWNERS requires appropriate reviewers

- Add workflow-level `permissions: read-all` to all workflows
- Add job-level least-privilege permissions
- Pin all actions to commit SHAs (actions/checkout, actionshub/chef-install, nick-fields/retry)
- Pin sous-chefs reusable workflow to commit SHA
- Replace `pull_request_target` with `pull_request` to prevent untrusted code execution with secrets
- Add `environment: falcon-integration-testing` for secrets protection
- Add `timeout-minutes: 60` to integration job
- Add Chef installation verification step
- Reduce lint.yml permissions (removed actions, pull-requests, issues write)
- Add CODEOWNERS file for workflow and security-sensitive file review requirements
- Use environment variables instead of direct matrix interpolation in shell commands
Prevent accidental commits of AI assistant configuration files:
- CLAUDE.md and .claude/ (Claude Code)
- .cursorrules and .cursor/ (Cursor)
- .aider* (Aider)
- .copilot/ and .github/copilot-* (GitHub Copilot)
Use `secrets: inherit` instead of explicit secret passing. This allows
ci.yml's environment protection to properly gate access to secrets.
The previous approach would have required secrets at repository level,
bypassing environment protection.
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.

1 participant