Join our Newsletter — 33% off our NHI Course
Home› Guides› GitHub Actions Security for Beginners: How Automated Workflows…
Guide Software & AI Supply Chain

GitHub Actions Security for Beginners: How Automated Workflows Get Hijacked

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 28 November 2026 11 min read
On this page

GitHub Actions security means stopping strangers from taking over the robots that test and publish your code.

This guide is for students, new developers and anyone whose team keeps code on GitHub. You do not need to write workflows yourself to be affected: if your project uses them, they may hold keys to your cloud, your website or your app store account.

In short

  • GitHub Actions runs jobs for you automatically when something happens in a project, such as new code arriving.
  • Those jobs often hold passwords and keys, so a hijacked job can leak them or misuse them.
  • Common ways in are borrowed add-ons that change, text from strangers treated as commands, and jobs with more power than they need.
  • Pin add-ons to an exact version, give each job only the access it needs and review changes to workflow files.

What you will learn

  • Explain what a GitHub Actions workflow is in plain words.
  • Spot the four warning signs in a workflow file.
  • Explain how a trusted add-on was used to leak secrets in 2025.
  • Check what your own workflows are allowed to do.
Automatic job list (workflow)
a file that tells GitHub which jobs to run, and when.
Borrowed add-on (action)
a ready-made building block, often written by someone else, that a workflow uses.
Robot's pass (GITHUB_TOKEN)
a temporary key GitHub gives each run so it can work on the project.

What is GitHub Actions security?

Think of a kitchen robot that follows a recipe card every time an order comes in. It works fast and never gets tired, but it does exactly what the card says.

GitHub is a website where people store and share code. GitHub Actions is its built-in robot. A workflow is the recipe card: a file in the project that lists jobs to run.[1] Something that happens in the project, like new code arriving, is called an event, and it starts the workflow. The jobs run on a borrowed computer called a runner.[1]

Workflows often use actions, ready-made add-ons that do common tasks, such as checking code or uploading files. Many actions are written by other people.[1]

GitHub Actions security is about who can change the recipe card, what goes into it, and which keys the robot is given.

Where the comparison stops working: a kitchen robot only reaches one kitchen. A workflow may hold keys to cloud accounts, websites and package stores, so one hijacked run can reach far beyond the project.

Why does it matter?

Workflows run without anyone watching, and they often hold the most powerful keys a team has. In March 2025, a popular add-on called tj-actions/changed-files was changed by an attacker. Projects that used it printed their secrets into their run records, called logs. The security advisory says over 23,000 repositories could have been affected.[4] Read our tj-actions/changed-files compromise page for the full story.

If you are a student with projects on GitHub

What could happen: you copy a workflow from a tutorial, and it gives every job full write access.

Check this: look for a permissions line and keep it to read-only unless a job needs more.

Next: Least Privilege for Beginners

If you are a new developer in a team

What could happen: you add a handy add-on by its version name, and the owner's account is later taken over.

Check this: ask whether your team pins add-ons to an exact version.

Next: How to Pin GitHub Actions to Commit SHAs

If you manage a software team

What could happen: a change to a workflow file slips through without review and sends keys elsewhere.

Check this: require a named reviewer for any change to workflow files.

Next: CI/CD Pipeline Security for Beginners

What does it look like?

Here is a made-up, simplified workflow file with four warning signs marked.

Example only. All values are made up.

# .github/workflows/publish.yml (EXAMPLE)
on: issues                                    (1)
permissions: write-all                        (2)
steps:
  - uses: example-org/helper-action@v2        (3)
  - run: echo "New issue: TITLE_FROM_STRANGER"   (4)
env:
  CLOUD_KEY: FAKE-KEY-0000                    (5)
  1. The workflow starts whenever anyone opens an issue, including strangers on a public project.
  2. Every job gets full write power over the project, which is more than most jobs need.
  3. The add-on is chosen by a version name. The owner can move that name to different code later.
  4. In a real file, this line would place an issue title, typed by anyone, straight into a command.
  5. In a real file, this line would contain a long-lasting cloud key typed into the workflow.

Why this is risky: a stranger can start this workflow and the text they type ends up inside a command. If the add-on changes, new code runs with full power and can see the cloud key.[2]

The safer way: set permissions to read-only and add more only where a job needs it. Pin the add-on to its full commit ID, the unique code for one exact version. Pass outside text in as a separate value rather than pasting it into the command. Keep keys in GitHub's secret settings, or use short-lived sign-in tokens instead of stored keys.[2]

How does it work?

Here is how a workflow usually gets hijacked, step by step.

  1. The trigger. An event starts the workflow, such as new code or a new issue.[1] On public projects, strangers can cause some of these events.
  2. The keys. GitHub gives the run a temporary pass, the GITHUB_TOKEN, and the run may also read stored secrets.[3]
  3. The way in. The attacker finds a weak spot. Common ones are a borrowed add-on whose version name now points to new code, or stranger text treated as a command.[2]
  4. The misuse. The attacker's code runs inside the job with the job's keys. It may print them into the logs, send them away or change the project.[4]
  5. The clean-up. The team swaps the bad add-on for a safe version and replaces every key the job could see.[4]
Diagram titled How a workflow gets hijacked, with four boxes in a row. Box 1, Trigger: new code or a new issue starts the workflow. Box 2, Runner: a borrowed computer runs the jobs with the robot's pass and stored secrets. Box 3, Borrowed add-on: code written by someone else, and its version name can be moved. Box 4, Leak: if the add-on or stranger text is bad, keys can end up in logs or sent away. A green bar underneath says pin add-ons, keep permissions small and review workflow changes.
Figure 1. The path from a trigger to a leak, and the three habits that block most of it.
Before and after diagram titled Version name or exact version. Left panel, labelled Risky: the workflow uses helper-action at v2. The add-on owner, or someone who has taken over their account, can move the v2 label to new code, and the next run uses it unless someone checks. Right panel, labelled Safer: the workflow uses helper-action at a full commit ID. That ID always means the same code, so a moved label does not change what runs. Update it on purpose after checking the new version.
Figure 2. A version name can be moved to new code. A full commit ID always points to the same code.

