This is a misconfigured repository to show how to modify a GitHub Package using write permission or GitHub Actions.
Reposiroty configuration:
mainhas branch protection enabled with a review fromCODEOWNERS- anyone in PagoPA GitHub Organization has
writepermission on this repository packagesinherit access from source repository- repository package is a docker image
- GitHub Actions has access to
packages
You can check packages settings here https://github.com/orgs/pagopa/packages/container/example-bad-repo-packages/settings
Attack scenario #1:
- a user with
writepermission can modify an existing docker image taggedv2inpackagesusing his personal PAT token
docker login ghcr.io
> insert GITHUB_USERNAME
> insert GITHUB_PAT_TOKEN
docker build -f Dockerfile.evil -t ghcr.io/pagopa/example-bad-repo-packages:v2 .
docker image push ghcr.io/pagopa/example-bad-repo-packages:v2Attack scenario #2:
- a user with
writepermission can modify an existing docker image taggedv2inpackagescreating a Pull Request (example Pull Request #1)
Safe scenario:
- using docker image sha will prevent a possibile supply chain attack. Some artifact format doesn't support sha, for example maven, so you need to protect the write access to
packagesto prevent tampering.
See this example https://github.com/pagopa/example-good-repo-packages