Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sync] Add GCP.Cloudfunctions.Functions.Create rule (#58) #1077

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Conversation

egibs
Copy link
Contributor

@egibs egibs commented Jan 30, 2024

Goal

Detect cloudfunctions.functions.create method for privilege escalation in GCP.

Categorization

TA0004:T1548

Strategy Abstract

The Identity and Access Management (IAM) service manages authorization and authentication for a GCP environment. This means that there are very likely multiple privilege escalation methods that use the IAM service and/or its permissions.

Technical Context

For this method, we will be creating a new Cloud Function with an associated Service Account that we want to gain access to. Because Cloud Function invocations have access to the metadata API, we can request a token directly from it, just like on a Compute Engine instance.

The required permissions for this method are as follows:

cloudfunctions.functions.call OR cloudfunctions.functions.setIamPolicy

cloudfunctions.functions.create

cloudfunctions.functions.sourceCodeSet

iam.serviceAccounts.actAs

The script for this method uses a premade Cloud Function that is included on GitHub, meaning you will need to upload the associated .zip file and make it public on Cloud Storage (see the exploit script for more information). Once the function is created and uploaded, you can either invoke the function directly or modify the IAM policy to allow you to invoke the function. The response will include the access token belonging to the Service Account assigned to that Cloud Function.

Blind Spots and Assumptions

Assumes proper GCP logging and audit policies.

False Positives

Legitimate administrative activity that is authorized and expected.

Validation

The exploit scripts for this method can be found here and here and the prebuilt .zip file can be found here.

Priority

High or Critical

Response

Again, these are not vulnerabilities in GCP, they are vulnerabilities in how you have configured your GCP environment, so it is your responsibility to be aware of these attack vectors and to defend against them. Make sure to follow the principle of least-privilege in your environments to help mitigate these security risks.

Additional Resources

https://rhinosecuritylabs.com/gcp/privilege-escalation-google-cloud-platform-part-1/

@egibs egibs requested review from a team January 30, 2024 18:55
@egibs egibs enabled auto-merge (squash) January 30, 2024 19:58
@egibs egibs merged commit 00a902b into main Jan 30, 2024
5 checks passed
@egibs egibs deleted the egibs-sync-58 branch January 30, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants