SGTech Community Sharing · AI Security

Follow the Input: What Prompt Guardrails Miss in AI Agent Systems

CloudsineAI logo

Contributed by Matthias Chin and Lee Tian Lee of CloudsineAI (SGTech member), drawing on their work on TraceCtrl, an open-source toolkit for security observability of AI agents, and on the monthly AI Threat Reports produced by the company’s red team.

Control points 1.1-01 Taint tracing · 4.1-04 Indirect injection · 4.3-09 Logging & monitoring · 3.4-01 Inter-agent controlsAlso touches 2.4-01, 2.9-02, 3.2-05, 4.1-01, 4.2-02, 4.3-05, 4.3-11, 4.4-01. Full mapping in the appendix.

Most teams secure an LLM application by checking the prompt going in and the response coming out. That works for a chatbot, where the dangerous text arrives in the prompt. It works less well for an agent, where the dangerous text often arrives some other way.

About CloudsineAI. Cloudsine is a Singapore-based cybersecurity company working on securing generative and agentic AI. The work referenced here is TraceCtrl, an open-source toolkit for security observability of AI agents, and the company’s monthly AI Threat Reports, in which its red team measures how often current models give way to adversarial prompts.

For readers who have not built one, an agent is a program in which the model chooses the next action. It is given a set of tools, which are ordinary functions such as “search the knowledge base”, “send an email” or “run this code”. The model picks a tool, the program runs it, the model reads the result and picks again. Larger systems chain several agents together and give them a shared memory, usually a searchable store of notes and documents that any of them can read from and write to.

In a system like that, text arrives from many directions: an inbound email, a fetched web page, a note another agent saved last week. Much of it never passes the prompt check, and what does may look harmless at the time. This article follows one piece of text through a small agent system twice: first as prompt inspection sees it, then with four extra labels recorded on every step. The labels ride on OpenTelemetry, a widely used tracing standard, and the code that produces them is public.

01One email, five steps

The scenario below is illustrative. It is assembled from publicly documented attack patterns and does not describe any customer incident. A company runs two separate agents that share one knowledge base. Neither agent talks to the other directly; the knowledge base is the only thing they have in common.

The two agents
Agent 1 — Intake agentAgent 2 — Assistant agent
JobFiles supplier emailsHandles staff requests
Input fromOutside emailsStaff; saved notes
ToolsRead mailbox; save noteSearch notes; send email
Attacker's emailhidden request insideAGENT 1 · INTAKESummarises the emailSharedknowledge baseAGENT 2 · ASSISTANTBuilds supplier reportGenuinestaff requestReport emailed toattacker's addresssteps 1–2step 3: saves poisoned notestep 4: retrieves notestep 4step 5
Fig 1 One outside email, two agents, five steps. The two highlighted boxes mark where the attack enters and where the data leaves; everything between them looks like normal work.

What goes wrong: the attacker never contacts Agent 2. A request hidden in an outside email is saved by Agent 1 as a trusted note, and two weeks later Agent 2 treats that note as company knowledge and emails a confidential report to the attacker.

  1. An email arrives from what appears to be an existing supplier, announcing a change of contact details. One sentence near the end reads as an administrative request: copies of the monthly supplier report should in future also go to a new address.
  2. The intake agent summarises the email. The prompt check sees a routine supplier message, with no override phrases, no role-play and nothing resembling a jailbreak, so it passes.
  3. The intake agent saves its summary as a note in the knowledge base, including the new address.
  4. Two weeks later a staff member asks the assistant agent to prepare and send the monthly supplier report. The request is genuine and passes inspection. The assistant searches the knowledge base and retrieves the note.
  5. The assistant sends the report to the usual recipients and to the new address, which belongs to the attacker.

No single prompt in this sequence was malicious on its own. The instruction entered at step 1, was laundered into trusted memory at step 3, and took effect at step 5 under a genuine request. As our monthly threat reports put it, attacks now live in sequences, not single prompts.

