Your Firewall Can't Read Prompts: A Developer's Guide to Securing LLM Apps in the UK

Your Firewall Can't Read Prompts: A Developer's Guide to Securing LLM Apps in the UK

●6 ●83 ●134
calendar_today • schedule7 min read

The attack surface moved into natural language. Here is how to build controls that actually see it, and how they map to NCSC, UK GDPR and EU AI Act expectations.

Picture a support bot you shipped last quarter. It runs behind a WAF, sits in a private subnet, authenticates every request and passes every pen test you throw at it. Then a customer pastes a paragraph into the chat that politely asks the model to ignore its instructions and summarise the last five tickets it saw. The model complies. Nothing in your network stack noticed, because nothing in your network stack reads English.

That is the core problem with LLM security. The payload is meaning, not bytes. Traditional tools inspect packets, signatures and endpoints. An LLM attack looks like a perfectly valid HTTPS request carrying a perfectly valid JSON body. The malicious part only exists at the semantic level.

For teams building in the UK there is a second layer on top: regulators now expect you to prove you have this under control. This post walks through the threats, the architecture that handles them, and how the compliance side translates into things an engineer can actually build. It is a condensed, developer-focused take on NeuralTrust's enterprise AI security guide for UK CISOs.

Five ways LLM apps break in production

1. Direct prompt injection. A user crafts input that overrides your system prompt. The OWASP Top 10 for LLM Applications ranks prompt injection as LLM01, the number one risk on the list. If you only defend against one thing, start here.

2. Indirect injection through context. Your RAG pipeline pulls a web page, a PDF or an email into the context window. Somewhere inside it is an instruction aimed at the model, not the human. The user never typed anything malicious. Your retriever fetched it for them.

3. Data exfiltration through outputs. The model has access to something sensitive, whether through context, tools or fine-tuning data, and returns it in a completion. Customer records, API keys and internal documents all leave the same way: as ordinary text in a response.

4. Tool-call abuse in agents. Once a model can call functions, a successful injection is no longer just a bad answer. It is an action. Sending an email, querying a database or opening a pull request all become reachable by whoever controls the prompt. If you are building agents, the Agent Security hub is a useful reference for threats like memory poisoning and tool misuse that go beyond single-turn chat.

5. Intent drift. No single message looks hostile, but over a long session or multi-step task the behaviour slides further from what the user or operator intended. Per-request filters miss this by design, which is why session-level visibility matters.

Notice the pattern. Every one of these arrives as legitimate traffic and leaves as legitimate traffic. The only place to catch them is where you can see both the prompt and the completion in full.

Put a gateway in the path

The most practical answer is architectural. Route every model call in the organisation through a single AI gateway instead of letting each app talk to OpenAI, Anthropic or a self-hosted model directly.

This matters for a simple reason. If ten teams each wrap their own SDK calls with their own filtering logic, you get ten different security postures, ten logging formats and no single place to change policy. A gateway gives you one choke point where you can:

  • Inspect prompts and completions in real time and block or rewrite them
  • Detect and redact PII before it reaches a third-party provider
  • Enforce per-team access controls, rate limits and token budgets
  • Log every interaction in one consistent format

Conceptually the request path looks like this:

# Simplified illustration of what a gateway does per request.
# Not a production implementation.

def handle_request(user, prompt, context_docs):
    policy = load_policy(user.team)

    # 1. Inbound inspection
    if detect_injection(prompt, context_docs):
        audit_log(user, prompt, verdict="blocked_injection")
        return refusal("Request blocked by policy")

    prompt = redact_pii(prompt, mode=policy.pii_mode)

    # 2. Access control and budget
    if not policy.allows_model(user.requested_model):
        return refusal("Model not permitted for this team")
    if usage_this_month(user.team) > policy.token_budget:
        return refusal("Token budget exceeded")

    # 3. Route to the provider allowed for this data class
    provider = policy.route_for(data_class=classify(prompt))
    completion = provider.complete(prompt, context_docs)

    # 4. Outbound inspection
    if leaks_sensitive_data(completion):
        completion = redact_pii(completion, mode="strict")

    audit_log(user, prompt, completion, provider=provider.name)
    return completion

The key detail is step 3. Routing based on data classification is what lets you keep certain categories of personal data on a UK or self-hosted model while sending low-risk traffic wherever it is cheapest. That one decision does a lot of your data protection work for you.

