Create the Input Sanitization Template

Check my progress

/ 30

Create the Response Sanitization Template

Check my progress

/ 30

Test Defenses in Agent Platform Workbench

Check my progress

/ 20

Audit Flagged Violations in Cloud Logging

Check my progress

/ 20

This lab may incorporate AI tools to support your learning.
This content is not yet optimized for mobile devices.
For the best experience, please visit us on a desktop computer using a link sent by email.

Overview

In modern enterprise AI architectures, securing Large Language Models (LLMs) requires moving beyond traditional network perimeters to content-aware, semantic firewalls.

Cymbal Wealth, a premier financial services enterprise, is deploying Cymbal Advisor—an advanced AI conversational assistant that helps portfolio managers analyze market trends and client records. However, recent security assessments revealed critical vulnerabilities:

  • Prompt Injections & Jailbreaks: Attackers attempting to bypass system instructions and manipulate model behavior.
  • Malicious URI Injection: Indirect injection attacks through external untrusted links.
  • Sensitive Data Exfiltration: Inadvertent leakage of Personally Identifiable Information (PII) and payment card data in generated model responses.

Traditional network firewalls inspect network packets, but cannot understand the intent or semantics of conversational prompts. To safeguard Cymbal Advisor, you assume the role of Max, Lead Cloud Security Engineer, to deploy Model Armor on Google Cloud.

In this lab, you configure Model Armor input and output sanitization templates, integrate Advanced Sensitive Data Protection (SDP) for dynamic de-identification, validate defenses programmatically via Agent Platform Workbench, and audit security violations in Cloud Logging.

What you'll learn

In this lab, you learn how to perform the following tasks:

  • Explore the centralized Model Armor dashboard and floor settings.
  • Create an Input Sanitization Template to intercept prompt injections, jailbreaks, and malicious URIs.
  • Create a Response Sanitization Template with Advanced Sensitive Data Protection (SDP) to de-identify sensitive customer data.
  • Test semantic firewall defenses in Agent Platform Workbench and audit security events in Cloud Logging.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:

    • The Open Google Cloud console button
    • The temporary credentials (username and password) that you must use for this lab
    • Other information, if needed, to step through this lab

    Note that the lab timer is located near the top of the page, showing the remaining time.

  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab setup and access panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab setup and access panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field. Navigation menu icon and Search field

Activate Cloud Shell

Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  2. Click through the following windows:

    • Continue through the Cloud Shell information window.
    • Authorize Cloud Shell to use your credentials to make Google Cloud API calls.

When you are connected, you are already authenticated, and the project is set to your Project_ID, . The output contains a line that declares the Project_ID for this session:

Your Cloud Platform project in this session is set to {{{project_0.project_id | "PROJECT_ID"}}}

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  1. (Optional) You can list the active account name with this command:
gcloud auth list
  1. Click Authorize.

Output:

ACTIVE: * ACCOUNT: {{{user_0.username | "ACCOUNT"}}} To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:
gcloud config list project

Output:

[core] project = {{{project_0.project_id | "PROJECT_ID"}}} Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Task 1. Explore the Model Armor dashboard and floor settings

Before building semantic firewall policies, explore the centralized Model Armor dashboard to understand how organization-wide floor settings and custom templates are structured.

  1. In the Google Cloud console, use the Navigation menu (Navigation menu icon) to navigate to Security > Security Command Center > Model Armor.
Note: The Model Armor API service is pre-enabled for your lab environment.
  1. Take a moment to explore the Model Armor dashboard. The dashboard provides centralized visibility into:
    • Floor Settings: Organization-wide baseline security policies that downstream templates cannot bypass.
    • Templates: Customizable policy sets for screening incoming user prompts and outgoing model responses.

Task 2. Create the Input Sanitization Template

To protect Cymbal Advisor against adversarial user prompts before they reach the model, you create an input sanitization template named advisor-input-filter.

  1. From the Model Armor dashboard, click Create Template (or + Create).

  2. In the template creation form, configure the following settings:

    • Template ID: advisor-input-filter
    • Region: us-central1
    • Filter version: Select Stable (Recommended) (ensures you use the vetted, reliable detector version).
    • Modality: Ensure Text is checked.
  3. Under the Detections section, configure the security filters:

    • Malicious URI detection: Check the box. (Detects and blocks known phishing and malware links).
    • Prompt injection and jailbreak detection: Check the box.
      • Confidence Level: Select Medium and above (or Medium).
    • Sensitive data protection: Check the box.
      • Detection type: Select Basic (scans for common predefined infoTypes).
    • Under Responsible AI:
      • Verify that the confidence levels for Hate Speech, Dangerous, Sexually Explicit, and Harassment are set to High (default).
  4. Expand the Additional configurations (optional) section:

    • Configure logging:
      • Check Template operations (logs creation, updates, and deletions of Model Armor templates in platform logs).
      • Check Prompts and responses (logs all prompts, responses, Model Armor evaluation verdicts, and sanitized text to Cloud Logging).
    • Multi-language support: Leave Enable Multi-language support unchecked (English will be used by default).
    • Enforcement mode: Verify that Inspect and block is selected (default).
  5. Click Create to deploy the template.

Click Check my progress to verify the objective. Create the Input Sanitization Template


Task 3. Create the Response Sanitization Template

To prevent Cymbal Advisor from leaking sensitive customer data or generating harmful outputs, you create a dedicated output sanitization template named advisor-output-filter.