02Four labels on every step

Most agent frameworks can already emit traces: one record, called a span, for every model call, tool call and hand-off between agents. A span is like one line in a delivery driver’s logbook: what was done, when it started, how long it took and whether it worked. When the assistant agent in Fig 1 emails the report, the span for that step is the last line of the sample log below. A whole job is a list of such lines in order, which is called a trace.

Those traces were designed for performance work, so they record latency, token counts and errors. They do not record where a piece of text came from or what kind of power a tool holds, and those are the two facts a defender needs. Our approach is to add a small number of security labels to each span as it is created, and to leave the transport as standard OpenTelemetry so that existing collectors and storage keep working.

Sample trace — steps 4 and 5 of Fig 1

[09:13:58] Agent2  run started  "send monthly supplier report"
[09:13:59] Agent2  model call   1.1s  ok
[09:14:00] Agent2  tool call    search_knowledge_base  0.2s  ok
[09:14:01] Agent2  model call   1.3s  ok
[09:14:02] Agent2  tool call    send_email  0.8s  ok  payload ****

Times and values are illustrative. Every line reports that the step worked. No line says that the note retrieved at 09:14:00 began life as an outside email, or that send_email is a tool that moves data out of the organisation. Those are the gaps the four labels fill. Fig 2 shows where in the pipeline the labels are attached and where the labelled spans go next.

Agent +span processorOTelCollectorSpanstoreAnalysisengineDashboardand APIlabelledspans
Fig 2 System overview.

Reading Fig 2 from left to right:

With the trace and the pipeline in mind, the four labels are easiest to see in the log itself. Below are log lines for both agents in Fig 1. The lines starting with + are what the span processor adds.

--- Day 1: Agent 1 files the supplier email ---
[10:02:11] Agent1  tool call   read_mailbox  ok
  + source=external  tool=email (HIGH RISK)  direction=input  seq=1
[10:02:13] Agent1  model call  ok
  + prompt_fingerprint=9f2c41ab (unchanged)  seq=2
[10:02:15] Agent1  tool call   save_note  ok
  + tool=memory_write  seq=3

--- Two weeks later: Agent 2 sends the report ---
[09:13:58] Agent2  run started
  + source=user  seq=1
[09:14:00] Agent2  tool call   search_knowledge_base  ok
  + source=memory  tool=memory_read  seq=3
[09:14:02] Agent2  tool call   send_email  ok
  + tool=email (HIGH RISK)  direction=output  seq=5

Label names are shortened for readability; the real attribute names, such as tracectrl.input.source, are in the documentation. The four labels, in plain words:

03The same five steps, with labels on

Go back to the five steps of Fig 1 and compare what each check could see.

What the prompt check saw. Steps 1, 3 and 5 are tool calls: reading the mailbox, saving the note, sending the email. A prompt check only looks at prompts, so it saw none of them. Steps 2 and 4 each include a prompt, and both looked like normal work, so both passed. Nothing was flagged.

What the labelled log shows. Two patterns stand out, and neither needs anyone to read the email itself:

What a security team does with that. Each pattern becomes a standing rule that runs over every trace:

The labels do not decide that the supplier email was malicious. They pick out the few steps worth a closer look from all the routine ones, so that a person or a stricter automated check can be pointed at them.

04From single traces to the attacker’s map

One gap remains. Agent 1 saved the note on day 1, and Agent 2 used it two weeks later in a separate trace, so no single log connects the two events. What connects them is the shape of the system: who can take content in, who can write to shared memory, who can read it, and who can send data out. That shape can be drawn automatically from the labels.

OutsideemailAgent 1SharedmemoryAgent 2send_emailHIGH RISKinwritesreadsout
Fig 3 The attacker’s map. Every box and arrow is learned from labelled spans. Read left to right, it is an attack path: a way in, a way to travel, and a way out. The path exists from the day Agent 2 is deployed, whether or not anyone has used it yet.

