Skip to content
Giminger ConsultingDE

Contain untrusted text in a workflow

Key takeaway

Email, documents and webpages can steer a model unexpectedly. The application enforces boundaries independently of its text response.

Lessons in this path
  1. Assign permissions by step
  2. Contain untrusted text in a workflow
  3. Route an AI issue to the right owner

How it works

Identify external inputs and where actions could happen. Enforce allowed fields, targets, roles and access on the server. Keep business approval outside the model.

Worked example

Text in a ticket is captured as a request. It cannot change a workflow recipient or select another file for sending.

What is prompt injection and why does it matter for mid-sized companies?

Prompt injection is text in an input that makes a language model deviate from its intended task. It can be overt, for example “ignore all previous instructions”, or hidden, for example in white text in a PDF, in file metadata or on a web page an agent reads. The OWASP list of top risks for large language model applications ranks prompt injection first.

This becomes relevant as soon as AI processes external content: customer emails, supplier offers, job applications, web pages. Based on current knowledge, the problem cannot be fully solved inside the model. The effective answer lies in architecture: the application limits what manipulated text can achieve.

How do you contain external content step by step?

The following steps work regardless of model and provider. They can be retrofitted to existing automations.

  1. List every input that comes from outside or can be influenced from outside, including attachments and linked pages.
  2. For each input, define what the model may produce from it: only a summary, only defined fields or a draft.
  3. Validate model outputs against a fixed structure and discard anything that does not fit.
  4. Never take recipients, target folders, amounts or roles from model text; take them from master data and configuration.
  5. Allow actions with external effect only through approval outside the model.
  6. Test the workflow with prepared test documents before it processes real data.

Which protective layer works against what?

No single measure is enough. The table shows how the layers complement each other and where their limits lie.

Protective layers against manipulated inputs
LayerProtects againstLimitation
Instructions in the promptAccidental deviationNot a security boundary, can be bypassed
Structured output with validationUnexpected fields and formatsContent of allowed fields may still be wrong
Fixed targets from configurationRedirected recipients and storage locationsRequires clean master data
Least privilegeDamage from wrong actionsLimits impact, does not prevent errors
Human approvalWrong actions with external effectOnly works if reviewers have time and evidence
LoggingUndetected incidentsOnly works after the fact

Rule of thumb: everything a model produces from external text is a suggestion. Everything that triggers an action is decided by the application.

Going deeper: separating reading and acting contexts

A proven architecture pattern separates two roles: one model reads the external text and extracts only defined fields. A second part of the application, which never sees the original text, decides what happens based on those fields and fixed rules. A hidden instruction in the document can then at most distort a field's content, but cannot take over the workflow logic.

Plausibility checks on the fields help too, for example whether an extracted bank account matches the supplier's stored bank details, as does limiting the number of actions per run. For agents that research on the web, use a list of allowed domains and forbid turning web content directly into actions. Test regularly with prepared documents, known as red teaming, and add these cases to your reference set.

Example: a manipulated invoice in the inbox

A fictional trade business has AI read incoming invoices and pass them to accounting as booking suggestions. During testing, the IT provider includes an invoice with invisible text saying payment must now go to a new bank account and accounting should not be informed.

The model does put the new account number into the field. The application, however, compares it with supplier master data, detects the mismatch and flags the suggestion red with the note “bank details differ, verify by phone with the known contact”. The workflow cannot trigger a payment anyway, because it is only allowed to write suggestions.

Common mistakes

  • Relying on a newer model to reliably detect prompt injection.
  • Taking recipient addresses or storage paths from the model's answer.
  • Treating attachments and linked content as trusted because the email comes from a known sender.
  • Testing only with clean data and never with prepared documents.

Frequently asked questions

Are there tools that detect prompt injection automatically?

Various vendors offer filters and classifiers that detect known patterns. They are a useful additional layer but no guarantee. Architectural limits remain the primary measure.

Does this also apply to copilot features in office software?

In principle yes, once an assistant reads external documents or emails. How far the vendor limits this depends on the product and configuration. Above all, check which actions the assistant may perform without confirmation.

Try it yourself

Use neutral test data to verify behavior with missing fields and unapproved targets.

Check your result

The application denies unapproved actions independent of how convincing an output sounds.

Official documentation and sources

Practical guides and references