{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "bf5e6905", "metadata": { "id": "2eec5cc39a59" }, "outputs": [], "source": [ "# Copyright 2024 Google LLC\n", "#\n", "# Licensed under the Apache License, Version 2.0 (the \"License\");\n", "# you may not use this file except in compliance with the License.\n", "# You may obtain a copy of the License at\n", "#\n", "# https://www.apache.org/licenses/LICENSE-2.0\n", "#\n", "# Unless required by applicable law or agreed to in writing, software\n", "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", "# See the License for the specific language governing permissions and\n", "# limitations under the License." ] }, { "cell_type": "markdown", "id": "e9cc1a26", "metadata": { "id": "hwWwZep-5uLR" }, "source": [ "# Gen AI & LLM Security for developers\n", "\n", "## Prompt Injection Attacks & Mitigations\n", "\n", "Demonstrates prompt protection topics of LLM model.\n", "\n", "- Simple prompt design [prompt design](https://cloud.google.com/vertex-ai/docs/generative-ai/learn/introduction-prompt-design)\n", "- Antipatterns on [prompt design](https://cloud.google.com/vertex-ai/docs/generative-ai/learn/introduction-prompt-design) with PII data and secrets\n", "- Prompt Attacks:\n", " - Data Leaking\n", " - Data Leaking with Transformations\n", " - Modifying the Output (Jailbreaking)\n", " - Hallucinations\n", " - Payload Splitting\n", " - Virtualization\n", " - Obfuscation\n", " - Multimodal Attacks (Image, PDF & Video)\n", " - Model poisioning\n", "- Protections & Mitigations with:\n", " - [Data Loss Prevention](https://cloud.google.com/dlp?hl=en)\n", " - [Natural Language API](https://cloud.google.com/natural-language) (Category Check, Sentiment Analysis)\n", " - Malware checking\n", " - LLM validation (Hypothesis Validation, DARE, Strict Input Validation with Random Token)\n", " - [Responsible AI Safety filters](https://cloud.google.com/vertex-ai/docs/generative-ai/learn/responsible-ai)\n", " - [Embeddings](https://developers.google.com/machine-learning/crash-course/embeddings/video-lecture)\n", "\n", "- Complete end-to-end integration example\n", "- Attacks and Mitigation on ReAct and RAG\n", "\n", "This is only learning and demonstration material and should not be used in production. **This in NOT production code**\n", "\n", "Authors: alexmeissner@google.com, vesselin@google.com\n", "\n", "Version: 3.0 - 06.2026" ] }, { "cell_type": "markdown", "id": "2ada9d8c", "metadata": { "id": "6cc19e98483e" }, "source": [ "
| \n",
" \n",
" Open in Colab\n", " \n", " | \n",
" \n",
" \n",
" Open in Colab Enterprise\n", " \n", " | \n",
" \n",
" \n",
" Open in Workbench\n", " \n", " | \n",
" \n",
" \n",
" View on GitHub\n", " \n", " | \n",
"
\n",
"Share to:\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n",
" \n",
"\n",
"