Cybersecurity by design in AI systems
Cross-cutting case · Cybersecurity

Cybersecurity by Design in AI Systems

The model can interpret an intention. It should not decide on its own whether it is authorised to carry it out.

A cross-cutting case, built from several projects

This is not the account of a single installation. It is a cross-cutting technical case gathering patterns BigLearn applies in solutions for insurance, healthcare, public administration, hospitality and retail: knowledge-based assistants, complaint handling, channels carrying sensitive data, order flows and agents connected to internal processes.

Clients are anonymised and we publish no incident metrics we cannot demonstrate. The verifiable result is the architecture: where language ends, where authorisation begins, which data may circulate, and at which point a person has to decide.

The dangerous mistake: confusing intelligence with authority

A language model is useful because it accepts ambiguous input: an email, a complaint, a commercial question, a document. That same flexibility creates the attack surface. Incoming content can carry hostile instructions; a retrieved document can be out of date or poisoned; and a plausible answer can still be factually wrong.

The architectural decision was to treat input, retrieved context and model output as untrusted data. The model interprets and proposes. Deterministic components verify identity, authorisation, schema, limits and process state before anything happens.

Threat model before the first prompt

For each flow we began by identifying assets, trust boundaries and possible effects. The assets were not only databases: they included system instructions, internal documents, user identity, integration credentials, conversation history, and the very ability to send, alter or classify information.

The adversarial scenario included direct and indirect prompt injection, context leakage, cross-tenant access, tool abuse, manipulated parameters, unsourced answers, request replay, excess data in logs and privilege escalation. That changes the question from «does the model answer well?» to «what happens when it answers badly?»

Five boundaries instead of one giant prompt

1 · InputIdentity and origin

Channel, session, authentication, usage limits and initial validation.

2 · ContextAuthorised retrieval

Permitted sources, filtered by the user's permissions before they reach the model.

3 · ModelInterpretation

Produces an answer or a structured intention; receives no credentials and no direct authority.

4 · PolicyDeterministic validation

Schema, authorisation, business rules, risk and whether confirmation is required.

5 · EffectMinimal tool

A narrow function executes, records the result, or routes it to a person.

The technical controls applied

Instructions separated from content

Permanent system rules are never mixed with emails, documents or retrieved text. External content is delimited and classified as data to analyse, never as new instructions to obey.

Structured output and schema validation

When the AI identifies a category, an address, a product or an action, it returns structured fields. Types, formats, permitted values and required fields are validated outside the model; free text is not converted directly into an operation.

Allowlisted tools

The agent only sees the operations the case requires. Reading does not imply writing; drafting does not imply sending. Each tool has narrow parameters and a technical identity with least privilege.

RAG with access control

Semantic search does not bypass permissions. The document set is filtered before retrieval, sources travel with the answer, and absence of evidence produces abstention or routing — not invention.

Confirmation proportional to impact

Answering an opening-hours question is not the same as changing an order, routing a report or producing a decision that affects a person. Actions are classified by risk, and the higher-impact ones wait for human confirmation.

Observability without a parallel archive

Versions, sources, tool calls, authorisations, errors and step correlation are recorded. Full content and personal data are not logged by default: purpose, access and retention have to be explicit.

untrusted language → structured intention → policy validation → authorisation → minimal execution → logging → response

Prompt injection: the filter is not the answer

An instruction like «ignore the previous rules» is the simplest example. The real problem is indirect: the instruction can sit inside a PDF, on a page the agent consults, or in an email that looks like a legitimate complaint. Trying to recognise every dangerous phrase is a useful defence, but an incomplete one.

The effective defence reduces the possible impact: the document does not redefine policy; the model holds no secrets; tools are limited; arguments are validated; a sensitive operation requires independent authorisation. So even when an attempt gets through the language layer, it meets a technical boundary that does not speak prompt.

Secure RAG: finding a document is not permission to reveal it

In knowledge-based solutions, retrieval is conditioned by the identity and context of the request. Filtering happens before excerpts are sent to the model. That prevents the model receiving information the user had no access to and then trying to «forget» it in the answer — a protection that would already be too late.

Company knowledge stays separate from the model. It can be updated, versioned and withdrawn without retraining anything. When there is not enough source material, the correct answer may be not to answer, to ask for more context, or to hand the case to a person.

The pattern applied across sectors

Insurance: the assistant consults approved knowledge, gathers data progressively and hands parameters to a deterministic process. The calculation belongs to the business engine; the model invents no premiums and takes no underwriting decision.

Healthcare and sensitive channels: AI can organise an account and extract useful information, but it does not decide about people. Access, retention and routing are defined by the process, and the final decision stays human.

Public administration: emails and complaints are untrusted input. The solution separates the original text from the extracted fields, classifies and geolocates, keeps traceability, and proposes the responsible department without turning the model's suggestion into an administrative decision.

Hospitality and retail: opening hours and public information can be answered with low friction; orders, status changes and guest data pass through validation, access control and logging. Conversational freedom does not become operational freedom.

What became reusable

The main result was a consistent way of building: an inventory of assets and data, classification of actions by impact, explicit trust boundaries, authorised retrieval, small tools, validated output, human intervention, and enough operational evidence to investigate an error. These patterns reduce the security work in new projects without assuming two sectors carry the same risk.

Security by design does not mean promising zero risk. It means knowing what the system is able to do, reducing the blast radius when it fails, and being able to reconstruct what happened. In an AI agent, that architectural honesty is worth more than a prompt that promises to obey.

Frequently asked questions

Why should an AI agent not be treated like a traditional application?

Because it interprets untrusted language and produces probabilistic results. An instruction can arrive mixed into documents, emails or external pages. So the model is given no direct authority: authentication, authorisation, validation and execution stay in deterministic components outside the model.

How do you protect an agent against prompt injection?

Separate system instructions, user data and retrieved content; mark external content as untrusted; limit the tool set; validate parameters before execution; and require human confirmation for higher-impact actions. A text filter on its own is not a security boundary.

Does a RAG system prevent hallucination?

No. RAG improves grounding but it does not turn the model into a deterministic database. You still need to control the sources, apply permissions before retrieval, show provenance, and stop an unsupported answer from automatically triggering a business action.

Can the AI model access company systems directly?

It should not. The model proposes a structured intention; an orchestration layer validates the schema, the identity, the authorisation and the limits of each operation. Only then does a function with minimal privileges carry out the permitted action.

What does security by design mean for an AI agent?

Not promising zero risk. It means knowing what the system is able to do, reducing the blast radius when it fails, and being able to reconstruct what happened afterwards. In an AI agent that architectural honesty is worth more than a prompt that promises to obey.

Does finding a document mean the user is allowed to see it?

No, and conflating the two is a common failure. Semantic search does not bypass permissions: the document set is filtered by identity and context before the excerpts reach the model. Filtering afterwards would already be too late.

Who developed these patterns

BigLearn is a Portuguese artificial intelligence consultancy, founded in 2017 and based in Lisbon, building AI agents and automation for regulated and non-regulated sectors.

These patterns come out of our AI agents and business automation work, and are applied from the first design conversation rather than added afterwards. Every project starts with a proof of concept with a written success criterion.

The other case studies are published under the same rule: client anonymised, verifiable figures, and the nature of the document stated up front.

Can your AI agent do more than it should?

Tell us what it is connected to and what it is allowed to do on its own. We review the boundaries before proposing anything.

Present your case