You do not need to build this yourself. NeuralTrust's TrustGate AI gateway does this as a drop-in layer, with inline prompt inspection, PII redaction and jailbreak detection, and it supports SaaS, hybrid and on-premises Kubernetes deployments. That last option matters if your data cannot leave your own infrastructure.

Log like an auditor is going to read it

Observability for LLMs is not the same as APM. Latency and error rates still matter, but you also need to answer questions like "what did the model say to this customer on Tuesday, and why?"

At minimum, capture:

  • The full prompt, retrieved context and completion (redacted where required)
  • Which model and provider handled it
  • User or service identity and team
  • Policy verdicts: what was flagged, blocked or rewritten
  • Token counts and cost
  • For agents, every tool call with its arguments and result

Doing this at the gateway rather than inside each app gives you a single consistent schema. Pipe it into your existing SIEM so that AI incidents show up next to everything else your security team already watches. NeuralTrust has a deeper walkthrough on LLM observability at the gateway layer if you want to go further on metrics like cost attribution and anomaly detection.

The UK compliance layer, translated for engineers

Regulation usually reaches developers as a vague requirement from someone else. Here is what the main frameworks actually ask for, in build terms.

NCSC guidance. The NCSC's Guidelines for secure AI system development, co-published with CISA and partner agencies, organise security across four lifecycle stages: secure design, secure development, secure deployment, and secure operation and maintenance. In practice that means threat modelling your prompts and tools at design time, protecting your model supply chain, hardening the serving path, and monitoring behaviour once live. The UK government's separate AI Cyber Security Code of Practice extends this model to include end of life. The NCSC has also been publishing guidance specific to agentic AI, which NeuralTrust breaks down in its post on NCSC AI guidelines for UK enterprises.

UK GDPR. The principles you already know apply to AI pipelines too. In code terms:

  • Data minimisation means redact what the model does not need before the call, not after.
  • Purpose limitation means data collected for support should not quietly end up in a fine-tuning set.
  • International transfers means you need to know which provider and region handles each request. This is where routing rules earn their keep.
  • Accountability means you can show what happened. Your audit log is your evidence.

The ICO's guidance on AI and data protection is clear that these obligations extend into how AI systems actually operate, not just how they were procured.

EU AI Act. Brexit does not take you out of scope. The Act can apply to UK companies that place AI systems on the EU market or whose system outputs are used in the EU. For systems classed as high risk, the obligations include a risk management system, technical documentation, automatic logging of events and human oversight. Notice how much of that overlaps with what a gateway and a proper audit trail already give you.

A sensible build order

If you are starting from zero, this sequence keeps each step useful on its own:

  1. Inventory. Find every place your organisation calls a model, including the side projects.
  2. Centralise. Put a gateway in front of all of them, even with policies in log-only mode at first.
  3. Classify and route. Define data classes and decide which providers and regions each one may use.
  4. Turn on PII handling. Redaction inbound, detection outbound.
  5. Enable runtime defence. Injection and jailbreak detection in blocking mode once you trust the false positive rate.
  6. Set budgets and access controls. Per team, per model.
  7. Wire up the SIEM. AI events belong in the same pipeline as everything else.
  8. Red team it. Use the OWASP LLM Top 10 as your test plan and repeat it regularly.
  9. Write the incident playbook. Decide now who pulls the plug on an agent and how.

Wrapping up

The shift to take away is that the security boundary for LLM apps is the conversation itself. Network controls still matter, but they are blind to the attacks that matter most here. Put a single inspection and logging layer in front of every model, route by data sensitivity, and keep records good enough to show a regulator. Do that and most of the UK compliance picture stops being a separate project and becomes a side effect of sound engineering.

Want more #ai & #cybersecurity deep dives?

Join 6,054+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

What Security Teams Want From AI Agents Before They Let Them Act Alone

Tom Smithverified - Nov 18

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23

Cisco's Amy Chang: A Model's "Passport" Doesn't Tell You Where It Actually Came From

Tom Smithverified - Aug 27

Defending Against AI Worms: Securing Multi-Agent Systems from Self-Replicating Prompts

alessandro_pignati - Apr 2

The Sovereign Vault — A Comprehensive Guide to Protocol-Driven AI

Ken W. Algerverified - Jun 4
chevron_left
2.1k Points • 223 Badges
75Posts
0Comments
3Connections
Alessandro Pignati is a Security Researcher at NeuralTrust, specializing in Agentic Security and LLM... Show more

Related Jobs

View all jobs →

Commenters (This Week)

2 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!