SGTech Community Sharing · AI Security
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.
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.
| Agent 1 — Intake agent | Agent 2 — Assistant agent | |
|---|---|---|
| Job | Files supplier emails | Handles staff requests |
| Input from | Outside emails | Staff; saved notes |
| Tools | Read mailbox; save note | Search notes; send email |
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.
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.
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.
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:
seq=3 was written in the same session as the outside email read at seq=1. That pairing is what should make a defender stop.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:
save_note with tool=memory_write after read_mailbox with source=external in the same session (steps 1 and 3): content from outside the organisation was saved into memory that other agents trust.send_email with direction=output, straight after source=memory (step 5): an agent took content from memory and then used a high-risk tool that sends data out.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.
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.
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.
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.
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).
| Month (2026) | New prompts | Test cases | Overall ASR | Best model | Worst model |
|---|---|---|---|---|---|
| April | 39 | Not stated | About one in three | GPT-5, 25.6% | Llama 3 2B, 46.2% |
| May | 31 | 186 | 22.0% (41 unsafe) | GPT-5, 0.0% | Llama 4 Scout, 51.6% |
| June | 41 | 246 | 23.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.
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.
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.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.
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.
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 | CSA control | What the control asks for | Where this article covers it |
|---|---|---|---|
| Taint tracing in threat modelling | 1.1-01 | Perform taint tracing across workflows in the agentic AI system; especially important at autonomy levels 2 and 3 | Source and step-order labels; Fig 3 attack path; planning point 4 |
| Untrusted data into memory and retrieval | 2.1-12 | Validate data before it supplements RAG databases; zero-trust handling of all data flows | Step 3 of the scenario; alert rule 1 |
| Inventory of agents and tools | 2.4-01 | Document agents and tools, including descriptions of each tool’s intended use, inputs and outputs | Agent inventory and tool classification; planning point 1 |
| Sandboxing and segregation | 2.9-02 | Decouple data flow from control flow; isolate agents that carry out transactions | Remediation options under Fig 3 |
| Adversarial testing | 3.2-05 | Regular AI red teaming of agents, integrated with existing security testing | Monthly red-team reports; threat vector database |
| Controls between agents | 3.4-01 | Monitor and log inter-agent interactions; keep sensitive data from leaking between agents | Agent-to-agent arrows in the attacker’s map; source=agent label |
| Input guardrails, direct injection | 4.1-01 | Input guardrails to detect direct prompt injection and adversarial attacks | Prompt check pseudocode, tests 1 to 7 |
| Input guardrails, indirect injection | 4.1-04 | Input guardrails to detect indirect prompt injection; scan external files before they reach memory or models | Fig 4; source=external label |
| Output guardrails | 4.2-02 | Output guardrails for personal data and for malicious or undesirable content | Response check in Fig 4 |
| Monitoring of tool usage | 4.3-05 | Logging that captures context, inputs, outputs, tool calls and decisions | Tool type and direction labels; sample logs |
| Audit trail and SIEM feed | 4.3-08 | Maintain audit trails of agent actions; stream logs to a SIEM for SOC monitoring | Span store; planning point 6 |
| Tracing across agents and tools | 4.3-09 | Comprehensive logging and monitoring of agent activities across the system | OpenTelemetry spans; Fig 2 pipeline |
| Traceability of decisions | 4.3-11 | Reconstruct why an agent acted as it did, for forensic analysis | Span sequence and session correlation; Fig 3 |
| Human in the loop | 4.4-01 | Human approval for high-risk agent actions before execution | Third option in Fig 3 remediation |
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.