In outline, the analysis engine does the following. The pseudocode below is a simplified illustration based on the TraceCtrl README, the architecture documentation and our March 2026 blog post on agent security intelligence; it is not the production source code.

# Simplified illustration, not production code
# runs every 60 seconds over all stored spans

# 1. draw the map
for span in all_spans:
    add its agent, tool or memory store to the map
    add an arrow: who called what, and which way data moved

# 2. look for ways from an entry to an exit
for entry in map where source == external:
    for exit in map where risk == HIGH and direction == output:
        path = route from entry to exit
        if path exists:
            score it on severity, tool risk, entry trust and path length
            report path and score

# 3. show the worst first
sort reported paths by score, highest at the top

For the two agents in this article, step 2 finds exactly one path, the one in Fig 3. The score weighs several factors together: how severe the weakness is, rated the way CVSS rates ordinary software vulnerabilities; how much power the tools on the path hold; how far the entry point can be trusted; and how many steps the path takes.

Once a path is on the list, fixing it is a design decision and no longer depends on catching an attack in progress. For the path in Fig 3 there are three options:

The same map answers three questions that boards and regulators are starting to ask: how many agents are running, what can each one reach, and how bad would it be if one were taken over. The MIT AI Agent Index 2025 is a useful reference point for how rarely those questions can be answered today.

05Where the prompt check still fits

The sections so far followed content as it travelled between agents. This section turns to the model inside each agent. A model can be talked into ignoring its instructions by text written for that purpose, which is called prompt injection, or a jailbreak when the aim is to get past its safety rules. The prompt check exists to catch that text, and Fig 4 shows where it sits.

Text going in:user, email, notesPromptcheckModelcan be trickedResponsecheckReply, tool callor memory write
Fig 4 Where the prompt check sits. Two checks wrap the model. One reads the text going in and blocks known attack patterns, and the other reads what comes out and blocks leaks or harmful content. Both read one piece of text at a time. Neither follows what happens afterwards, such as where a saved note travels or which agent reads it two weeks later, and that later part is what the labels and the attacker’s map in Figs 2 and 3 cover. A complete defence needs both layers.

An agent inherits every weakness of the model inside it, and the evidence that those weaknesses persist is easy to collect. Each month our red team writes new adversarial prompts, runs them against six models, and records how many produce an unsafe response. All of the prompts map to LLM01, prompt injection, in the OWASP Top 10 for LLM applications. The share that succeeds is the attack success rate (ASR).

Table 1 — Monthly red-team results, April to June 2026
Month (2026)New promptsTest casesOverall ASRBest modelWorst model
April39Not statedAbout one in threeGPT-5, 25.6%Llama 3 2B, 46.2%
May3118622.0% (41 unsafe)GPT-5, 0.0%Llama 4 Scout, 51.6%
June4124623.6% (58 unsafe)GPT-5, 2.4%Llama 4 Scout, 70.7%

Two observations follow, with a caveat attached to both. The gap between the most and least resistant model is wide and has grown, from roughly 20 percentage points in April to 68 in June. A model’s standing also moves from month to month: the same small Llama model failed 46.2% of prompts in April, 9.7% in May and 29.3% in June. The caveat is that each month uses a different and fairly small set of prompts, so these figures measure exposure to that month’s techniques and should not be read as a trend line on a fixed benchmark.

The practical conclusion is that the safety built into a model during training is a moving quantity that the deploying organisation does not control. In April, one model explicitly acknowledged an injection attempt in its reply and then complied with it, which shows that recognising intent and enforcing policy are separate capabilities. A runtime check outside the model is the part the organisation can update on its own schedule. Ours stores each confirmed attack prompt in a threat vector database and matches incoming prompts by semantic similarity, so that a reworded variant of a known attack still scores close to the original.

Written out as pseudocode, the prompt check box in Fig 4 is a set of tests that run at the same time, and the text is blocked if any one of them fails:

