GCP - Artifact Registry Privesc
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
For more information about Artifact Registry check:
With this permission an attacker could upload new versions of the artifacts with malicious code like Docker images:
It was checked that it's possible to upload a new malicious docker image with the same name and tag as the one already present, so the old one will lose the tag and next time that image with that tag is downloaded the malicious one will be downloaded.
It's not possible to upload a python library with the same version as the one already present, but it's possible to upload greater versions (or add an extra .0
at the end of the version if that works -not in python though-), or to delete the last version an upload a new one with (needed artifactregistry.versions.delete)
:
artifactregistry.repositories.downloadArtifacts
With this permission you can download artifacts and search for sensitive information and vulnerabilities.
Download a Docker image:
Download a python library:
What happens if a remote and a standard registries are mixed in a virtual one and a package exists in both? Check this page:
artifactregistry.tags.delete
, artifactregistry.versions.delete
, artifactregistry.packages.delete
, (artifactregistry.repositories.get
, artifactregistry.tags.get
, artifactregistry.tags.list
)Delete artifacts from the registry, like docker images:
artifactregistry.repositories.delete
Detele a full repository (even if it has content):
artifactregistry.repositories.setIamPolicy
An attacker with this permission could give himself permissions to perform some of the previously mentioned repository attacks.
Cloud Functions
When a Cloud Function is created a new docker image is pushed to the Artifact Registry of the project. I tried to modify the image with a new one, and even delete the current image (and the cache
image) and nothing changed, the cloud function continue working. Therefore, maybe it might be possible to abuse a Race Condition attack like with the bucket to change the docker container that will be run but just modifying the stored image isn't possible to compromise the Cloud Function.
App Engine
Even though App Engine creates docker images inside Artifact Registry. It was tested that even if you modify the image inside this service and removes the App Engine instance (so a new one is deployed) the code executed doesn't change. It might be possible that performing a Race Condition attack like with the buckets it might be possible to overwrite the executed code, but this wasn't tested.
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)