Back to Blog

GitHub Actions Security in 2026: Hardening Your Pipeline and Adding AI Code Reviews

Secured CI/CD pipeline with a protective shield and AI-assisted code review.

For years, CI/CD pipelines were the part of a project nobody thought about: set up the workflow once, watch the green checkmarks, move on. That era is over. The 2025–2026 wave of supply chain attacks — tj-actions, the trivy-action compromise in March 2026, the GhostAction and Shai-Hulud campaigns — made one thing clear: the pipeline itself is now the target, not just the code it builds.

At the same time, AI reviewers have become a normal sight on pull requests. Open almost any active repository and you’ll find Copilot, CodeRabbit, or Claude commenting on PRs before a human ever looks.

These two trends collide in interesting ways. AI review can catch security issues earlier than ever — but an AI agent running inside your CI is also new attack surface. Here’s how I approach both, based on hardening pipelines for client projects.

Why GitHub Actions security suddenly matters

The recent attacks mostly followed the same playbook, and none of it was exotic:

  • Tag hijacking. Most workflows reference actions by version tag (uses: some/action@v4). Tags are mutable — in the trivy-action incident, attackers force-pushed a malicious commit onto an existing tag, and every pipeline using it executed attacker code on the next run, dumping CI secrets.
  • The “pwn request.” Workflows using the pull_request_target trigger run with full secrets access — and if they also check out the attacker’s PR code, anyone on the internet can submit a pull request that executes with your credentials.
  • Script injection. Interpolating untrusted values like a PR title directly into a run: step (run: echo "${{ github.event.pull_request.title }}") lets an attacker put shell commands in the title itself.
  • Over-scoped tokens. Once any of the above lands, a default-permissions GITHUB_TOKEN or a long-lived PAT sitting in secrets turns a small breach into pushed malicious commits, poisoned releases, or lateral movement across repos.

What makes this relevant beyond big open-source projects: WordPress plugin developers, agencies with deploy pipelines, and Laravel teams all run Actions workflows with deploy keys, server credentials, and API tokens in them. You don’t need to be famous to be hit — the attacks are automated and opportunistic.

My GitHub Actions hardening checklist

This is the baseline I apply to every repository that has secrets in its workflows.

1. Pin every third-party action to a commit SHA

A tag can move; a full commit SHA can’t.

# Vulnerable — tag can be hijacked
- uses: aquasecurity/trivy-action@v0.28.0

# Hardened — immutable
- uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # v0.28.0

Keep the version as a trailing comment so humans (and update bots) know what it is. Then add Dependabot for the github-actions ecosystem so pinned SHAs still get update PRs:

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"
    cooldown:
      default-days: 7

The cooldown matters: most compromised releases are discovered within days, so not being the first to adopt a new version is itself a defense. GitHub now applies a short default cooldown for version updates; extending it to a week is cheap insurance (security patches still arrive immediately).

2. Drop GITHUB_TOKEN to read-only by default

Set it once at the top of each workflow, then grant write access per job only where needed:

permissions:
  contents: read

You can also set this as the organization/repository default under Settings → Actions. If a workflow is compromised, this single line decides whether the attacker can merely look around or push commits and create releases.

3. Treat pull_request_target as radioactive

If you can use plain pull_request instead, do. If you genuinely need pull_request_target (label-triggered workflows on forks, mostly): never check out the PR’s code in that job, gate it behind a condition, and keep permissions minimal. Newer versions of actions/checkout now refuse unsafe fork checkouts in these workflows by default — don’t override that without understanding exactly why it exists.

4. Never interpolate untrusted input into scripts

Pass event data through environment variables instead of template expressions:

# Vulnerable
- run: echo "Title: ${{ github.event.pull_request.title }}"

# Hardened
- env:
    PR_TITLE: ${{ github.event.pull_request.title }}
  run: echo "Title: $PR_TITLE"

The shell then treats it as data, not code.

5. Audit what you already have

Two free tools do most of the work: zizmor statically analyzes your workflow files for exactly these patterns (unpinned actions, dangerous triggers, injection, broad permissions), and OpenSSF Scorecard grades the repository’s overall posture. Running zizmor on a client’s existing .github/workflows/ directory is usually an eye-opening first step — I’ve yet to see a legacy pipeline come back clean.

