Sub topic 7
Deciding whether to trust an action
This chapter assumes you can read a workflow file and know the uses syntax, tags, and commit SHAs from the earlier chapters. Here you learn how to judge an action before you add it to a workflow.
Why trust matters
An action is code that runs inside your job. It can read your checked-out source, see the environment variables you give it, and use the GITHUB_TOKEN that the job receives. A malicious or compromised action can leak secrets or change your code.
The Marketplace does not audit most listings, so a listing is not a safety guarantee. You make the decision, and a short routine makes it repeatable.
What the Marketplace shows you
Each listing gives some signals. None of them is proof of safety, but together they help.
| Signal | What it tells you | Limit |
|---|---|---|
| Verified creator badge | GitHub has verified the publisher's identity as an organization | It says who published the action, not that the code is safe |
| Stars and usage count | Other people use it | Popularity can be faked, and popular actions are attractive targets |
| Release history | Whether versions are tagged and maintained | Tags can be moved |
| Open issues and pull requests | Whether the maintainers respond | Quiet projects can still be fine |
| Linked repository | Lets you read the source | You must actually read it |
Read the source
Open the repository linked from the listing and check these items:
action.yml. Look at therunssection to see the action type. Check which inputs it requires, especially any that take tokens or credentials.- The entry point. For a JavaScript action, find the source file. Be wary if the repository holds only a bundled
dist/file with no readable source or build step. For a Docker action, read theDockerfileand the base image. - Network calls. Look for requests to hosts that have nothing to do with the action's purpose.
- Dependencies. Count them. Each one is more code you trust.
- Ownership and activity. Check how long the repository has existed, who maintains it, and whether recent commits look normal.
- Security policy. A
SECURITY.mdfile and a record of fixing reported issues are good signs.
Look out for lookalikes
Attackers publish actions with names close to popular ones, such as a changed letter in the owner name. Copy the owner/repo from the official documentation of the tool, not from a search result. Check the spelling before you commit it.
Combine trust with pinning
Reading the code on one day tells you nothing about the code that runs next month. If you reference an action by a tag such as @v4, the maintainer, or someone who takes over the account, can move that tag to new code. A full-length commit SHA is immutable, so what you reviewed is what runs.
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# Replace the placeholder with the full 40-character commit SHA of the release you reviewed.
- uses: actions/checkout@<full-length-commit-sha> # v4
- run: echo "Build steps go here"This workflow pins to a reviewed commit and limits the token to read-only access to repository contents. The comment records the tag so that people and Dependabot can see which release the SHA represents.
A decision routine
The diagram shows one way to decide. Stop at the first "no" and look for another option.
Limit the damage
Assume that you might be wrong. Two controls reduce the harm:
- Set
permissionson the workflow or job so theGITHUB_TOKENhas only what the job needs. - Pass a secret only to a step that needs it, and use
withor a step-levelenvinstead of exposing it to the whole job.
The next chapter covers both controls in detail.
Common mistakes
- Treating a high star count as a security review.
- Trusting a tag as if it never changes.
- Granting
write-allpermissions because a workflow failed once. - Adding an action to save two lines of shell.
Exercise
A teammate wants to add a little-known action that has a verified creator badge and 40 stars. Name two checks you would do before approving it, and what you would do to the uses line afterward.
Show answer
Any two of: read action.yml and the entry point source, check for unexpected network calls, count dependencies, check maintainer activity and security policy, confirm the owner name is not a lookalike. Afterward, pin the uses line to the full-length commit SHA of the reviewed release, with the tag in a comment, and set minimal permissions for the job.
Exercise
Why does a verified creator badge not prove that an action is safe?
Show answer
The badge confirms the identity of the publisher organization. It says nothing about the quality or safety of the code, and a verified account can still publish a buggy or compromised release.