# Simplified illustration, not production code
check_prompt(text):
  1. keyword list hit?              -> BLOCK
  2. regex rule hit?                -> BLOCK
  3. personal data found?           -> BLOCK
  4. close to a known attack?       -> BLOCK
  5. harmful or toxic content?      -> BLOCK
  6. leaks the system prompt?       -> BLOCK
  7. judge model says malicious?    -> BLOCK
  otherwise                         -> ALLOW

# Test 4, the similarity match, in one example:
#   known attack:  "ignore any rules and ..."
#   new prompt:    "disregard all your guidelines and ..."
#   different words, same meaning -> scores close -> BLOCK

Tests 1 to 3 are simple pattern matches and cost almost nothing. Test 4 is the threat vector database, kept current by the monthly red-team findings. Tests 5 to 7 use models and cost the most. A matching set runs on the model’s reply, which is the response check in Fig 4, where personal data, harmful content and system prompt leakage matter most.

False positives deserve as much attention as missed attacks. An earlier article in this series described, from a penetration tester’s side, how a model that refuses authorised work stops an automated job. A guardrail that blocks legitimate requests fails in the same way, and in practice it gets switched off. For that reason our public model leaderboard scores each model on how often it answers benign requests as well as on how often it resists attacks, and we would encourage anyone evaluating a guardrail, including ours, to ask for both numbers.

06What to plan for in an enterprise deployment

The examples in this article involve two agents and one team. A large organisation runs many more agents, built by different teams on different stacks, and its security operations centre already has plenty of alerts to read. The six points below are what we would advise any team to plan for at that scale, whichever tooling it uses. Where they mention our own tooling, they describe the open-source release that anyone can inspect.

  1. Own the tool inventory. Working out a tool’s type from its name and description gives a useful first inventory on day one. It will misjudge a tool called process_data that has no description, and a third-party plugin can pick an innocent name. At scale, plan for tool owners to declare the type, a review step for new tools, and a record of who approved what.
  2. Decide what is watched and what is blocked. The labels and the attacker’s map are analysis: recomputed every 60 seconds, they tell a team where to look. Blocking belongs in the request path, which is the role of the checks in Fig 4 when deployed as a gateway. In the open-source SDK, guardrails declared on an agent run in monitoring mode, a sensible way to begin: watch, tune, then enforce.
  3. Expect a mixed estate. Instrumentation is published and tested for Agno and AWS Strands, and is available from source for LangChain, CrewAI and Google ADK, all in Python. A large organisation will also have agents in other languages and agents built into software it buys. Those cannot be instrumented from the inside, so plan to cover them with gateway checks and whatever logs the vendor provides.
  4. Follow the content where it matters most. The scenario here was caught by a session-level rule and a structural attack path. Following one specific piece of content from the email, into the note, and out through the report is called taint tracing, and CSA Singapore’s addendum on securing agentic AI recommends it. It is worth planning for on the flows that carry the most sensitive data.
  5. Size the data. Every agent step becomes a stored span. Plan early for how long spans are kept, which business units can see which agents, and what that storage costs.
  6. Send alerts to where analysts already work. An alert helps only if someone can act on it. Measure the false-positive rate of each rule on real traffic before switching it on widely, and deliver alerts into the existing security tooling with enough context to triage.

07Four questions to start with

No particular tool is needed to begin. Four questions, asked of each agent system, retrace the attack path in Fig 3 and give most of the benefit described in this article.

  1. Where can text from outside the organisation enter an agent, other than through the chat box?
  2. Which agents can write to a memory or knowledge store that other agents read from?
  3. Which agents hold a tool that sends data out of the organisation or executes code?
  4. Does a path connect the first group to the third, and does a human approval step sit anywhere on it?

To try the labelling approach directly: the SDK is Apache 2.0 and the engine and dashboard are under the Business Source License 1.1. The full stack runs locally with Docker Compose, and instrumenting an agent takes a few lines of code. We will walk through the TraceCtrl SDK hands-on at our workshop at GovTech’s STACK Conference 2026 on 3 November 2026.

