Building a Production-Ready AI Security Foundation

Aron Eidelman
Developer Relations Engineer, Security Advocate
Scaling Generative AI applications from proof-of-concept to production is often bottlenecked by security concerns, specifically sensitive data exposure and prompt injection.
Establishing a production-ready posture requires a defense-in-depth strategy across three layers:
-
Application Layer: Real-time threat detection and mitigation.
-
Data Layer: Enforcing privacy controls and compliance.
-
Infrastructure: Network segmentation and compute isolation.
To implement these controls, this guide details three hands-on labs focused on securing these specific architectural planes.
Protect the Application in Real-Time: Model Armor
The application layer, where users directly interact with your AI model, is the most exposed surface in a GenAI application. This surface is frequently targeted by attackers using prompts and responses to exploit vulnerabilities.
This lab focuses on securing the application and model layers by demonstrating how to deploy a comprehensive security service called Model Armor. Model Armor acts as an intelligent firewall, analyzing prompts and responses in real-time to detect and block threats before they can cause harm.
In this lab, you learn to mitigate critical risks, including:
-
Prompt injection & jailbreaking: Malicious users crafting prompts to bypass safety guardrails or extract confidential data. You will create a Model Armor security policy that automatically detects and blocks these attempts.
-
Malicious URL detection: Blocking users who embed dangerous links in prompts, which could be part of an indirect injection.
-
Sensitive data leakage: Preventing the model from inadvertently exposing Personally Identifiable Information (PII) in its responses.
The Key Components:
You will create reusable templates that define what Model Armor should analyze, detect, and block. The block-unsafe-prompts template targets malicious inputs, while the data-loss-prevention template prevents sensitive data from being exposed in prompts or responses.
After completing this lab, you will have the blueprint to integrate Model Armor directly into your application’s backend API, ensuring that every request to your model first passes through this real-time threat detection layer.
Safeguard AI Data with Sensitive Data Protection
While the application layer needs real-time defense, the data used for training and testing AI models requires protection before it even enters the development environment. Raw customer data poses significant privacy challenges, and developers need high-quality data that is safe and compliant.
This lab guides you through building an automated data sanitization pipeline to protect sensitive information used in AI development. You will use Google Cloud’s Sensitive Data Protection (SDP) to inspect, classify, and de-identify Personally Identifiable Information (PII) across various data formats.
The Key Components:
-
Inspection Templates: You define an inspection template to look for specific sensitive information types, or infoTypes, that are relevant to your data and geography, such as credit card numbers or SSNs.
-
De-identification Templates: You build separate de-identification templates for different data formats, giving you granular control:
-
Unstructured Data: Replacing sensitive values in text files (like chat logs) with their
infoTypename to preserve context. -
Structured Data: Using record transformations like character masking on CSV files to preserve data utility for testing while still de-identifying sensitive fields.
-
Image Data: Leveraging optical character recognition (OCR) to detect and redact sensitive text embedded within images.
-
Automated Jobs: You configure a single job that automatically applies the correct redaction based on the file type it detects and inspects, automating the security workflow for data stored in Cloud Storage.
In a production environment, you would use these templates to create a fully automated, hands-off detection and de-identification process, often by setting up a job trigger whenever new raw customer data is uploaded. For sensitive data unique to your business, you can define custom infoTypes within Sensitive Data Protection.
Harden the AI Infrastructure Foundation
The final layer of defense is the underlying infrastructure that hosts your development, training, and deployment processes. A production-ready AI environment must be isolated, hardened, and protected from system tampering, privilege escalation, and accidental data exposure.
This lab focuses on mitigating common infrastructure threats by creating a multi-layered, secure foundation.
The Key Components:
-
Secure Network Foundation: You provision a secure Virtual Private Cloud (VPC) and subnet, configured with Private Google Access to ensure that compute resources can reach Google APIs over a private network, avoiding the public internet. You also deploy a Cloud NAT gateway to allow private instances to initiate controlled outbound connections without having a public IP.
-
Hardened Compute: You deploy a secure Vertex AI Workbench instance inside your private VPC, which serves as your isolated development environment. You enforce the principle of least privilege by creating and assigning a dedicated service account with only the necessary roles. The instance itself is hardened by disabling root access and enabling security features like Secure Boot.
-
Secure Storage: You create a fortified Cloud Storage bucket for your datasets, models, and artifacts. You apply strong configurations, including:
-
Enforce public access prevention to override any misconfigured IAM settings.
-
Uniform bucket-level access for simpler, more predictable control.
-
Object versioning and soft delete for recovery from accidental or malicious overwrites or deletions.
-
Data access logs to provide a comprehensive and immutable audit trail.
For maximum security, this entire environment can be wrapped in a VPC Service Controls perimeter, which prevents data exfiltration by ensuring services can only be accessed by authorized resources within your private network perimeter.
Build Your Production-Ready AI Security Today
Ready to move your AI project from prototype to a secure, production-grade application? Dive into the codelabs now to begin your journey across the application, data, and infrastructure layers:
These labs are part of the Securing AI Applications module in our official Production-Ready AI with Google Cloud program. Explore the full curriculum for more content that will help you bridge the gap from a promising prototype to a production-grade AI application.
Share your progress and connect with others on the journey using the hashtag #ProductionReadyAI. Happy learning!