A worked example

Bodhi Ulrich is a junior developer at Quarry Kitchens, a fictional firm that makes kitchen-planning software. His manager, Gideon Lindahl, asks him to check the team's workflows after reading about a hijacked add-on.

Bodhi thinks of the kitchen robot. It follows the card exactly, so the question is who can change the card and what it is allowed to touch.

He opens the workflow that publishes the app. Three things stand out. Every job has full write power. Two add-ons are chosen by version names like v3. And a cloud key that never expires sits in the project's secrets.

First, Bodhi sets the default permissions to read-only. Only the publishing job gets the extra right it needs.

Next, he looks up each add-on's full commit ID on its official project page and pins to it. He checks that the ID comes from the add-on's own project, not a copy.

Then he talks to Gideon about the cloud key. They agree to switch to short-lived sign-in tokens, so the workflow gets a fresh key for each run instead of a stored one.

Last, Gideon makes himself and one other senior developer the required reviewers for any change to the workflow folder.

The work takes an afternoon. Gideon adds "check workflows" to the team's monthly review list, so new add-ons get the same treatment.

Myths and mistakes

What people thinkWhat is true
A version name like v2 always means the same code.A version label can be moved or deleted. A full commit ID is fixed.[2]
GitHub hides secrets in logs, so they are safe.GitHub tries to hide them, but this is not guaranteed. Check your logs.[2]
Popular add-ons are safe to trust.The tj-actions add-on was widely used and still had its labels moved to bad code.[4]
Text from an issue is just text.If pasted straight into a command, it can be run as part of that command.[2]
Our project is private, so workflows are safe.Private projects still use outside add-ons and hold keys. The same habits apply.

What can I do this week?

  • Open each workflow file and look for a permissions line.
  • List every outside add-on your workflows use and who writes it.
  • Pin the most important add-ons to a full commit ID.
  • Ask who must approve changes to the .github/workflows folder.
  • Read a recent run log and check that no keys appear in it.

Checklist

  • Default workflow permissions are read-only, with extra rights added per job.
  • Outside add-ons are pinned to a full commit ID from the add-on's own project.
  • Text from issues, pull requests or comments is never pasted straight into commands.
  • Keys live in GitHub's secret settings, never in workflow files.
  • Short-lived sign-in tokens are used for cloud access where the provider supports them.
  • Changes to workflow files need approval from a named reviewer.
  • The team knows to replace every key a job could see if an add-on is compromised.

Common questions

Is GitHub Actions safe to use?

Yes, when it is set up with care. GitHub gives you the settings you need, such as permission limits, secret storage and required reviewers. Most problems come from how a workflow is written: too much power, add-ons that can change, or outside text used in commands.

What is a commit SHA and why pin to it?

A commit SHA is a long ID that points to one exact version of some code. A version label such as v2 can be moved by the owner, or by someone who takes over their account. Pinning to the full ID means the code only changes when you choose.

What should I do if an add-on I use is hijacked?

Replace every key that the affected jobs could see, starting with the most powerful. Then move to a safe version of the add-on and check recent run logs for leaked values. Our Third-Party GitHub Action Compromise Response Playbook lists the steps.

Do I need to worry if my project is public?

Yes, a little more. On public projects, anyone can open issues and pull requests, and some of these can start workflows. GitHub advises against running jobs from public projects on your own computers, because a stranger's code could run there.[2]

Are short-lived sign-in tokens hard to set up?

Usually not. Major cloud providers support them, and GitHub's guides walk through each one.[2] The workflow asks the cloud for a fresh key on each run, so there is no long-lasting key to leak. See GitHub Actions OIDC Federation Hardening Guide.

Where next?

Ready for the detail? Read the practitioner guide: Top 10 GitHub Actions Security Mistakes. It goes further into risky triggers, self-hosted runners and how to check workflows automatically.

Also useful:

Related NHI Mgmt Group resources: How to Pin GitHub Actions to Commit SHAs · GitHub Actions Cache Poisoning · CI/CD Pipeline Security for Beginners

Key terms

Workflow
A file that tells GitHub Actions which jobs to run, and when.
Action
A ready-made add-on, often written by someone else, that a workflow uses to do a task.
Runner
The computer that carries out a workflow's jobs.
GITHUB_TOKEN
A temporary key GitHub creates for each workflow run so it can work on the project.
Commit SHA
A long ID that always points to one exact version of some code.
Least privilege
Giving each person or program only the access it needs, and no more.
CI/CD pipeline
The automatic steps that build, test and publish software.

Sources and further reading

  1. Understanding GitHub Actions. GitHub Docs, GitHub. https://docs.github.com/en/actions/get-started/understand-github-actions, accessed 28 Nov 2026.
  2. Secure use reference. GitHub Docs, GitHub. https://docs.github.com/en/actions/reference/security/secure-use, accessed 28 Nov 2026.
  3. Use GITHUB_TOKEN for authentication in workflows. GitHub Docs, GitHub. https://docs.github.com/en/actions/tutorials/authenticate-with-github_token, accessed 28 Nov 2026.
  4. Security advisory for tj-actions/changed-files (GHSA-mrrh-fwg8-r2c3, CVE-2025-30066). GitHub Advisory Database, published 15 March 2025. https://github.com/advisories/GHSA-mrrh-fwg8-r2c3, accessed 28 Nov 2026.

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.