Palo Alto Networks' Unit 42 discovered a critical vulnerability in the Google Cloud Vertex AI Python SDK (google-cloud-aiplatform) that permitted cross-tenant remote code execution (RCE). The vulnerability, present in SDK versions 1.139.0 and 1.140.0, allowed an attacker with no initial access to a victim's environment to hijack and poison machine learning (ML) models during the upload process. The core of the issue was a predictable default naming pattern for staging buckets combined with a lack of ownership verification in the SDK.
An attacker could exploit this by predicting and pre-creating a Google Cloud Storage (GCS) bucket (a technique known as 'bucket squatting'). When a victim using a vulnerable SDK version uploaded a model without specifying a custom staging location, the SDK would inadvertently send the model artifacts to the attacker-controlled bucket. The attacker could then replace the legitimate model with a malicious one, leveraging Python's pickle deserialization to achieve RCE when the victim deployed the compromised model. Google has addressed this vulnerability in SDK version 1.148.0 following responsible disclosure from Unit 42.
The vulnerability, dubbed 'Pickle in the Middle,' is a multi-stage attack that hinges on three key components:
Predictable GCS Bucket Name: When a user uploads a model via the VertexAI.Model.upload() function without specifying a staging_bucket, the SDK generates a default bucket name using a deterministic pattern: [project-id]-[region]-vertex-ai-staging. An attacker only needs the victim's project ID and region to predict this name.
Bucket Squatting and Missing Ownership Check: GCS bucket names are globally unique. An attacker can preemptively create a bucket with the predicted name in their own Google Cloud project. The vulnerable SDK versions checked for the bucket's existence but failed to verify that it belonged to the user's project. Consequently, the SDK would proceed to upload the victim's model artifacts to the attacker's bucket, assuming it was a legitimate staging area.
Malicious Model Replacement and Deserialization RCE: The attacker can then, within a narrow time window, replace the victim's uploaded model files (e.g., model.joblib) with a malicious version. Since many Python ML models are serialized using pickle or its wrapper joblib, the attacker can craft a malicious model file. This file, when deserialized by the Vertex AI serving infrastructure using pickle.load() or joblib.load(), executes arbitrary code via the __reduce__ method. This provides the RCE payload delivery mechanism.
The attack flow is as follows:
[victim-project-id]-[region]-vertex-ai-staging.google-cloud-aiplatform)1.139.0 and 1.140.01.148.0 and laterOrganizations using Vertex AI for MLOps pipelines are urged to check their dependencies and ensure they are not running the affected versions.
The vulnerability was discovered and demonstrated through a proof-of-concept by Unit 42 researchers. There is no public evidence of this specific technique being exploited in the wild. However, 'bucket squatting' is a known attack class, and with the public disclosure, threat actors may attempt to find and exploit unpatched systems.
A successful exploit of this vulnerability has severe security implications, leading to a complete compromise of the targeted ML model's serving environment. The business impact includes:
No specific Indicators of Compromise (IOCs) were provided in the source article, as it details a vulnerability rather than a specific active campaign.
Security teams may want to hunt for the following patterns to identify potential misuse or vulnerable configurations:
storage.buckets.create and storage.objects.create events.principalEmail does not match project*-vertex-ai-stagingDetecting and responding to this threat requires a focus on both preventative and detective controls.
Detection Strategies:
requirements.txt files to identify vulnerable versions of the google-cloud-aiplatform SDK (1.139.0, 1.140.0).storage.objects.create events where the principalEmail (the actor) belongs to a different project than the bucket's parent project.[your-project-id]-[region]-vertex-ai-staging are owned by an external project.Immediate Actions:
Patch Immediately: The most critical mitigation is to upgrade the google-cloud-aiplatform SDK to version 1.148.0 or newer. This can be done by running: pip install --upgrade google-cloud-aiplatform.
Explicitly Define Staging Buckets: As a defense-in-depth measure, always specify a known, company-owned GCS bucket when uploading models. This overrides the vulnerable default behavior. Example:
from google.cloud import aiplatform
aiplatform.init(project='your-project', staging_bucket='gs://your-secure-staging-bucket')
# ... model upload code
Strategic Recommendations:
service-[PROJECT_NUMBER]@gcp-sa-aiplatform.iam.gserviceaccount.com) has the minimum necessary permissions and does not have overly broad access to unrelated projects or data stores.Upgrade the `google-cloud-aiplatform` SDK to a patched version (1.148.0 or later) to fix the vulnerability.
As a defense-in-depth measure, explicitly configure a secure, owned staging bucket in all model upload scripts to override the SDK's default behavior.
Enable and monitor Google Cloud Audit Logs to detect suspicious cross-project access to GCS buckets.
Educate developers and MLOps engineers on the risks of default configurations and the importance of specifying secure parameters.
The primary and most effective countermeasure is to immediately update the google-cloud-aiplatform library across all development environments, CI/CD runners, and production systems. Organizations should implement a process to scan for vulnerable versions 1.139.0 and 1.140.0 and enforce an upgrade to version 1.148.0 or higher. This can be achieved by updating requirements.txt or pyproject.toml files and rebuilding dependent container images. CI/CD pipelines should include a step that fails the build if vulnerable versions of this library are detected. This directly applies the patch from Google, which introduces the necessary ownership verification for the staging bucket, completely neutralizing the 'bucket squatting' attack vector.
As a critical defense-in-depth measure, organizations must enforce a policy of never relying on default configurations for sensitive operations like model uploads. Specifically for this threat, all Python scripts and applications using the Vertex AI SDK must be modified to explicitly provide the staging_bucket parameter within the aiplatform.init() function or the Model.upload() method. The specified bucket must be one that is owned and controlled by the organization's Google Cloud project. This can be enforced through code reviews, pre-commit hooks that lint for the absence of this parameter, and policy-as-code tools like Open Policy Agent (OPA) Gatekeeper to validate configurations before deployment. This hardening step mitigates the vulnerability even on unpatched SDK versions and protects against similar future vulnerabilities related to default settings.
To detect potential post-exploitation activity, security teams should implement network traffic analysis for egress traffic originating from Vertex AI serving environments. Since a successful RCE would likely lead to C2 communication or data exfiltration, monitoring for anomalous outbound connections is key. Use VPC Flow Logs in conjunction with Google's Packet Mirroring to capture and analyze traffic. Establish a baseline of normal network behavior for your deployed models. Create alerts for connections to non-standard ports, connections to known malicious IPs or domains, or large data transfers to unexpected destinations (e.g., cloud storage providers not used by your organization). This technique serves as a detective control to identify a compromise if preventative measures fail.
Google releases `google-cloud-aiplatform` SDK version 1.148.0, which includes a fix for the vulnerability.
Unit 42 publicly discloses the 'Pickle in the Middle' vulnerability and attack vector.

Cybersecurity professional with over 10 years of specialized experience in security operations, threat intelligence, incident response, and security automation. Expertise spans SOAR/XSOAR orchestration, threat intelligence platforms, SIEM/UEBA analytics, and building cyber fusion centers. Background includes technical enablement, solution architecture for enterprise and government clients, and implementing security automation workflows across IR, TIP, and SOC use cases.
Help others stay informed about cybersecurity threats
Every tactic, technique, and sub-technique used in this threat has been identified and mapped to the MITRE ATT&CK framework for consistent, actionable threat language.
Observables and indicators of compromise (IOCs) have been extracted and cataloged. Risk has been assessed and correlated with known threat actors and historical campaigns.
Detection rules, incident response steps, and D3FEND-aligned mitigation strategies are included so your team can act on this intelligence immediately.
Structured threat data is packaged as a STIX 2.1 bundle and can be visualized as an interactive graph — relationships between actors, malware, techniques, and indicators.
Sigma detection rules are derived from the threat techniques in this article and can be converted for deployment across any major SIEM or EDR platform.