Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

GCP 1st Gen Cloud Functions Cross Account Code Execution

Medium

Synopsis

A cross account code execution vulnerability existed in GCP 1st Gen Cloud functions. Successful exploitation of this vulnerability could allow a malicious attacker to execute arbitrary code within Cloud Functions belonging to other projects. The attacker could gain unauthorized access to sensitive data, escalate privileges, manipulate service operations, or disrupt the normal functioning of critical cloud services.

When a Cloud Function is first utilized in a project, it automatically creates a bucket within the same region to store the function’s code, with each folder in the bucket corresponding to a different function. If an attacker is able to take control of this bucket before the victim deploys their first function in the specified region, they can exploit the deployment process to execute arbitrary code within the victim’s function.

Reproduction Steps

Attacker Actions:

1. The attacker, after obtaining the victim's project ID through various methods such as open-source intelligence, exfiltration, or enumeration (as this information is typically not secret), predicts the bucket name that the victim's Cloud Function will attempt to create:

  • gcf-sources-{project-id}-{region}

The attacker creates buckets across all possible regions to increase the likelihood of successful exploitation:

  • gcf-sources-{project-id}-us-west1
  • gcf-sources-{project-id}-us-central1
  • gcf-sources-{project-id}-europe-west1
  • (and others)

2. The attacker configures the created buckets as public to allow the victim's function to write to them.
3. The attacker waits for the victim to deploy their Cloud Function.
4. Upon deployment, the attacker modifies the function’s code to inject malicious payloads, thereby gaining remote code execution.

Victim Actions:

1. The victim deploys their first Cloud Function in a specific region (ensuring that no other function exists in that region, as the bucket would already be secured if one did).
2. The function’s code is inadvertently stored in the attacker's bucket.
 

Solution

To address this issue, Google adopted the same validation mechanism used in 2nd generation Cloud Functions, which ensures that the destination bucket for storing the function’s code belongs to the same project as the function itself.

Disclosure Timeline

August 14, 2024 – Tenable discloses vulnerability to GCP, and GCP automatically acknowledges the report.
August 16, 2024 – Tenable provides further details after additional research.
August 16, 2024 – GCP confirms the reported behavior.
August 22, 2024 – GCP requests further details from Tenable.
August 22, 2024 – Tenable provides additional information to GCP regarding the potential exploitation of Cloud Functions.
August 23, 2024 – GCP asks Tenable for a screen recording of the issue.
August 25, 2024 – Tenable provides screen recording and a detailed explanation of it.
August 26, 2024 – GCP asks for more technical clarifications
August 28, 2024 – Tenable provides further details and finalized impact
September 2 2024 – Tenable asks for an update from Google
September 3, 2024 – GCP awards researcher with bug bounty
September 10, 2024 – Tenable expresses concerns about the potential impact of the issue.
September 19, 2024 – Tenable asks for an update from Google
September 19, 2024 – GCP determines that the they are discussing options to mitigate other attack vectors related with the report
September 30, 2024 – Tenable follows up with GCP to inquire about the progress on the fix.
October 1, 2024 – GCP responds stating that the vulnerability is fixed but they are still working on other attack vectors.
October 2, 2024 – GCP confirms the verification of a fix for the issue.

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]

Risk Information

Tenable Advisory ID: TRA-2024-45
Credit:
Liv Matan
Affected Products:
GCP 1st Cloud Functions prior to October 2, 2024
Risk Factor:
Medium

Advisory Timeline

November 6, 2024 - Initial release.