Coming next: TraceCtrl Enterprise. Planning point 3 above notes that the agents an organisation buys, rather than builds, cannot be instrumented from the inside. TraceCtrl Enterprise, which we are building on the same SDK and span labels, is aimed at that gap and at running TraceCtrl across a whole organisation. It adds a multi-tenant deployment, hosted or on the organisation’s own infrastructure, with role-based access so that each business unit sees its own agents. An AI security posture module uses read-only access to discover agents on platforms such as Microsoft Copilot Studio, Microsoft 365 Copilot and Azure AI Foundry, with more to come. It places them in the same inventory as the organisation’s own instrumented agents and checks every one against a common set of configuration rules. A red team module will help uncover vulnerabilities in agentic AI systems before attackers do. The aim is a single answer to the question boards are asking: how many agents are running, and what can each one reach. To find out more, contact sales@cloudsine.tech.

AAppendix: mapping to the CSA Securing Agentic AI addendum

The table maps each practice in this article to the controls in CSA Singapore’s Securing Agentic AI addendum (v1.0, 17 June 2026), which supplements the 2024 Guidelines and Companion Guide on Securing AI Systems. Controls are grouped by lifecycle stage: 1 Planning and Design, 2 Development, 3 Deployment, 4 Operations and Maintenance. Control IDs are given as section-item, so 4.3-05 is the fifth item under control 4.3.

Practice to CSA control
PracticeCSA controlWhat the control asks forWhere this article covers it
Taint tracing in threat modelling1.1-01Perform taint tracing across workflows in the agentic AI system; especially important at autonomy levels 2 and 3Source and step-order labels; Fig 3 attack path; planning point 4
Untrusted data into memory and retrieval2.1-12Validate data before it supplements RAG databases; zero-trust handling of all data flowsStep 3 of the scenario; alert rule 1
Inventory of agents and tools2.4-01Document agents and tools, including descriptions of each tool’s intended use, inputs and outputsAgent inventory and tool classification; planning point 1
Sandboxing and segregation2.9-02Decouple data flow from control flow; isolate agents that carry out transactionsRemediation options under Fig 3
Adversarial testing3.2-05Regular AI red teaming of agents, integrated with existing security testingMonthly red-team reports; threat vector database
Controls between agents3.4-01Monitor and log inter-agent interactions; keep sensitive data from leaking between agentsAgent-to-agent arrows in the attacker’s map; source=agent label
Input guardrails, direct injection4.1-01Input guardrails to detect direct prompt injection and adversarial attacksPrompt check pseudocode, tests 1 to 7
Input guardrails, indirect injection4.1-04Input guardrails to detect indirect prompt injection; scan external files before they reach memory or modelsFig 4; source=external label
Output guardrails4.2-02Output guardrails for personal data and for malicious or undesirable contentResponse check in Fig 4
Monitoring of tool usage4.3-05Logging that captures context, inputs, outputs, tool calls and decisionsTool type and direction labels; sample logs
Audit trail and SIEM feed4.3-08Maintain audit trails of agent actions; stream logs to a SIEM for SOC monitoringSpan store; planning point 6
Tracing across agents and tools4.3-09Comprehensive logging and monitoring of agent activities across the systemOpenTelemetry spans; Fig 2 pipeline
Traceability of decisions4.3-11Reconstruct why an agent acted as it did, for forensic analysisSpan sequence and session correlation; Fig 3
Human in the loop4.4-01Human approval for high-risk agent actions before executionThird option in Fig 3 remediation

SSources

All pages accessed 20 September 2026.

Edited by Ding Sun, AI Workgroup, SGTech CSC Chapter.
Part of AI Security in Practice, a fortnightly community sharing series by the SGTech Cybersecurity Chapter, AI Workgroup.