{"id":40666,"date":"2026-11-24T07:00:00","date_gmt":"2026-11-24T15:00:00","guid":{"rendered":"https:\/\/cloudinary.com\/blog\/?p=40666"},"modified":"2026-11-23T10:45:17","modified_gmt":"2026-11-23T18:45:17","slug":"protect-ai-agents-image-prompt-injection-nextjs-cloudinary","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","title":{"rendered":"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>Multimodal AI agents can treat words inside an image as instructions, not only as content. If an application sends every uploaded image directly to a vision model, an attacker may be able to steer the model, request secrets, or influence tool use through visible text or more subtle cross-modal signals.<\/p>\n<p>Yes, hidden or visible instructions inside an image can manipulate a multimodal AI agent. The defensive pattern in this tutorial places each image in an authenticated Cloudinary quarantine, extracts text and metadata, checks its moderation state, persists a policy decision, and releases a signed image URL only when every required gate passes.<\/p>\n<ul>\n<li>Live demo: <a href=\"https:\/\/prompt-injection-with-next-js-and-c.vercel.app\/\">https:\/\/prompt-injection-with-next-js-and-c.vercel.app\/<\/a>\n<\/li>\n<li>Github repo: <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\">https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary<\/a>\n<\/li>\n<\/ul>\n<p>This pipeline reduces exposure to image prompt injection. It is a layered control, not a universal detector for every adversarial image.<\/p>\n<h2>What You\u2019ll Build<\/h2>\n<p>You\u2019ll build a Next.js ingestion layer that makes Cloudinary the source of truth for an image\u2019s security state. It will:<\/p>\n<ol>\n<li>Validate an uploaded JPEG, PNG, or WebP before processing it.<\/li>\n<li>Store the image as an authenticated Cloudinary asset.<\/li>\n<li>Run Cloudinary\u2019s Advanced OCR and Amazon Rekognition moderation.<\/li>\n<li>Inspect returned media metadata for instruction-like content.<\/li>\n<li>Evaluate a fail-closed policy and persist its decision as structured metadata.<\/li>\n<li>Read the asset back through the Cloudinary Admin API.<\/li>\n<li>Return a signed agent payload only for an allowed asset.<\/li>\n<\/ol>\n<p>The finished demo does not invoke a vision model. Instead, it proves the security boundary immediately before that invocation, which is the point where an application should decide whether the model can receive the image.<\/p>\n<h2>Why Image Prompt Injection Needs a Separate Security Boundary<\/h2>\n<p>The <a href=\"https:\/\/genai.owasp.org\/llmrisk\/llm01-prompt-injection\/\">OWASP GenAI Security Project describes multimodal prompt injection<\/a> as a risk in which malicious instructions embedded in an image can alter a model\u2019s behavior and potentially cause unauthorized actions or information disclosure.<\/p>\n<p>This risk is broader than readable text. The peer-reviewed USENIX Security 2025 paper <a href=\"https:\/\/www.usenix.org\/conference\/usenixsecurity25\/presentation\/zhang-tingwei\">Self-interpreting Adversarial Images<\/a> demonstrates cross-modal attacks in which natural-looking images contain hidden meta-instructions that steer a model\u2019s interpretation. That research is also why this tutorial describes optical character recognition (OCR) as one defense layer, not a complete solution.<\/p>\n<p>The application uses a quarantine-first architecture:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">Browser<\/span>\n  <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">Next<\/span><span class=\"hljs-selector-class\">.js<\/span> <span class=\"hljs-selector-tag\">upload<\/span> <span class=\"hljs-selector-tag\">route<\/span>\n  <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">file<\/span> <span class=\"hljs-selector-tag\">validation<\/span>\n  <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">authenticated<\/span> <span class=\"hljs-selector-tag\">Cloudinary<\/span> <span class=\"hljs-selector-tag\">quarantine<\/span>\n       <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">Advanced<\/span> <span class=\"hljs-selector-tag\">OCR<\/span>\n       <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">media<\/span> <span class=\"hljs-selector-tag\">metadata<\/span> <span class=\"hljs-selector-tag\">extraction<\/span>\n       <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">Amazon<\/span> <span class=\"hljs-selector-tag\">Rekognition<\/span> <span class=\"hljs-selector-tag\">moderation<\/span>\n  <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">policy<\/span> <span class=\"hljs-selector-tag\">decision<\/span>\n  <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">Cloudinary<\/span> <span class=\"hljs-selector-tag\">structured<\/span> <span class=\"hljs-selector-tag\">metadata<\/span>\n  <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">Admin<\/span> <span class=\"hljs-selector-tag\">API<\/span> <span class=\"hljs-selector-tag\">readback<\/span>\n       <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">block<\/span> <span class=\"hljs-selector-tag\">or<\/span> <span class=\"hljs-selector-tag\">review<\/span>: <span class=\"hljs-selector-tag\">no<\/span> <span class=\"hljs-selector-tag\">agent<\/span> <span class=\"hljs-selector-tag\">URL<\/span>\n       <span class=\"hljs-selector-tag\">-<\/span>&gt; <span class=\"hljs-selector-tag\">allow<\/span>: <span class=\"hljs-selector-tag\">signed<\/span> <span class=\"hljs-selector-tag\">image<\/span> <span class=\"hljs-selector-tag\">URL<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Cloudinary is load-bearing in this design. It stores the quarantined asset, runs the image analyses, preserves the policy record, and enforces signed delivery.<\/p>\n<h2>Prerequisites<\/h2>\n<p>You\u2019ll need:<\/p>\n<ul>\n<li>Node.js 20 or later.<\/li>\n<li>A Cloudinary account with access to the Marketplace.<\/li>\n<li>The <strong>Text Detection and Extraction<\/strong> add-on by Google.<\/li>\n<li>The <strong>AI Moderation<\/strong> add-on by Amazon Rekognition.<\/li>\n<li>A Vercel account only if you want to deploy the finished application.<\/li>\n<\/ul>\n<p>Both Cloudinary add-ons require registration and have usage quotas. The <a href=\"https:\/\/console.cloudinary.com\/addons\/\">Cloudinary Marketplace<\/a> currently offers free plans, but plans and prices can change, so review the quota shown in your product environment before production use. Cloudinary documents a minimum image resolution of 1024 by 768 pixels for Advanced OCR. Amazon Rekognition moderation accepts smaller images, but OCR is the stricter requirement for this combined pipeline.<\/p>\n<p>The project uses Next.js 16, React 19, the Cloudinary Node.js SDK, <code>next-cloudinary<\/code>, shadcn components, and Vitest. It was scaffolded with <a href=\"https:\/\/github.com\/cloudinary-devs\/create-cloudinary-next\">create-cloudinary-next<\/a>.<\/p>\n<h2>Step 1: Clone and Install the Project<\/h2>\n<p>Clone the finished project so your code matches the excerpts in this tutorial:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">git <span class=\"hljs-keyword\">clone<\/span> https:<span class=\"hljs-comment\">\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary.git<\/span>\ncd <span class=\"hljs-string\">\"Prompt-Injection-With-Next.js-and-Cloudinary\"<\/span>\nnpm install\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>If you want to reproduce the initial scaffold instead, start with <code>create-cloudinary-next<\/code>, then add the server routes and policy files from the repository.<\/p>\n<h2>Step 2: Enable the Required Cloudinary Add-ons<\/h2>\n<p>The Marketplace contains several products with similar names. This application needs these exact two cards:<\/p>\n<figure class=\"table-wrapper\"><table>\n<thead>\n<tr>\n<th>Cloudinary Marketplace card<\/th>\n<th>Provider<\/th>\n<th>Environment Value<\/th>\n<th>Purpose in This Pipeline<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>Text Detection and Extraction<\/strong><\/td>\n<td>Google<\/td>\n<td><code>CLOUDINARY_OCR_MODE=adv_ocr<\/code><\/td>\n<td>Extract visible text for the prompt-injection policy<\/td>\n<\/tr>\n<tr>\n<td><strong>AI Moderation<\/strong><\/td>\n<td>Amazon Rekognition<\/td>\n<td><code>CLOUDINARY_MODERATION_KIND=aws_rek<\/code><\/td>\n<td>Check unsafe visual-content categories and return a moderation state<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n<p>Don\u2019t select <strong>AI Content Analysis<\/strong> or <strong>Cloudinary AI Vision<\/strong> for this implementation. Those products expose different capabilities and parameters.<\/p>\n<p>In the Cloudinary Console:<\/p>\n<ol>\n<li>Open <strong>Marketplace<\/strong> using the puzzle-piece icon.<\/li>\n<li>Select <strong>Text Detection and Extraction<\/strong> by Google.<\/li>\n<li>Choose a plan and confirm the registration.<\/li>\n<li>Return to the Marketplace and select <strong>AI Moderation<\/strong> by Amazon Rekognition.<\/li>\n<li>Choose a plan and confirm the registration.<\/li>\n<li>Open <strong>Installed Add-ons<\/strong> and verify that both products appear.<\/li>\n<\/ol>\n<p>Cloudinary\u2019s <a href=\"https:\/\/cloudinary.com\/documentation\/ocr_text_detection_and_extraction_addon\">OCR add-on documentation<\/a> defines <code>adv_ocr<\/code> for photos and graphics, and <code>adv_ocr:document<\/code> for text-heavy documents. The <a href=\"https:\/\/cloudinary.com\/documentation\/aws_rekognition_ai_moderation_addon\">Amazon Rekognition moderation documentation<\/a> defines <code>aws_rek<\/code> as the upload parameter used here.<\/p>\n<h2>Step 3: Configure Server Credentials<\/h2>\n<p>Open <strong>Settings<\/strong> and then <strong>API Keys<\/strong> in the Cloudinary Console. Copy the cloud name and API key for the product environment used by the demo, and create or reveal its API secret. If a secret has appeared in chat, logs, screenshots, or another untrusted location, rotate it before continuing.<\/p>\n<p>Copy the environment template:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">cp<\/span> <span class=\"hljs-selector-class\">.env<\/span><span class=\"hljs-selector-class\">.example<\/span> <span class=\"hljs-selector-class\">.env<\/span><span class=\"hljs-selector-class\">.local<\/span>\n<span class=\"hljs-selector-tag\">openssl<\/span> <span class=\"hljs-selector-tag\">rand<\/span> <span class=\"hljs-selector-tag\">-hex<\/span> 32\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The second command generates a 64-character random value for the reviewer-session secret. Add the generated value and your Cloudinary credentials to <code>.env.local<\/code>:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=your_cloud_name\nCLOUDINARY_API_KEY=your_api_key\nCLOUDINARY_API_SECRET=your_rotated_api_secret\nDEMO_SESSION_SECRET=your_64_character_random_value\nCLOUDINARY_OCR_MODE=adv_ocr\nCLOUDINARY_MODERATION_KIND=aws_rek\nNEXT_PUBLIC_SITE_URL=http:<span class=\"hljs-comment\">\/\/localhost:3000<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Only the cloud name has the <code>NEXT_PUBLIC_<\/code> prefix. The API key and API secret authenticate server requests, while the session secret signs a scoped, HTTP-only reviewer cookie. Never expose either secret to a Client Component, browser bundle, screenshot, log, or Git commit.<\/p>\n<p>You can copy the complete variable list from <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/.env.example\"><code>.env.example<\/code><\/a>.<\/p>\n<h2>Step 4: Provision Cloudinary Structured Metadata<\/h2>\n<p>Structured metadata turns the scan result into a durable record on the asset. This prevents the UI from becoming the authority for an approval decision.<\/p>\n<p>Run the setup command once for each Cloudinary product environment:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">npm<\/span> <span class=\"hljs-selector-tag\">run<\/span> <span class=\"hljs-selector-tag\">cloudinary<\/span><span class=\"hljs-selector-pseudo\">:setup<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The script calls the Cloudinary Metadata API, skips fields that already exist, and creates the missing definitions. These are the fields it provisions:<\/p>\n<figure class=\"table-wrapper\"><table>\n<thead>\n<tr>\n<th>External ID<\/th>\n<th>Stored Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>pi_decision<\/code><\/td>\n<td><code>allow<\/code>, <code>review<\/code>, or <code>block<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>pi_risk_score<\/code><\/td>\n<td>Policy score from 0 to 100<\/td>\n<\/tr>\n<tr>\n<td><code>pi_policy_version<\/code><\/td>\n<td>Version of the rule set that made the decision<\/td>\n<\/tr>\n<tr>\n<td><code>pi_ocr_status<\/code><\/td>\n<td>OCR completion state<\/td>\n<\/tr>\n<tr>\n<td><code>pi_moderation_status<\/code><\/td>\n<td>Cloudinary moderation state<\/td>\n<\/tr>\n<tr>\n<td><code>pi_ocr_text<\/code><\/td>\n<td>Untrusted text extracted from the image<\/td>\n<\/tr>\n<tr>\n<td><code>pi_metadata_text<\/code><\/td>\n<td>Flattened, untrusted media metadata<\/td>\n<\/tr>\n<tr>\n<td><code>pi_signals<\/code><\/td>\n<td>Compact JSON summary of triggered rules<\/td>\n<\/tr>\n<tr>\n<td><code>pi_original_filename<\/code><\/td>\n<td>Original client filename<\/td>\n<\/tr>\n<tr>\n<td><code>pi_scanned_at<\/code><\/td>\n<td>Scan date<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n<p>The setup engine is small because Cloudinary manages the field definitions:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> existing = <span class=\"hljs-keyword\">await<\/span> cloudinary.api.list_metadata_fields();\n<span class=\"hljs-keyword\">const<\/span> existingIds = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Set<\/span>(\n  existing.metadata_fields.map(<span class=\"hljs-function\">(<span class=\"hljs-params\">field<\/span>) =&gt;<\/span> field.external_id),\n);\n\n<span class=\"hljs-keyword\">for<\/span> (<span class=\"hljs-keyword\">const<\/span> &#91;external_id, label] <span class=\"hljs-keyword\">of<\/span> fields) {\n  <span class=\"hljs-keyword\">if<\/span> (existingIds.has(external_id)) <span class=\"hljs-keyword\">continue<\/span>;\n  <span class=\"hljs-keyword\">await<\/span> cloudinary.api.add_metadata_field({\n    external_id,\n    label,\n    <span class=\"hljs-attr\">type<\/span>: <span class=\"hljs-string\">\"string\"<\/span>,\n    <span class=\"hljs-attr\">mandatory<\/span>: <span class=\"hljs-literal\">false<\/span>,\n  });\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<blockquote>\n<p>See the full <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/scripts\/setup-cloudinary.mjs\"><code>setup-cloudinary.mjs<\/code> script<\/a>. Cloudinary\u2019s <a href=\"https:\/\/cloudinary.com\/documentation\/structured_metadata\">structured metadata documentation<\/a> explains how typed fields remain attached to assets and can be managed through the API or Media Library.<\/p>\n<\/blockquote>\n<p>To verify this step in the Console, open <strong>Settings<\/strong>, find <strong>Manage Structured Metadata<\/strong>, and confirm that all ten <code>pi_*<\/code> fields are enabled.<\/p>\n<h2>Step 5: Validate the File before Cloudinary Upload<\/h2>\n<p>The Next.js route rejects invalid input before it consumes add-on quota. It enforces an 8 MB request limit, compares the declared MIME type with JPEG, PNG, or WebP magic bytes, and applies a 40-megapixel cap after Cloudinary decodes the image.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> contentLength = <span class=\"hljs-built_in\">Number<\/span>(request.headers.get(<span class=\"hljs-string\">\"content-length\"<\/span>) ?? <span class=\"hljs-number\">0<\/span>);\n<span class=\"hljs-keyword\">if<\/span> (contentLength &gt; uploadLimits.maxBytes + <span class=\"hljs-number\">256<\/span>_000) {\n  <span class=\"hljs-keyword\">return<\/span> errorResponse(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Error<\/span>(<span class=\"hljs-string\">\"The request exceeds the 8 MB upload limit.\"<\/span>), <span class=\"hljs-number\">413<\/span>);\n}\n\n<span class=\"hljs-keyword\">const<\/span> formData = <span class=\"hljs-keyword\">await<\/span> request.formData();\n<span class=\"hljs-keyword\">const<\/span> image = formData.get(<span class=\"hljs-string\">\"image\"<\/span>);\n<span class=\"hljs-keyword\">if<\/span> (!(image <span class=\"hljs-keyword\">instanceof<\/span> File)) {\n  <span class=\"hljs-keyword\">return<\/span> errorResponse(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Error<\/span>(<span class=\"hljs-string\">\"Add an image using the image form field.\"<\/span>), <span class=\"hljs-number\">400<\/span>);\n}\n\n<span class=\"hljs-keyword\">const<\/span> bytes = <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Uint8Array<\/span>(<span class=\"hljs-keyword\">await<\/span> image.arrayBuffer());\nvalidateImageFile(image, bytes);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<blockquote>\n<p>Read the complete <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/app\/api\/scans\/route.ts\"><code>POST \/api\/scans<\/code> route<\/a> and <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/security\/file.ts\"><code>file validation module<\/code><\/a>.<\/p>\n<\/blockquote>\n<p>These checks reduce common upload abuse, but they do not replace dedicated malware scanning or full decompression-bomb protection in a high-risk production system.<\/p>\n<h2>Step 6: Upload Into an Authenticated Cloudinary Quarantine<\/h2>\n<p>The browser sends the file to the Next.js server. The server then uses <code>upload_stream<\/code> so the Cloudinary API secret never reaches the browser.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> options: UploadApiOptions = {\n  ...optionalAnalysisOptions(),\n  <span class=\"hljs-attr\">resource_type<\/span>: <span class=\"hljs-string\">\"image\"<\/span>,\n  <span class=\"hljs-attr\">type<\/span>: <span class=\"hljs-string\">\"authenticated\"<\/span>,\n  <span class=\"hljs-attr\">public_id<\/span>: <span class=\"hljs-string\">`agent-shield\/quarantine\/<span class=\"hljs-subst\">${randomUUID()}<\/span>`<\/span>,\n  <span class=\"hljs-attr\">overwrite<\/span>: <span class=\"hljs-literal\">false<\/span>,\n  <span class=\"hljs-attr\">media_metadata<\/span>: <span class=\"hljs-literal\">true<\/span>,\n  <span class=\"hljs-attr\">tags<\/span>: &#91;<span class=\"hljs-string\">\"agent-shield\"<\/span>, <span class=\"hljs-string\">\"quarantine\"<\/span>, <span class=\"hljs-string\">\"untrusted-input\"<\/span>],\n  <span class=\"hljs-attr\">context<\/span>: {\n    <span class=\"hljs-attr\">original_filename<\/span>: filename,\n    <span class=\"hljs-attr\">trust_boundary<\/span>: <span class=\"hljs-string\">\"untrusted\"<\/span>,\n  },\n  <span class=\"hljs-attr\">headers<\/span>: <span class=\"hljs-string\">\"X-Robots-Tag: noindex, nofollow\"<\/span>,\n};\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The <code>authenticated<\/code> delivery type is the quarantine boundary. Cloudinary states that authenticated originals and derived assets require signed access. The random public ID prevents user-controlled naming, <code>overwrite: false<\/code> protects an existing asset, and <code>X-Robots-Tag<\/code> discourages indexing if a URL is ever exposed.<\/p>\n<p>The application requests <code>ocr: &quot;adv_ocr&quot;<\/code>, <code>moderation: &quot;aws_rek&quot;<\/code>, and <code>media_metadata: true<\/code> in the same signed server upload. See the full <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/cloudinary\/security-assets.ts\"><code>uploadQuarantinedImage<\/code> implementation<\/a>.<\/p>\n<h2>Step 7: Extract OCR, Metadata, and Moderation Evidence<\/h2>\n<p>The upload response contains three different evidence surfaces. Treat all of them as untrusted input.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> ocr = extractOcr(upload);\n<span class=\"hljs-keyword\">const<\/span> moderationStatus = extractModerationStatus(upload);\n<span class=\"hljs-keyword\">const<\/span> metadataText = &#91;\n  image.name,\n  flattenMetadata(upload.media_metadata),\n].join(<span class=\"hljs-string\">\" \"<\/span>).trim();\n\n<span class=\"hljs-keyword\">const<\/span> result = evaluateImagePolicy({\n  <span class=\"hljs-attr\">ocrText<\/span>: ocr.text,\n  metadataText,\n  <span class=\"hljs-attr\">ocrStatus<\/span>: ocr.status,\n  moderationStatus,\n});\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Advanced OCR returns text under <code>info.ocr.adv_ocr<\/code>. Media metadata may include Exchangeable Image File Format (EXIF), International Press Telecommunications Council (IPTC), or Extensible Metadata Platform (XMP) values. Amazon Rekognition moderation returns states such as <code>approved<\/code>, <code>rejected<\/code>, or <code>pending<\/code>.<\/p>\n<p>Moderation and prompt-injection detection solve different problems. Moderation identifies categories of unsafe visual content. The local policy examines OCR and metadata for instruction-like language. An image must pass both layers.<\/p>\n<h2>Step 8: Make the Policy Fail Closed<\/h2>\n<p>The policy detects common instruction overrides, prompt-role references, secret extraction requests, tool-execution requests, authority claims, and imperatives. A strong signal or rejected moderation blocks the image. Missing analysis never produces <code>allow<\/code>.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> score = <span class=\"hljs-built_in\">Math<\/span>.min(\n  <span class=\"hljs-number\">100<\/span>,\n  signals.reduce(<span class=\"hljs-function\">(<span class=\"hljs-params\">total, signal<\/span>) =&gt;<\/span> total + signal.score, <span class=\"hljs-number\">0<\/span>),\n);\n<span class=\"hljs-keyword\">const<\/span> hasHardBlock =\n  input.moderationStatus === <span class=\"hljs-string\">\"rejected\"<\/span> ||\n  signals.some(<span class=\"hljs-function\">(<span class=\"hljs-params\">signal<\/span>) =&gt;<\/span> signal.score &gt;= <span class=\"hljs-number\">50<\/span>);\n<span class=\"hljs-keyword\">const<\/span> checksComplete =\n  input.ocrStatus === <span class=\"hljs-string\">\"complete\"<\/span> &amp;&amp;\n  input.moderationStatus === <span class=\"hljs-string\">\"approved\"<\/span>;\n<span class=\"hljs-keyword\">const<\/span> decision = hasHardBlock\n  ? <span class=\"hljs-string\">\"block\"<\/span>\n  : score &gt;= <span class=\"hljs-number\">20<\/span> || !checksComplete\n    ? <span class=\"hljs-string\">\"review\"<\/span>\n    : <span class=\"hljs-string\">\"allow\"<\/span>;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>This is a deliberately understandable policy for a tutorial. Production systems should tune rules from measured false positives and false negatives, add model-specific classifiers, and route ambiguous cases to human review. Read the complete <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/security\/policy.ts\"><code>policy.ts<\/code> engine<\/a> and its <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/security\/policy.test.ts\"><code>Vitest cases<\/code><\/a>.<\/p>\n<h2>Step 9: Persist the Decision on the Cloudinary Asset<\/h2>\n<p>The route writes its result back to the authenticated asset. OCR text and embedded metadata remain evidence, not instructions for the downstream model.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">await<\/span> <span class=\"hljs-selector-tag\">cloudinary<\/span><span class=\"hljs-selector-class\">.api<\/span><span class=\"hljs-selector-class\">.update<\/span>(<span class=\"hljs-selector-tag\">upload<\/span><span class=\"hljs-selector-class\">.public_id<\/span>, {\n  <span class=\"hljs-attribute\">resource_type<\/span>: <span class=\"hljs-string\">\"image\"<\/span>,\n  type: <span class=\"hljs-string\">\"authenticated\"<\/span>,\n  metadata: {\n    pi_decision: result.decision,\n    pi_risk_score: <span class=\"hljs-built_in\">String<\/span>(result.score),\n    pi_policy_version: result.policyVersion,\n    pi_ocr_status: ocrStatus,\n    pi_moderation_status: moderationStatus,\n    pi_signals: JSON.<span class=\"hljs-built_in\">stringify<\/span>(result.signals),\n    pi_scanned_at: new <span class=\"hljs-built_in\">Date<\/span>().<span class=\"hljs-built_in\">toISOString<\/span>().<span class=\"hljs-built_in\">slice<\/span>(<span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">10<\/span>),\n  },\n});\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The actual implementation also bounds stored text lengths and minimizes the signal record. See <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/cloudinary\/security-assets.ts\"><code>persistPolicyResult<\/code><\/a>.<\/p>\n<p>Persisting the decision supports later inspection, but persistence alone is not enough. The release endpoint must re-read the authoritative state rather than trusting a browser response or a mutable local object.<\/p>\n<h2>Step 10: Read the Result Back Through the Admin API<\/h2>\n<p>After writing metadata, the application fetches the asset by its immutable Cloudinary <code>asset_id<\/code>:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> asset = <span class=\"hljs-keyword\">await<\/span> cloudinary.api.resource_by_asset_id(\n  assetId,\n  <span class=\"hljs-literal\">undefined<\/span>,\n  {\n    <span class=\"hljs-attr\">metadata<\/span>: <span class=\"hljs-literal\">true<\/span>,\n    <span class=\"hljs-attr\">context<\/span>: <span class=\"hljs-literal\">true<\/span>,\n    <span class=\"hljs-attr\">moderations<\/span>: <span class=\"hljs-literal\">true<\/span>,\n  },\n);\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>This readback proves that the policy record survived the upload request. It also lets the application observe a moderation state that changed asynchronously. The refresh route re-reads the current state and recalculates the decision when moderation initially returns <code>pending<\/code>.<\/p>\n<p>The relevant implementations are <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/cloudinary\/security-assets.ts\"><code>getAssetById<\/code><\/a>, the <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/app\/api\/scans\/%5BscanId%5D\/route.ts\"><code>scan readback route<\/code><\/a>, and the <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/app\/api\/scans\/%5BscanId%5D\/refresh\/route.ts\"><code>moderation refresh route<\/code><\/a>.<\/p>\n<h2>Step 11: Release Only a Signed Agent Payload<\/h2>\n<p>An allowed asset still requires controlled delivery. The server creates a signed URL for the authenticated Cloudinary image:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">createSignedAssetUrl<\/span>(<span class=\"hljs-params\">publicId: string<\/span>) <\/span>{\n  <span class=\"hljs-keyword\">return<\/span> getCloudinary().url(publicId, {\n    <span class=\"hljs-attr\">resource_type<\/span>: <span class=\"hljs-string\">\"image\"<\/span>,\n    <span class=\"hljs-attr\">type<\/span>: <span class=\"hljs-string\">\"authenticated\"<\/span>,\n    <span class=\"hljs-attr\">sign_url<\/span>: <span class=\"hljs-literal\">true<\/span>,\n    <span class=\"hljs-attr\">secure<\/span>: <span class=\"hljs-literal\">true<\/span>,\n  });\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Before returning that URL, the agent route reads Cloudinary again and requires all three conditions:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> asset = <span class=\"hljs-keyword\">await<\/span> getAssetById(scanId);\n<span class=\"hljs-keyword\">const<\/span> scan = assetToScanRecord(asset);\n\n<span class=\"hljs-keyword\">if<\/span> (!scan.agentUrlAvailable) {\n  <span class=\"hljs-keyword\">return<\/span> NextResponse.json(\n    { <span class=\"hljs-attr\">error<\/span>: <span class=\"hljs-string\">\"Fail-closed policy: the image is not approved.\"<\/span> },\n    { <span class=\"hljs-attr\">status<\/span>: <span class=\"hljs-number\">409<\/span> },\n  );\n}\n\n<span class=\"hljs-keyword\">return<\/span> NextResponse.json({\n  <span class=\"hljs-attr\">approved<\/span>: <span class=\"hljs-literal\">true<\/span>,\n  <span class=\"hljs-attr\">input<\/span>: { <span class=\"hljs-attr\">type<\/span>: <span class=\"hljs-string\">\"input_image\"<\/span>, <span class=\"hljs-attr\">image_url<\/span>: scan.reviewUrl },\n});\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>The payload intentionally excludes OCR text, metadata, and signal excerpts. Passing those strings beside the image would reintroduce untrusted instructions into the model context.<\/p>\n<blockquote>\n<p>Read the full <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/app\/api\/scans\/%5BscanId%5D\/agent\/route.ts\"><code>agent release route<\/code><\/a> and <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/lib\/security\/session.ts\"><code>signed reviewer-session implementation<\/code><\/a>.<\/p>\n<\/blockquote>\n<p>Cloudinary\u2019s <a href=\"https:\/\/cloudinary.com\/documentation\/control_access_to_media\">media access-control documentation<\/a> explains authenticated assets and signed delivery URLs. A signed URL validates access to a protected asset, but the URL can still be shared. Use token-based or cookie-based access control, a controlled proxy, or another expiring authorization layer when revocation and link sharing are in scope.<\/p>\n<h2>Step 12: Verify the Cloudinary Asset in the Console<\/h2>\n<p>Don\u2019t stop at a successful browser response. Verify the asset and its persisted security state in Cloudinary:<\/p>\n<ol>\n<li>Upload a benign image so you can inspect an approved asset in <strong>Assets<\/strong>. Rejected moderation results may be available through the moderation view instead of the normal asset view.<\/li>\n<li>Search for the <code>agent-shield<\/code> tag or the <code>agent-shield\/quarantine<\/code> public-ID prefix.<\/li>\n<li>Open the uploaded asset.<\/li>\n<li>Confirm its delivery type is <code>authenticated<\/code>.<\/li>\n<li>Confirm the tags include <code>agent-shield<\/code>, <code>quarantine<\/code>, and <code>untrusted-input<\/code>.<\/li>\n<li>Inspect the moderation result and confirm that Amazon Rekognition is <code>approved<\/code>, <code>rejected<\/code>, or still <code>pending<\/code>.<\/li>\n<li>Open the asset\u2019s metadata panel and confirm that the <code>pi_*<\/code> structured metadata fields contain the decision, score, analysis states, policy version, and date.<\/li>\n<li>Return to the application and request the agent payload. Only an asset with <code>allow<\/code>, completed OCR, and approved moderation should return an image URL.<\/li>\n<\/ol>\n<p>This Console check separates an upload response from a security record that remains available after refresh.<\/p>\n<h2>Test the Result With an Attack Matrix<\/h2>\n<p>Use controlled test images, never real secrets. The repository includes a reproducible <a href=\"https:\/\/github.com\/musebe\/Prompt-Injection-With-Next.js-and-Cloudinary\/blob\/main\/docs\/attack-matrix.md\">image prompt-injection attack matrix<\/a>.<\/p>\n<figure class=\"table-wrapper\"><table>\n<thead>\n<tr>\n<th>Case<\/th>\n<th>Detection Surface<\/th>\n<th>Required Outcome<\/th>\n<th>Verification<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Direct text injection<\/td>\n<td>Application text-input policy<\/td>\n<td>Block before this image pipeline<\/td>\n<td>No Cloudinary upload is required<\/td>\n<\/tr>\n<tr>\n<td>Visible image instructions<\/td>\n<td>Advanced OCR plus policy rules<\/td>\n<td><code>block<\/code> and agent endpoint <code>409<\/code><\/td>\n<td>Inspect OCR signal and persisted <code>pi_decision<\/code><\/td>\n<\/tr>\n<tr>\n<td>Metadata payload<\/td>\n<td>Media metadata plus policy rules<\/td>\n<td><code>block<\/code> or <code>review<\/code>, and endpoint <code>409<\/code><\/td>\n<td>Inspect metadata signal and persisted score<\/td>\n<\/tr>\n<tr>\n<td>Benign image<\/td>\n<td>OCR, metadata, and moderation<\/td>\n<td><code>allow<\/code> only after all checks pass<\/td>\n<td>Confirm signed <code>input_image<\/code> payload<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n<p>On August 22, 2026, the verified benign end-to-end test uploaded a disposable 1200 x 900 image, received completed OCR and approved Amazon Rekognition moderation, persisted policy version <code>2026-08-22.1<\/code>, read the asset back by <code>asset_id<\/code>, and returned a signed <code>input_image<\/code> payload. The disposable Cloudinary asset was then deleted. The policy suite separately verifies visible instruction blocking, metadata exfiltration blocking, pending-moderation review, and benign approval.<\/p>\n<p>Run the complete local validation suite:<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">npm run check\n<\/code><\/span><\/pre>\n<p>At the verified article commit, this command passes linting, TypeScript checks, nine tests, and a Next.js production build.<\/p>\n<h2>Deploy to Vercel<\/h2>\n<p>Add the same seven environment variables to the Vercel project, using the production URL for <code>NEXT_PUBLIC_SITE_URL<\/code>. Keep <code>CLOUDINARY_API_KEY<\/code>, <code>CLOUDINARY_API_SECRET<\/code>, and <code>DEMO_SESSION_SECRET<\/code> server-only.<\/p>\n<p>Run the metadata setup command against the same Cloudinary product environment used by the deployment. Then deploy and verify:<\/p>\n<ol>\n<li>\n<code>GET \/api\/health<\/code> reports configured credentials and enabled analysis modes without returning credential values.<\/li>\n<li>A valid image completes an end-to-end scan.<\/li>\n<li>The Cloudinary Console shows the authenticated asset and persisted metadata.<\/li>\n<li>A blocked or review decision cannot obtain an agent payload.<\/li>\n<li>An allowed decision returns a signed URL only for the current reviewer session.<\/li>\n<\/ol>\n<p>The completed deployment is available in the <a href=\"https:\/\/prompt-injection-with-next-js-and-c.vercel.app\/\">live Agent Shield Lab<\/a>.<\/p>\n<h2>Security Limitations and Production Hardening<\/h2>\n<p>This demo protects a narrow, important boundary. It doesn\u2019t claim that OCR plus regular expressions can detect every image prompt-injection technique.<\/p>\n<figure class=\"table-wrapper\"><table>\n<thead>\n<tr>\n<th>Limitation<\/th>\n<th>Production Control to Consider<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>OCR can miss small, distorted, low-contrast, rotated, or unsupported text<\/td>\n<td>Normalize images, test alternate OCR or classifiers, and require human review for high-impact actions<\/td>\n<\/tr>\n<tr>\n<td>OCR does not detect steganography or model-specific adversarial perturbations<\/td>\n<td>Add specialized detectors, content disarm and reconstruction, and model-specific evaluations<\/td>\n<\/tr>\n<tr>\n<td>Moderation detects unsafe visual categories, not prompt semantics<\/td>\n<td>Keep the prompt-injection policy as a separate gate<\/td>\n<\/tr>\n<tr>\n<td>Heuristic rules can produce false positives and false negatives<\/td>\n<td>Measure on representative data, version policies, and maintain an appeal or review path<\/td>\n<\/tr>\n<tr>\n<td>A signed Cloudinary URL can be shared<\/td>\n<td>Add expiring token or cookie access, or serve through a controlled authorization proxy<\/td>\n<\/tr>\n<tr>\n<td>The demo cookie identifies a review session, not a person<\/td>\n<td>Integrate production identity, authorization, rate limiting, audit logs, and revocation<\/td>\n<\/tr>\n<tr>\n<td>Another part of the agent context can contain an injection<\/td>\n<td>Apply trust boundaries to text, retrieved content, tool output, audio, and every other untrusted modality<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/figure>\n<p>An agent should also use least-privilege tools, explicit action authorization, constrained network access, output validation, and human approval for consequential operations. Image screening reduces the chance that malicious content reaches the model, while capability controls limit the damage if screening fails.<\/p>\n<h2>Protect AI Agents From Image Prompt Injection With Cloudinary<\/h2>\n<p>A secure multimodal agent shouldn\u2019t treat an uploaded image as trusted model input. This Next.js and Cloudinary pipeline quarantines the asset, extracts security evidence, fails closed when required checks are incomplete, persists a versioned decision, and releases only an approved signed image URL.<\/p>\n<p>That boundary won\u2019t eliminate every cross-modal attack. It does give you an auditable place to combine Cloudinary analysis, application policy, human review, and least-privilege agent design before an untrusted image can influence a model.<\/p>\n<p>Ready to start building better visual experiences? <a href=\"https:\/\/cloudinary.com\/users\/register_free\">Sign up<\/a> for a free Cloudinary account today.<\/p>\n<p><strong>Resources:<\/strong><\/p>\n<ul>\n<li>\n<a href=\"https:\/\/cloudinary.com\/blog\/nextjs-secure-image-uploads\">Secure image uploads in Next.js with Cloudinary<\/a> explains signed upload foundations.<\/li>\n<li>\n<a href=\"https:\/\/cloudinary.com\/blog\/community-photo-wall-tanstack-start-cloudinary-ai-moderation\">Build a moderated community photo wall<\/a> explores user-generated content moderation as a separate workflow.<\/li>\n<li>\n<a href=\"https:\/\/cloudinary.com\/documentation\/image_upload_api_reference\">Cloudinary\u2019s Upload API reference<\/a> documents the <code>ocr<\/code>, <code>moderation<\/code>, <code>type<\/code>, metadata, and access-control parameters used here.<\/li>\n<\/ul>\n<\/div>\n\n\n<style>\n.faqs {\n    padding: 30px 60px;\n    margin-top: 40px;\n    background: var(--color-background-offset);\n    border-radius: 20px;\n}\n\n#frequently_asked_questions {\n    margin-bottom: 20px;\n}\n\n.question {\n    margin-bottom: 12px;\n    border-bottom: 1px solid rgba(0, 0, 0, 0.12);\n}\n\n.question summary {\n    position: relative;\n    padding: 18px 40px 18px 0;\n    cursor: pointer;\n    font-weight: 700;\n    list-style: none;\n}\n\n.question summary::-webkit-details-marker {\n    display: none;\n}\n\n.question summary::after {\n    content: \"+\";\n    position: absolute;\n    top: 50%;\n    right: 0;\n    transform: translateY(-50%);\n    font-size: 24px;\n    font-weight: 400;\n    line-height: 1;\n}\n\n.question[open] summary::after {\n    content: \"\u2212\";\n}\n\n.answer {\n    padding: 0 40px 20px 0;\n}\n<\/style>\n\n<div class=\"faqs\">\n\n<h2 id=\"frequently_asked_questions\">Frequently Asked Questions<\/h2>\n\n<details class=\"question\">\n    <summary>Can hidden instructions inside an image manipulate an AI agent?<\/summary>\n    <div class=\"answer\">Yes. Multimodal models can interpret image content as instructions, and research has demonstrated both visible typographic attacks and hidden cross-modal meta-instructions. The practical impact depends on the model, surrounding prompt, available tools, and application permissions.<\/div>\n<\/details>\n\n<details class=\"question\">\n    <summary>Does Cloudinary OCR stop every image prompt-injection attack?<\/summary>\n    <div class=\"answer\">No. Cloudinary OCR exposes detectable text so an application can evaluate it before model delivery. It may miss text, and it does not detect every steganographic or adversarial signal. Combine it with metadata inspection, model-specific testing, least-privilege tools, and human review where risk warrants it.<\/div>\n<\/details>\n\n<details class=\"question\">\n    <summary>Why use authenticated Cloudinary assets instead of public uploads?<\/summary>\n    <div class=\"answer\">Authenticated assets require signed access for both originals and derived resources. That property creates a useful quarantine boundary because an unapproved image has no ordinary public delivery URL.<\/div>\n<\/details>\n\n<details class=\"question\">\n    <summary>What happens while Cloudinary moderation is pending?<\/summary>\n    <div class=\"answer\">The policy returns <code>review<\/code>, not <code>allow<\/code>. The refresh endpoint reads the current moderation state from Cloudinary and recalculates the decision. The agent endpoint remains locked until moderation is approved and OCR is complete.<\/div>\n<\/details>\n\n<details class=\"question\">\n    <summary>Why store the decision in Cloudinary structured metadata?<\/summary>\n    <div class=\"answer\">Structured metadata keeps the decision, policy version, evidence state, and timestamp beside the asset. The agent endpoint can read that persisted record through the Admin API instead of trusting the browser or an earlier response.<\/div>\n<\/details>\n\n<details class=\"question\">\n    <summary>Does a signed Cloudinary URL expire automatically?<\/summary>\n    <div class=\"answer\">No. A signed delivery URL proves that its path was authorized, but it is still a shareable URL. Use Cloudinary token or cookie access control, or an authenticated proxy, when you need expiration, revocation, or user-specific access.<\/div>\n<\/details>\n\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Frequently Asked Questions Can hidden instructions inside an image manipulate an AI agent? Yes. Multimodal models can interpret image content as instructions, and research has demonstrated both visible typographic attacks and hidden cross-modal meta-instructions. The practical impact depends on the model, surrounding prompt, available tools, and application permissions. Does Cloudinary OCR stop every image prompt-injection [&hellip;]<\/p>\n","protected":false},"author":87,"featured_media":40667,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[424,212],"class_list":["post-40666","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-agentic","tag-next-js"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.3 (Yoast SEO v28.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Protect AI Agents From Image Prompt Injection<\/title>\n<meta name=\"description\" content=\"Build a fail-closed Next.js and Cloudinary pipeline that quarantines uploads, extracts image text, persists security decisions, and gates multimodal AI agents.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary\" \/>\n<meta property=\"og:description\" content=\"Build a fail-closed Next.js and Cloudinary pipeline that quarantines uploads, extracts image text, persists security decisions, and gates multimodal AI agents.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-24T15:00:00+00:00\" \/>\n<meta name=\"author\" content=\"melindapham\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\"},\"author\":{\"name\":\"melindapham\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#\\\/schema\\\/person\\\/0d5ad601e4c3b5be89245dfb14be42d9\"},\"headline\":\"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary\",\"datePublished\":\"2026-11-24T15:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\"},\"wordCount\":278,\"publisher\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/res.cloudinary.com\\\/cloudinary-marketing\\\/images\\\/f_auto,q_auto\\\/v1793988466\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA\",\"keywords\":[\"Agentic\",\"Next.js\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2026\",\"copyrightHolder\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\",\"url\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\",\"name\":\"Protect AI Agents From Image Prompt Injection\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/res.cloudinary.com\\\/cloudinary-marketing\\\/images\\\/f_auto,q_auto\\\/v1793988466\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA\",\"datePublished\":\"2026-11-24T15:00:00+00:00\",\"description\":\"Build a fail-closed Next.js and Cloudinary pipeline that quarantines uploads, extracts image text, persists security decisions, and gates multimodal AI agents.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage\",\"url\":\"https:\\\/\\\/res.cloudinary.com\\\/cloudinary-marketing\\\/images\\\/f_auto,q_auto\\\/v1793988466\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA\",\"contentUrl\":\"https:\\\/\\\/res.cloudinary.com\\\/cloudinary-marketing\\\/images\\\/f_auto,q_auto\\\/v1793988466\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\\\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA\",\"width\":2000,\"height\":1100},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/cloudinary.com\\\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/res.cloudinary.com\\\/cloudinary-marketing\\\/images\\\/f_auto,q_auto\\\/v1649718331\\\/Web_Assets\\\/blog\\\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\\\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\\\/\\\/res.cloudinary.com\\\/cloudinary-marketing\\\/images\\\/f_auto,q_auto\\\/v1649718331\\\/Web_Assets\\\/blog\\\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\\\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/cloudinary.com\\\/blog\\\/#\\\/schema\\\/person\\\/0d5ad601e4c3b5be89245dfb14be42d9\",\"name\":\"melindapham\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"caption\":\"melindapham\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Protect AI Agents From Image Prompt Injection","description":"Build a fail-closed Next.js and Cloudinary pipeline that quarantines uploads, extracts image text, persists security decisions, and gates multimodal AI agents.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","og_locale":"en_US","og_type":"article","og_title":"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary","og_description":"Build a fail-closed Next.js and Cloudinary pipeline that quarantines uploads, extracts image text, persists security decisions, and gates multimodal AI agents.","og_url":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","og_site_name":"Cloudinary Blog","article_published_time":"2026-11-24T15:00:00+00:00","author":"melindapham","twitter_card":"summary_large_image","twitter_image":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary"},"author":{"name":"melindapham","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9"},"headline":"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary","datePublished":"2026-11-24T15:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary"},"wordCount":278,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA","keywords":["Agentic","Next.js"],"inLanguage":"en-US","copyrightYear":"2026","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","url":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","name":"Protect AI Agents From Image Prompt Injection","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA","datePublished":"2026-11-24T15:00:00+00:00","description":"Build a fail-closed Next.js and Cloudinary pipeline that quarantines uploads, extracts image text, persists security decisions, and gates multimodal AI agents.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA","width":2000,"height":1100},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog"},{"@type":"ListItem","position":2,"name":"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9","name":"melindapham","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","caption":"melindapham"}}]}},"parsely":{"version":"1.1.0","canonical_url":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","meta":{"@context":"https:\/\/schema.org","@type":"NewsArticle","headline":"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary","url":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary","mainEntityOfPage":{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA&w=150&h=150&crop=1","image":{"@type":"ImageObject","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA"},"articleSection":"Uncategorized","author":[{"@type":"Person","name":"melindapham"}],"creator":["melindapham"],"publisher":{"@type":"Organization","name":"Cloudinary Blog","logo":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA"},"keywords":["agentic","next.js"],"dateCreated":"2026-11-24T15:00:00Z","datePublished":"2026-11-24T15:00:00Z","dateModified":"2026-11-24T15:00:00Z"},"rendered":"<meta name=\"parsely-title\" content=\"How to Protect Multimodal AI Agents From Image Prompt Injection With Next.js and Cloudinary\" \/>\n<meta name=\"parsely-link\" content=\"https:\/\/cloudinary.com\/blog\/protect-ai-agents-image-prompt-injection-nextjs-cloudinary\" \/>\n<meta name=\"parsely-type\" content=\"post\" \/>\n<meta name=\"parsely-image-url\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA&w=150&amp;h=150&amp;crop=1\" \/>\n<meta name=\"parsely-pub-date\" content=\"2026-11-24T15:00:00Z\" \/>\n<meta name=\"parsely-section\" content=\"Uncategorized\" \/>\n<meta name=\"parsely-tags\" content=\"agentic,next.js\" \/>\n<meta name=\"parsely-author\" content=\"melindapham\" \/>","tracker_url":"https:\/\/cdn.parsely.com\/keys\/cloudinary.com\/p.js"},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1793988466\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary\/Blog_How_to_Protect_Multimodal_AI_Agents_From_Image_Prompt_Injection_With_Next.js_and_Cloudinary.png?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/40666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=40666"}],"version-history":[{"count":1,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/40666\/revisions"}],"predecessor-version":[{"id":40668,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/40666\/revisions\/40668"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/40667"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=40666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=40666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=40666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}