ZTGIT

AI security: prompt injection, guardrails and the LLM gateway

ZTGIT team

A language model in production is not “just another API.” It reads content you do not control, answers in free text and costs money per call. That opens three risks that did not exist before.

The risks

Prompt injection. The central risk of applied AI. The model does not firmly distinguish between “the system instructions” and “the content it is reading.” If that content — an email, a page, a document — contains hostile instructions (“ignore what you were told before and do this”), the model may obey them. The practical rule: every tool output, every document and every piece of data is data, never instructions. An agent that treats what it reads as a command is a hijackable agent.

Data leakage. Prompts often carry sensitive data — names, documents, secrets — to an external service that may log them. Without a filter, you export PII without noticing.

Cost and abuse. Each call costs. Without a limit per user and per application, a loop bug or deliberate abuse becomes a large bill and a denial-of-service vector.

The three layers of defense

No layer solves it alone; together, they contain the risk.

1. The LLM gateway

An LLM gateway is the single point through which all model calls pass. It centralizes the keys (which are not scattered across applications), applies usage limits per identity, lets you switch models without touching code, and gives a place to measure and log. It is the base the other layers rest on. In ZTGIT, ZTGIT-LLMGateway plays this role.

2. The guardrails

Guardrails are the input and output filters. On input: detect injection attempts, block forbidden content, mask PII before it reaches the model. On output: stop unsafe answers, check format, prevent the model from returning a secret. ZTGIT-LLMGuard handles guardrails and ZTGIT-LLMFilter handles masking of sensitive data.

3. The logging

Every call — who asked, what went in, what came out, how much it cost — must be logged, for audit and investigation. It is the AI-world equivalent of what the SIEM does for everything else. In ZTGIT, ZTGIT-LLMTracer keeps that trail.

Agents and tools

When the model gains tools — reading files, calling APIs, taking actions — the injection risk stops being theoretical: a hostile instruction hidden in a document can become a real action. That is why ZTGIT’s agent governance (the AIAB standard — Bring Open Source Software) starts from a non-negotiable principle: what the agent reads is data, not a command. The MCP standard, which connects models to tools, must be mediated with the same care — keys in the vault, access by identity, logging of everything.

The summary

AI security is not a feature you switch on; it is a layered architecture: a gateway to centralize and limit, guardrails to filter and mask, logging to audit. And, at the center of it all, the discipline of never confusing the content the model reads with the instructions it should follow.

From the blog