AI Security

Zero‑Trust Document Protection for AI Summarization with Azure OpenAI and Azure Blob Storage

TL;DR: Encrypt documents on the client, store the ciphertext in Azure Blob Storage, send only the encrypted blob reference to Azure OpenAI’s ChatCompletion endpoint with a custom function that decrypts inside a secure sandbox, and delete the plaintext after the summary is returned. Use short‑lived keys, rotate them weekly, and audit every step with structured logs.

What is the threat model for AI‑driven document summarization?

When a document contains personally identifiable information (PII) or proprietary data, sending it in clear text to a hosted LLM creates two attack surfaces:

A zero‑trust approach assumes the AI service is a black box that should never see raw data. The goal is to keep the plaintext under the control of the small company while still leveraging the model’s reasoning capabilities.

How to encrypt documents before sending them to Azure OpenAI

Use a symmetric algorithm (AES‑256‑GCM) with a per‑document key that is generated on the client. The key is then wrapped with a master key stored in Azure Key Vault. Below is a minimal Node.js example:

const crypto = require('crypto');
function encrypt(plain) {
  const key = crypto.randomBytes(32); // 256‑bit
  const iv = crypto.randomBytes(12);
  const cipher = crypto.createCipheriv('aes-256-gcm', key, iv);
  const ciphertext = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
  const tag = cipher.getAuthTag();
  return {ciphertext, iv, tag, key};
}

Upload {ciphertext, iv, tag} to Azure Blob Storage as a single object. Store the wrapping metadata (key identifier, IV, tag) in a separate, access‑controlled metadata file.

Secure key management for client‑side encryption

Azure Key Vault provides hardware‑protected keys and automatic rotation. Follow these practices:

  1. Generate a master key (RSA‑2048) in Key Vault.
  2. Wrap each per‑document AES key with the master key using RSA‑OAEP.
  3. Store the wrapped key alongside the blob metadata; never persist the raw AES key.
  4. Rotate the master key monthly and re‑wrap active document keys.

Only the Azure Function that invokes the OpenAI model needs permission to unwrap keys, limiting the blast radius.

Integrating Azure Blob Storage with Azure OpenAI

Azure OpenAI does not accept raw binary payloads, but you can use a function‑calling pattern. Create a small Azure Function that:

Because the function runs in a dedicated App Service plan with no outbound internet except to OpenAI, the plaintext never leaves the controlled environment.

Verifying the summarization result without exposing raw text

After the function returns the summary, store it in a separate, low‑sensitivity database (e.g., Azure Cosmos DB). Keep the original encrypted blob for audit purposes for a configurable retention period (e.g., 30 days), then purge it with a lifecycle policy. To ensure the summary is accurate, you can run a second, lightweight validation step that checks for required keywords without re‑exposing the full document.

Operational checklist for small teams

Before launching the workflow, run through this list:

  1. Key policy: Verify Key Vault access policies grant unwrap rights only to the Azure Function identity.
  2. Encryption test: Encrypt a sample document, decrypt it in the function, and compare hashes.
  3. Logging: Emit structured logs (timestamp, blob ID, function name, outcome) to Azure Monitor. Do not log raw ciphertext or keys.
  4. Retention: Set Blob lifecycle rules to delete encrypted blobs after the agreed retention window.
  5. Incident response: Document steps to rotate keys and revoke function access if a breach is suspected.

Following this checklist gives founders and operators confidence that sensitive data never leaves their control, even while leveraging powerful LLM summarization.

If you need help designing or reviewing the zero‑trust flow, AISecAll can run a short security review and suggest hardening measures tailored to your stack.

Need a practical AI security review?

AISecAll reviews prompts, tool permissions, document flows, and agent behavior so small teams can use AI without guessing where the risk sits.

Book a call Discuss a project