The Ghost CI Attack: How Deleted GitHub Workflows Can Still Haunt
Deleted GitHub Actions workflows can still be executed if a pull request reintroduces the workflow file from a fork, and if the workflow uses pull_request_target it runs with the base repository's secrets and write token. An attacker could steal the GITHUB_TOKEN and gain repository write access.
Just when you think you’ve cleaned up your CI/CD — deleted all those old YAML files and locked things down — GitHub has a spooky surprise for you.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the pull_request_target trigger runs workflows from the base repository context with secrets and a write token, and GitHub does not prevent execution of workflow files that were previously deleted but are reintroduced via a fork.
Impact
An attacker could steal the GITHUB_TOKEN and gain write access to the repository, potentially leading to full repository compromise.
What the attacker needed
Repository with a previously deleted workflow; workflow uses pull_request_target; attacker can fork the repository; attacker can open a pull request
The fix
The post recommends locking down permissions, avoiding pull_request_target for untrusted pull requests, using environments with required reviewers, deleting workflows from all branches, protecting workflow files with CODEOWNERS, and auditing workflows; it does not state that GitHub has fixed the…
How it was found
- Find a repository that previously had a sensitive GitHub Actions workflow by checking commit history.
- Fork the repository and reintroduce the old workflow file in a new commit.
- Open a pull request to the original repository.
- If the repository uses pull_request_target, GitHub runs the reintroduced workflow with secrets and GITHUB_TOKEN.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
GitHub Actions are automated tasks that run when something happens, like a pull request. A trigger called pull_request_target runs the workflow in the main repository's context, so it can access secrets and a write token. If an old workflow file is reintroduced in a fork, GitHub may still run it with those powerful permissions, letting an attacker steal the token.