# 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.

```sh
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.
