The on pull_request
GitHub actions event can be triggered by anyone for public repositories.
i.e. someone:
.github/workflows/something.yml
running on pull_request
eventThe action they specified in the pull request is then run. If you have a self-hosted runner then anyone can run arbitrary code like shell commands on your server in the context of the self-hosted runner's user.
How can I whitelist hooks that actions can be triggered by on a repository? Or otherwise, how can I safely use Github Actions with public repositories with self-hosted runners? I have seen the warning... I just assumed that I had to carefully review pull requests.
A configuration option was added to help secure self-hosted runners. If you have a public repository and a self-hosted runner, then you should always enable the option "Require approval for all outside collaborators" as seen in the Actions configuration screen below.
The new default is to require approval for all first-time contributors to run workflows.
However, GitHub still recommends that you do not use self-hosted runners with public repositories. They specifically state self-hosted runners should almost never be used for public repositories on Github As also mentioned on that page is to use CodeOwners to monitor changes to the directory that your workflow files are stored in (.github/workflows).