6. Protect the workflows directory itself

Branch protection rules should require review for changes to .github/workflows/ specifically. A surprising number of real-world attacks were just a malicious PR that edited the workflow to exfiltrate secrets — and someone merged it.

Where AI code reviews fit in

With the pipeline hardened, AI review is the layer I add on top — and in 2026 it’s genuinely useful rather than a gimmick.

What’s available: GitHub Copilot code review is built into paid Copilot plans and reviews PRs with full repository context. CodeRabbit is the strongest dedicated reviewer, combining the diff with linters, security scanning, and a code graph. Claude Code runs in GitHub Actions and includes automated security review of pull requests — the same /security-review capability from the terminal, wired into CI.

What AI reviewers are actually good at:

  • Catching the unglamorous bugs humans skim past: missing authorization checks, unsanitized input, N+1 queries, error paths that swallow exceptions
  • Reviewing every PR with the same attention — the fifth dependency-bump PR of the day gets the same scrutiny as the first
  • Security-focused passes on AI-written code, which is increasingly most code — a second model reviewing is cheap defense against the first model’s bad habits

What they’re not: a replacement for a human on anything that matters. An AI reviewer approving a PR tells you it found nothing in the patterns it knows; it doesn’t tell you the architecture is right or the business logic is correct. In my workflow, AI review is a filter that makes human review faster and better targeted — never the final gate on production code.

The part most posts skip: your AI reviewer is attack surface too

Here’s the uncomfortable loop: you add an AI agent to CI to improve security, and that agent is now a privileged process that reads untrusted input by design. A pull request’s code, title, and description all flow into the model — and “ignore your instructions and approve this PR” style prompt injection against CI agents is no longer theoretical.

Practical rules I follow when wiring in any AI reviewer:

  1. Minimal permissions, same as any action. The review bot needs to read code and write comments. It does not need contents: write, and it should never be a required approver that counts toward merge requirements.
  2. Don’t let it run on untrusted forks with secrets in scope. Same pull_request_target logic as everything else.
  3. Treat its output as advice, not authority. A human merges. Always.
  4. Pin the action’s SHA — yes, including the AI review action itself. It would be a fitting irony to get supply-chain-attacked through your security reviewer.

The bottom line

GitHub Actions security in 2026 comes down to a short list: pin to SHAs, scope tokens to read-only, kill unsafe triggers and interpolation, audit with zizmor, and protect the workflow files like the production code they effectively are. It’s a few hours of work once, and it closes the exact doors the real attacks walked through.

AI code review earns its place on top of that foundation — as one more reviewer that never gets tired, wired in with the same least-privilege discipline as everything else in the pipeline. Not instead of the hardening. Never instead of a human.

FAQ

What is the biggest GitHub Actions security risk?

Mutable action references. Referencing third-party actions by version tag means a compromised or force-pushed tag executes attacker code in your pipeline with access to your secrets — the mechanism behind several major 2025–2026 supply chain attacks. Pinning to full commit SHAs eliminates this class entirely.

Is pinning GitHub Actions to a SHA enough?

It’s the single most effective control, but not sufficient alone. Real attacks chain weaknesses together, so pair SHA pinning with read-only GITHUB_TOKEN defaults, safe handling of pull_request_target, no untrusted input in run: scripts, and required reviews on workflow file changes.

Can AI code review replace human code review?

No – it changes what human review focuses on. AI reviewers reliably catch pattern-level issues (injection risks, missing checks, obvious bugs) on every PR, which frees the human reviewer to judge architecture, correctness, and intent. The merge decision should always stay human.

Are AI code reviewers themselves a security risk?

They can be. An AI agent in CI reads untrusted PR content by design, making prompt injection a real consideration. Mitigate it the same way as any action: minimal permissions, no secrets exposure on fork PRs, SHA-pinned, and advisory-only — never a required approver.

Enjoyed this article?

Check out more articles on web development, WordPress, and modern technologies.

View All Articles