This template leverages Advanced Sensitive Data Protection (SDP), referencing pre-provisioned Cloud DLP inspect and de-identify templates (advisor-inspect-template and advisor-deidentify-template) to automatically replace detected sensitive values (such as credit card numbers and SSNs) with their infoType name (e.g. [CREDIT_CARD_NUMBER]).

  1. In the Model Armor dashboard, click Create Template.

  2. Configure the general properties:

    • Template ID: advisor-output-filter
    • Region: us-central1
    • Filter version: Select Stable (Recommended).
    • Modality: Ensure Text is checked.
  3. Under the Detections section, configure the filters:

    • Prompt injection and jailbreak detection: Uncheck the box (prompt injections target incoming user inputs, not model responses).
    • Sensitive data protection: Check the box.
      • Detection type: Select Advanced.
      • In the Inspect template field, paste the following full resource path: projects/{{{project_0.project_id}}}/locations/us-central1/inspectTemplates/advisor-inspect-template
      • In the De-identify template field, paste the following full resource path: projects/{{{project_0.project_id}}}/locations/us-central1/deidentifyTemplates/advisor-deidentify-template
    • Under Responsible AI:
      • Verify that the confidence levels for Hate Speech, Dangerous, Sexually Explicit, and Harassment are set to High (default).
  4. Expand the Additional configurations (optional) section:

    • Configure logging:
      • Check Template operations.
      • Check Prompts and responses.
    • Multi-language support: Leave Enable Multi-language support unchecked.
    • Enforcement mode: Verify that Inspect and block is selected.
  5. Click Create.

Click Check my progress to verify the objective. Create the Response Sanitization Template


Task 4. Test Defenses in Agent Platform Workbench

With your templates deployed, you will now test their effectiveness programmatically using the pre-provisioned Jupyter Notebook in Agent Platform Workbench.

  1. In the Google Cloud console, use the Navigation menu (Navigation menu icon) to navigate to Agent Platform > Notebooks > Workbench.

  2. On the Instances tab, locate cymbal-testing-instance and click Open JupyterLab.

  3. In the JupyterLab file browser on the left, double-click model_armor_test.ipynb to open it.

  4. In the Select Kernel dialog, choose Python 3.

  5. Read through and run each cell in the notebook sequentially from top to bottom (Press SHIFT+ENTER):

    • Section 1 (Setup & Discovery): Discovers project credentials and verifies connectivity to Model Armor endpoints.
    • Section 2 (Test 1 - Jailbreak Attempt): Sends an adversarial prompt to advisor-input-filter and observes the MATCH_FOUND block verdict.
    • Section 3 (Test 2 - Malicious URI Injection): Submits a phishing link flagged by Google Threat Intelligence to verify real-time link interception.
    • Section 4 (Test 3 - Sensitive Data Protection & De-Identification): Submits customer PII and financial data to advisor-output-filter and observes dynamic redaction ([CREDIT_CARD_NUMBER], [US_SOCIAL_SECURITY_NUMBER], [EMAIL_ADDRESS], [PHONE_NUMBER]).
  6. Ensure all test cells have executed successfully and produced outputs before proceeding.

Security Deep Dive: Detectors like CREDIT_CARD_NUMBER do not just match digit length—they run mathematical checksum validations (such as the Luhn algorithm) before assigning a high-confidence finding. When configuring SDP inspect templates in production, setting min_likelihood allows security engineers to balance false-positive rates against strict exfiltration prevention.

Click Check my progress to verify the objective. Test Defenses in Agent Platform Workbench


Task 5. Audit Flagged Violations in Cloud Logging

Model Armor integrates natively with Cloud Logging to provide comprehensive audit trails for security operations and threat hunting teams.

  1. In the Google Cloud console, use the Navigation menu (Navigation menu icon) to navigate to Logging > Logs Explorer.

  2. In the Query pane, paste the following filter to isolate Model Armor sanitization events:

jsonPayload.@type="type.googleapis.com/google.cloud.modelarmor.logging.v1.SanitizeOperationLogEntry"
  1. Click Run query.

  2. In the Query results pane, click the chevron (>) next to a recent log entry to expand it and drill down into the following fields under jsonPayload:

    • operationType: Distinguishes whether the event evaluated an incoming user prompt (SANITIZE_USER_PROMPT) or a generated model response (SANITIZE_MODEL_RESPONSE).
    • sanitizationInput.text: Review the intercepted payload. Notice that because de-identification was active, sensitive customer data is masked with token tags ([CREDIT_CARD_NUMBER], [US_SOCIAL_SECURITY_NUMBER]), ensuring raw sensitive data is never exposed in plain text within log storage.
    • sanitizationResult.filterMatchState: Confirms that a threat was intercepted (MATCH_FOUND).
    • sanitizationResult.filterResults: Expand individual detectors (such as sdp, pi_and_jailbreak, or malicious_uris) to review granular detection coordinates and confidence scores.
    • sanitizationMetadata.sanitizationVerdict: Displays the active enforcement outcome (MODEL_ARMOR_SANITIZATION_VERDICT_BLOCK) along with the sanitizationVerdictReason.

Click Check my progress to verify the objective. Audit Flagged Violations in Cloud Logging


Congratulations!

You have successfully deployed and validated an active semantic firewall using Model Armor!

You configured input and output sanitization templates, integrated Advanced Sensitive Data Protection to mask sensitive financial and PII data, executed real-world attack simulations via Agent Platform Workbench, and monitored threat activity in Cloud Logging.

Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We can notify you via email when it becomes available

Great!

We can contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Using an Incognito or private browser window is the best way to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.