The HisnLabs Security Blog

By HisnLabs Security & Research Team · Published · 8 min read

What are AI guardrails? A plain guide for businesses

What are AI guardrails? A plain guide for businesses

A company that connects an assistant, a chatbot or an agent to a large language model gets something remarkable: a helper that answers customers at any hour, in their own words. The same openness that makes it useful also means every message is a way in. An AI guardrail is the part of the system that lets you keep that openness with confidence. It reads what goes into the model and what comes out, and applies your rules on the way, so the assistant can be generous with the people it is meant to serve and firm with the few who try to misuse it.

This guide explains what a guardrail does, how good ones are built, and how to tell a strong one from a weak one. It is written for the people who decide: product owners, security leads and the managers who sign off on an AI launch.

What a guardrail is, in one paragraph

A guardrail is a checkpoint that sits between your users (or your agents) and the model. Every message passes through it. It looks for a small number of things that matter: someone trying to override the assistant’s instructions, personal data that should not be sent to a model provider, requests your policy does not allow, and answers that should not reach the user. For each message it reaches a decision, and the decision is not always “block”. A well-designed guardrail can let the message through, hide a sensitive value, add a warning, ask the user to rephrase, or stop it. Most messages in a normal day should simply pass, quickly and invisibly.

The risks it is there for

The OWASP GenAI Security Project keeps the best-known list of risks for applications built on language models. Three of its entries describe most of what a business guardrail is for.

  • Prompt injection. OWASP defines it in one sentence: “A Prompt Injection Vulnerability occurs when user prompts alter the LLM's behavior or output in unintended ways” [1].
  • Sensitive information disclosure: personal data, financial details and confidential business information appearing where they should not, in either direction [2].
  • Excessive agency: an assistant that can call tools or other systems doing more than it should. OWASP names three root causes, “Excessive functionality”, “Excessive permissions” and “Excessive autonomy” [3].

OWASP’s own list of mitigations for prompt injection includes “Implement input and output filtering”, “Segregate and identify external content” and “Conduct adversarial testing and attack simulations” [1]. A guardrail is the practical form of the first two, and the third is how you know it works.

Input checks and output checks

A guardrail works in both directions. On the way in, it looks at what the user typed, the documents attached and anything retrieved from your knowledge base. This is where it spots attempts to steer the model, and where it can swap an ID number or an IBAN for a placeholder before the model provider ever sees it. On the way out, it looks at the model’s answer before your user does: is the answer leaking something from the system prompt, repeating personal data it should not, or breaking the format your application expects?

Output checks matter more as answers are streamed word by word. A guardrail that only reads complete answers either makes users wait for the whole reply or checks it too late. A good design reads the stream as it arrives and can stop an answer partway through.

Layers: fast checks first, deep review only when needed

Checking every message with a large model would be slow and costly. Checking every message with a list of banned words would be fast and nearly useless. Strong guardrails combine both ideas in layers, where each message is handled by the lightest step that can decide it.

  1. Clean-up. Before anything else, undo the tricks that hide text from filters: invisible characters, look-alike letters, encoded text and, in Arabic, diacritics and stretched letters. Every later check then reads the text as a person would.
  2. Fast rules. Pattern checks for things with a known shape, such as national ID numbers, IBANs, card numbers and leaked keys, plus your own allow and block lists. They take almost no time and settle many cases.
  3. A small classifier. A compact model trained for one question: is this text trying to manipulate the AI? It reads meaning rather than keywords, so it can recognise an attack written in a new way.
  4. A deeper review. Only for the few messages still unclear after the first three steps: a closer look at the message in the context of the conversation, before your policy decides.

The point of the layers is not only speed. It is that the expensive, careful step is spent where it is needed, and ordinary messages are not held up by a check they never needed.

Agents and documents: when the instruction is not typed by the user

The hardest case is the one most people do not expect. OWASP separates direct injection, typed by the person in the chat, from indirect injection, which happens “when an LLM accepts input from external sources, such as websites or files” [1]. A 2023 paper by Greshake and colleagues showed the indirect form against real products and explained the root cause: LLM-integrated applications “blur the line between data and instructions” [4].

For a business, this means the guardrail must also read what the assistant reads: the PDF a customer uploads, the web page an agent visits, the result a tool returns. A sentence hidden in white text in a document is still a sentence to the model. A guardrail that only inspects the chat box sees half the picture. One that inspects documents and tool results, and limits which tools an agent may call, covers the way most real agent deployments are built.

What good looks like: it catches manipulation and lets people through

A guardrail has two jobs, and it is judged on both. The first is obvious: notice attempts to manipulate the model. The second is just as important: let ordinary people through. Researchers have measured the cost of getting the second one wrong. The XSTest paper describes models that refuse “even clearly safe prompts” when those prompts “use similar language to unsafe prompts or mention sensitive topics”, and built a test of 250 safe prompts and 200 unsafe contrasts to measure it [5]. Meta’s CyberSecEval 2 team put the trade-off plainly: “conditioning an LLM to reject unsafe prompts can cause the LLM to falsely reject answering benign prompts, which lowers utility”, and proposed measuring it as a false refusal rate [6].

This is why the best guardrails are designed around the people they serve. A customer asking how to report a stolen card is not an attacker because the message contains the word “stolen”. A student pasting a fully vowelled Arabic poem is not hiding anything. When a guardrail treats them kindly, users trust the assistant, and the business gets the full value of the AI it paid for. We wrote a separate article on exactly this: guardrails that don’t annoy your users.

How to choose a guardrail: six questions to ask a vendor

You do not need to be a machine-learning specialist to compare guardrails. Ask these questions, and expect clear answers.

  1. Was it tested on public test sets that I can rerun myself, and on data it was never trained on? Ask for the names of the sets and a way to reproduce the numbers.
  2. What are the results per language? A single blended figure can hide a weak spot. If your users write in Arabic, its dialects or Arabizi, ask for those groups separately.
  3. How often does it wrongly block normal messages? Every “caught” figure needs its “wrongly blocked” figure next to it, measured on safe texts.
  4. How many messages is each result based on, and how wide is the uncertainty? A result on fifty messages and a result on five thousand are not the same claim.
  5. How much time does it add per message, measured on stated hardware and for typical message lengths?
  6. Where is my data processed and stored, who can read the logs, and can it run inside my own network if I need it to?

A vendor who answers all six with numbers, links and a method is giving you something you can check. Our tutorial on how to test an AI guardrail with public test sets walks through the method step by step, so you can run the same checks yourself.

Where Guardrino fits

Guardrino is the AI firewall HisnLabs is building for businesses, and this guide describes the way it is designed. It is planned as a gateway between your staff, your agents and any LLM, with the layered checks above, personal data masked before the model sees it, a policy with five outcomes (allow, mask, warn, ask to rephrase, block), answers checked as they stream, and documents and tool results inspected for agents. It is built for Arabic and English from the start, including Gulf and Egyptian dialects and Arabizi, and planned to run hosted in the UAE or installed offline in your own network.

Guardrino is in development. There is no public version, no price and no release date yet, and we publish no results until a release has been measured the way this guide recommends. Businesses that want to shape it can join the pilot programme on the Guardrino page. If you want the story behind it, read why we are building Guardrino for the Middle East.

How Guardrino and HisnLabs fit in

Guardrino is the AI firewall for businesses that HisnLabs is building the way this guide recommends. It is in development and not released; the short simulation below shows what it is designed to do with the kinds of messages described above.

Sources