Lock Your GitHub Actions: A GitHub Actions Security Primer

TL;DR: Pinning every third-party action to one exact commit, and switching off write access by default, closes the most common holes in a build pipeline. It costs nothing, takes an afternoon, and blocks the kind of attack that has already hit thousands of real projects.
You push a small fix to your team's app. A robot wakes up, downloads a helper script that a stranger wrote, and runs it with your project's passwords within arm's reach. That robot is GitHub Actions, and it runs on autopilot every day for millions of teams. Most of them never check what it's actually executing.
What "locking" your GitHub Actions actually means
GitHub Actions is the automation that fires when something happens in a code repository — a push, a pull request, a scheduled nightly job. It builds the app, runs the tests, and ships the result. Most teams don't write those steps from scratch. They borrow ready-made "actions" from a public marketplace, written by people they've never met.
Locking means two things. First, you point at one frozen copy of that borrowed code instead of a moving label. Second, you decide exactly what it's allowed to touch. Neither step takes long, and both get skipped far more often than they should.
Here's the trap. A line like uses: someone/action@v4 is a pointer, not a snapshot. The owner can repoint v4 at new code at any time. That includes code they didn't write, if their account gets hijacked.
Why this reaches past the developers
Your login page, your customer records, your payment keys — they often sit in the same place the build runs. A hijacked action can read all of it and print it into a log that anyone on the team can open.
It has already happened at scale. In early 2025, a widely used action was compromised and leaked credentials into build logs, catching thousands of projects. Nobody did anything unusual. They just trusted a version tag.
So even if you never touch code, you can ask one useful question: are our build tools pinned to exact versions, or floating?
How to lock yours in an afternoon
- Pin to the full 40-character commit hash. That's a fingerprint for one exact snapshot of the code. A hash can't be moved; a tag like
v4can. - Set the default token to read-only. In your repo, go to Settings → Actions → General → Workflow permissions.
- Never pair
pull_request_targetwith code from a fork. That combination hands strangers your secrets. - Scope every secret to the one job that needs it, and keep secrets out of logs.
- Use short-lived cloud tokens (OIDC) instead of long-lived keys where your provider supports it.
- Require approval for workflows from first-time contributors.
What locking won't save you from
Pinning is a seatbelt, not a force field. If the action you pin is already malicious, you've just frozen the problem in place. Read what you install, prefer actions from GitHub or the cloud provider you already pay, and keep the list short.
Pinned versions also go stale. Turn on Dependabot or Renovate so it bumps the hashes for you and opens a pull request you can review. The real fix sits higher up: organisation-level rules that only allow approved actions. Watch for more of those controls, because individual discipline doesn't scale.
Key Takeaways
- A version tag can be repointed at new code; a commit hash cannot.
- Default write permissions turn a small bug into a full data leak.
- One compromised helper script can expose every secret in your build.
- Automatic dependency updates solve the "pinned but outdated" problem.
Frequently Asked Questions
What does it mean to pin a GitHub Action?
It means replacing @v4 with the long commit hash of one exact version. That way the code you reviewed is the code that runs.
Does locking down GitHub Actions cost money?
No. All the settings involved are free features of GitHub, and the work is mostly a one-time cleanup.
Can a pinned action still be dangerous?
Yes. Pinning protects you from code changing after you approve it, not from code that was already malicious.
How did this story feel?
Be the first to react
Recommended gear
Popular tech picks
Samsung Galaxy S25 Ultra
6.9" AMOLED · 200MP · 5000mAh
Editor's pickView on Amazon →Apple MacBook Air 13-inch (M4)
M4 · 16GB · 13.6" Liquid Retina
Editor's pickView on Amazon →Sony WH-1000XM5
Over-ear ANC · 30h battery
Best headphonesView on Amazon →Affiliate links: we may earn a commission at no extra cost to you.
More on #github
Weekly tech brief
The tech stories worth your time, every Sunday.
One short email with the most useful guides and gadget picks from the week. No spam, unsubscribe anytime.
Written by
TechPulse TeamThe TechPulse editorial team publishes clear, practical technology guides. Every article is original and written to be understood — not just skimmed. Read our editorial policy.
Comments (0)
No comments yet — start the conversation!
Keep reading

How VPNs Work and When You Actually Need One
A VPN is a sealed envelope for your internet traffic. Here's what it hides, what it can't, and the two situations where it's genuinely worth paying for.

How VPNs Work and When You Actually Need One
A VPN hides your traffic from the café Wi-Fi, but it won't make you anonymous. Here's when it's worth paying for one and when to skip it.

Smartphone Remote-Control Fraud: What the Arrests Mean
Two arrests in Japan highlight smartphone remote-control fraud. Learn how malicious apps can take over your screen and what to check.