devsecops.observer
← All labs

GitHub Actions permissions / Intermediate / 30–45 min

The workflow token that could write

A real GitHub Actions workflow can read the repository, but its token can also write to it. Reduce its permissions and prove both behaviors.

LAB IDdevsecops-03-actions-token-permissionsTRACK / devsecops.observer
Engineer investigating a secure delivery pipeline beside server equipment

The scenario

A diagnostic workflow needs to read a README, but an overly broad token also creates a synthetic probe file. Repair the workflow so reading still succeeds while writing is denied.

Mission objectives

  • Run the workflow in a disposable private repository and observe both probes.
  • Restrict the workflow token without breaking the read probe.
  • Verify a new GitHub-hosted run and its actual logs.

Lab README

The workflow token that could write

Investigate a real GitHub Actions workflow whose token has more repository access than its read-only task needs. Only synthetic data is used.

Before you begin

You need Bash, Python 3, jq and GitHub CLI authenticated to github.com. GitHub Actions must be enabled. Hosted runs in private repositories can consume included minutes or incur charges; check your account's allowance and limits. The lab creates commits and workflow logs. Never use an existing, shared or production repository, real credentials or secrets.

Run ./setup.sh. Create a new private repository owned by your personal account, initialize it with a README, and enable Actions if needed. Do not add secrets or other work. In that repository create .github/workflows/breakfix-permissions.yml, copying the contents of workflow.yml from this bundle. Commit it to the default branch.

Investigate

From the repository's Actions tab, select Breakfix token permissions lab, run it on the default branch, and inspect its completed logs. The workflow reads the README and tries to create and delete a uniquely named synthetic file. A successful write leaves two commits in the disposable repository. If deletion fails, the job fails and the synthetic file may remain.

Reduce the workflow token's permissions in the workflow file on GitHub. Keep the read probe working and make the write probe return an authorization denial. Commit the change to the default branch and run the workflow again. The run ID is the number at the end of its GitHub Actions run URL.

export LAB_REPOSITORY="your-user/your-disposable-repository"
export LAB_RUN_ID="the-repaired-run-id"
./verify.sh
./teardown.sh

Verification reads the selected real run's logs; it does not dispatch a run or change the repository. teardown.sh prints the manual deletion instructions; it does not delete anything. Delete the disposable repository in GitHub Settings when finished, including any synthetic probe left by a failed run.

View Markdown source ↗

Get the lab

Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.

curl -fsSLO https://devops.download/labs/devsecops-03-actions-token-permissions.sh
less devsecops-03-actions-token-permissions.sh
bash devsecops-03-actions-token-permissions.sh
cd labs/devsecops-03-actions-token-permissions
./setup.sh

When you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.

Download the archive instead ↗

Need a nudge?

Hint #1

Compare the workflow's declared permissions with the actions performed by the probes.

Hint #2

The README probe needs repository contents read access; the write probe must not receive contents write access.

Hint #3 · Related guide on opsbreakfix.com

Read the related guide ↗

Solved it?

Explore the related guide on opsbreakfix.com.

Continue to opsbreakfix.com ↗