Next Article in Journal
An SDR-Integrated Dual-Band Directional Antenna System for Counter-Drone RF Link Suppression: Design and Open-Field Validation
Previous Article in Journal
Analysis of a Gaussian-Profiled Corrugated Horn Antenna with Variable-Depth Corrugations for Dual-Band X/Ku Satellite Communication Systems
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Security-Augmented Use Case Flow Refinement for LLM-Based Agentic Systems

1
School of Computer Science and Engineering, Beihang University, Beijing 100191, China
2
Xi’an Aeronautics Computing Technique Research Institute, Aviation Industry Corporation of China, Xi’an 710065, China
3
Engineering Research Center of Integration and Application of Digital Learning Technology, Ministry of Education, No. 2, Weigongcun Road, Haidian District, Beijing 100039, China
*
Author to whom correspondence should be addressed.
Electronics 2026, 15(18), 4135; https://doi.org/10.3390/electronics15184135 (registering DOI)
Submission received: 4 August 2026 / Revised: 26 August 2026 / Accepted: 10 September 2026 / Published: 12 September 2026

Abstract

Unlike conventional software systems and large language models (LLMs) evaluated in isolation, LLM-based agentic systems introduce a compositional, workflow-level attack surface. Existing security analysis approaches provide limited support for identifying security omissions implicit in functional use case flows and deriving corresponding flow refinements for direct incorporation into use case specifications. We formulate the Security-Augmented Use Case Flow Refinement Task and propose MA-SAFR, a multi-agent framework that coordinates Red Team, Blue Team, and Critic agents for threat anchoring, security-branch construction, and validation. EvoGraphRAG adapts relation-aware retrieval through validation feedback, while Risk-Specific Security Guidance (RSSG) provides risk- and role-specific constraints. To support systematic evaluation of this task, we construct SAFR-Bench from OWASP and MITRE ATLAS, comprising 157 cases and 235 source-grounded threat–refinement pairs. Across three generation models, MA-SAFR improves all three metrics on average compared with the strongest corresponding baselines; pipeline recall and pipeline precision increase by 63.44% and 54.96%, respectively. Controlled analyses show that RSSG and feedback-based graph evolution within gEvoGraphRAG improve downstream threat-to-defense conversion. Despite remaining challenges in implicit-threat identification, multi-threat coverage, and defense alignment, the results show that MA-SAFR can support the construction of valid security-augmented use case flows.

1. Introduction

LLM-based agentic systems are increasingly being deployed in real-world application settings, where they process user-provided information, support decisions, and interact with external tools or services [1]. Unlike conventional software systems, whose security-relevant operations are largely governed by developer-defined control logic, or LLMs evaluated in isolation, whose security is typically assessed at the model input–output boundary, agentic systems introduce an additional compositional, workflow-level attack surface. Specifically, model outputs can become intermediate control signals that select tools, supply arguments, retrieve external knowledge, update memory, or change application state [2,3,4]. This coupling among model behavior, potentially untrusted information, evolving state, delegated permissions, and tool-mediated execution allows malicious instructions or erroneous decisions to cross component boundaries and propagate through tool calls, data updates, and downstream business actions [5,6]. These risks therefore need to be analyzed in relation to the workflow steps where they are introduced, triggered, propagated, controlled, or recovered from [7,8].
Many of these workflow-level risks can be traced to system behaviors captured during requirements analysis, often through use case modeling, which organizes actor–system interactions into structured functional flows [9,10,11]. These flow steps not only describe normal business behavior but may also leave security-relevant assumptions unstated and potential risk entry points unaddressed. Existing approaches to risk analysis, security requirements analysis, and AI safety evaluation can identify relevant risks and security needs from different perspectives [5,12,13,14,15]. However, their outputs are usually threat lists, misuse cases, standalone security requirements, mitigation suggestions, test reports, or expert analyses rather than flow-level refinements that can be directly incorporated into existing use case specifications. Engineers therefore still need to manually determine whether a risk is grounded in the functional flow, where it is introduced or triggered, where the defense should be inserted, whether the defense covers the threat mechanism, and how the workflow should recover, retry, or terminate after the defense is triggered. As a result, traceability between identified threats and concrete use case flow refinements remains limited, thereby providing insufficient guidance for downstream design, testing, and implementation [16,17].
To close this gap, we formulate the Security-Augmented Use Case Flow Refinement Task, which identifies security omissions implicit in functional use case flows and completes the missing security behavior as security-augmented refinements within the original use case flow structure. The task focuses on an end-to-end transformation from functional behavior to security handling logic: each security omission is grounded at a concrete flow step, and the corresponding preventive and failure-handling behavior is incorporated into the original flow while preserving the original functional intent. To address this task, we propose MA-SAFR, a multi-agent framework that analyzes functional use case flows to identify grounded threats and generate corresponding flow-level security refinements, thereby producing traceable, reviewable, and actionable security-augmented use case flows that can be directly incorporated into existing use case specifications. Given a functional use case flow, MA-SAFR uses a Red Team Agent to identify security threats grounded in the flow and anchor them to flow steps where the risks are introduced or triggered. A Blue Team Agent translates the corresponding defenses into Security Branch Points (SBPs) and Security-augmented Alternative Flows (SAFs). A Critic Agent validates whether the generated threat/refinement pairs satisfy five quality dimensions needed for flow-level refinement: threat validity, defense coverage, threat-defense traceability, branch closure, and flow consistency. To support this agent workflow, we design a security-oriented and flow-aware knowledge support mechanism comprising EvoGraphRAG and a Risk-Specific Security Guidance (RSSG) layer. EvoGraphRAG organizes external security knowledge as a graph and adapts retrieval through edge-weight updates based on Critic-derived validation feedback, while RSSG provides risk- and role-specific generation constraints for threat anchoring and SBP/SAF construction.
Based on this formulation, we investigate the following problem-oriented research questions:
  • RQ1: How effectively can missing security behavior be identified and incorporated into functional use case flows of LLM-based agentic systems?
  • RQ2: How does risk-specific security guidance affect threat identification and security refinement within functional use case flows?
  • RQ3: How does feedback-driven adaptation of security knowledge retrieval affect the quality of security-augmented use case flow refinements?
To support systematic evaluation of the Security-Augmented Use Case Flow Refinement Task, we construct SAFR-Bench from OWASP and MITRE ATLAS, comprising 157 cases and 235 source-grounded threat–refinement pairs. Using this benchmark, we evaluate MA-SAFR across three generation models and compare it with single-agent, no-retrieval, and vanilla-RAG baselines. The results show that, on average, MA-SAFR improves upon the strongest baseline in threat-validity recall, pipeline recall, and pipeline precision, with relative gains of 63.44% and 54.96% in the latter two metrics, respectively. Further controlled analyses examine how RSSG and feedback-based edge-weight updates in EvoGraphRAG affect S B P / S A F refinement quality, while a parameter sensitivity analysis assesses the edge-weight update configuration. External qualitative case studies provide preliminary evidence of applicability to medical and software-development flows beyond SAFR-Bench, while a computational-cost analysis reports online LLM-generation cost in terms of token consumption and observed generation time. Finally, our failure analysis identifies three remaining bottlenecks: threat identification failures, incomplete coverage of security omissions in multi-threat cases, and semantic misalignment among identified threats, generated S B P / S A F refinements, and the original functional flow.
The main contributions of this paper are as follows:
  • We formulate the Security-Augmented Use Case Flow Refinement Task, which transforms functional use case flows into security-augmented use case flows, and construct SAFR-Bench, which contains 157 cases and 235 source-grounded threat records and corresponding security-augmented alternative flows, supporting evaluation of threat discovery and anchoring, and flow refinement.
  • We propose MA-SAFR, a multi-agent framework that decomposes security-augmented flow refinement into three coupled reasoning stages: threat anchoring, defense-branch generation, and quality validation through Red Team, Blue Team, and Critic agents.
  • We propose a security-oriented and flow-aware knowledge support mechanism that combines EvoGraphRAG with a Risk-Specific Security Guidance (RSSG) layer. EvoGraphRAG retrieves relation-aware risk–attack–mitigation evidence and adapts retrieval preferences through feedback-based graph evolution, while RSSG provides risk- and role-specific guidance for grounding threats and constructing flow-consistent SBP/SAF refinements.
The paper is structured as follows: Section 2 reviews related work and positions our study within the existing literature. Section 3 formalizes the representation of use case flows and defines the Security-Augmented Use Case Flow Refinement Task. Section 4 presents MA-SAFR details, including the Red Team, Blue Team, and Critic agents, EvoGraphRAG, and the RSSG layer. Section 5 describes SAFR-Bench, the evaluation metrics, research questions, baseline settings, and experimental setup. Section 6 presents the comparative results and component-level analyses of RSSG and feedback-based edge-weight updates, examines parameter sensitivity, computational cost and scalability considerations, evaluates the reliability of LLM-based judging, and reports the diagnostic failure analysis and external qualitative case studies. Section 7 discusses potential internal, external, and construct threats to our study. Section 8 concludes the paper and outlines future directions.

2. Related Work

2.1. Security Requirements Analysis and Refinement

Security requirements analysis and refinement aim to identify threats in functional specifications and derive corresponding security requirements [18]. Threat-oriented methods identify and categorize threats before eliciting and validating security requirements [19]; model-driven approaches detect STRIDE threats and recommend protective requirements [20]; use-case-driven methods further derive misuse cases, security use cases, and mitigation schemes from functional scenarios [13].
Recent studies have applied LLMs to security requirements analysis, including eliciting threats from system descriptions [21] and deriving security requirements from functional specifications under the guidance of security standards [14]. Multi-agent approaches have also been explored to identify inclusivity-related concerns and refine security requirements [22].
The conventional and LLM-based approaches reviewed above primarily produce threat models, mitigation schemes, or standalone security requirements; the process of anchoring a security omission to a functional-flow step and translating the corresponding defense into a validated handling branch remains largely analyst-driven. To bridge this gap, MA-SAFR treats security-oriented use-case refinement as an end-to-end, verifiable transformation from functional behavior to security handling logic rather than as isolated artifact generation. Its Red Team Agent identifies and grounds each omission at a concrete flow step, while its Blue Team Agent converts the resulting threat record into an SBP/SAF pair that encodes the security check, trigger condition, handling actions, and closure within the original flow. The Critic Agent then validates the complete transformation for threat validity, defense coverage, threat–defense traceability, branch closure, and flow consistency.

2.2. Reflective and Feedback-Driven LLM Agent Systems

Reflection and iterative feedback have been widely explored as mechanisms for improving LLM agent behavior without updating model parameters. Reflexion converts scalar or free-form task feedback into verbal reflections and stores them in episodic memory to guide subsequent trials [23]. Self-Refine instead uses the same LLM to generate feedback on its current output and iteratively revise that output [24], while CRITIC grounds the verification–correction process in feedback obtained through interactions with external tools [25]. Together, these methods show how memory, self-evaluation, and tool-supported critique can support feedback-driven improvement.
Feedback-driven coordination has also been studied in role-specialized multi-agent systems for engineering tasks. MetaGPT encodes standardized operating procedures into a software-engineering workflow, allowing agents with distinct roles to produce and verify intermediate artifacts [26]. ChatDev similarly organizes specialized agents across software design, coding, and testing through multi-turn communication [27]. In circuit design, AutoSizer coordinates agents for circuit understanding, adaptive search-space construction, and optimization orchestration, and uses simulation feedback in a two-loop process to revise variable priorities and parameter ranges [28]. These systems demonstrate the usefulness of role specialization and iterative evaluation across engineering domains.
MA-SAFR does not introduce a fundamentally new feedback paradigm. Instead, it provides a security-requirements-specific instantiation in which Critic judgments over threat and SBP/SAF tuples are mapped to topology-preserving edge-weight updates in a source-grounded security knowledge graph. The resulting persistent preferences guide subsequent role-specific retrieval, prioritizing risk and attack evidence for the Red Team and threat-linked mitigation paths for the Blue Team without introducing new security knowledge.

2.3. Security Benchmarks for LLMs and Agentic Systems

Relevant security benchmarks can be broadly grouped by evaluation target into model-level and agent-level benchmarks. Model-level safety evaluation has focused on harmful generation, trustworthiness, and adversarial robustness. RealToxicityPrompts [29] supports the evaluation of toxic degeneration, while ToxiGen [30] provides adversarially generated examples for implicit hate-speech detection. Broader frameworks such as DecodingTrust [31] assess multiple trustworthiness dimensions, whereas HarmBench [32] standardizes automated red teaming and robust-refusal evaluation. These benchmarks primarily treat individual inputs and model responses as the evaluation unit and report toxicity, harmfulness, refusal or compliance, and attack success.
Agent-level benchmarks extend evaluation to multi-step trajectories involving external data, tools, and environment state. ToolEmu [7] examines risky tool use in LM-emulated sandboxes, AgentDojo [5] evaluates utility and security under indirect prompt injection, and Agent Security Bench (ASB) [8] systematizes attacks and defenses across agent prompts, tools, and memory. They typically evaluate agent behavior in terms of task completion, attack success, unsafe tool calls, policy violations, and sensitive-information leakage.
Although these benchmarks cover model outputs and agent behavior, they provide limited support for evaluating the transformation of security omissions implicit in functional use case flows into requirements-level flow refinements. To address this gap, SAFR-Bench organizes each case as a layered structure that links a requirement description and a functional use case flow to source-grounded threat records and corresponding SBP/SAF refinements. This structure supports evaluation of threat discovery and anchoring, defense-branch generation, and end-to-end refinement. OWASP LLM Top 10 [33] and MITRE ATLAS [34] provide the security taxonomies and source evidence used to construct these cases. Accordingly, SAFR-Bench complements model- and agent-level benchmarks by treating traceable requirements-level flow refinement as a distinct evaluation target.

2.4. Graph-Based and Adaptive RAG for Security Reasoning

Retrieval-augmented generation (RAG) augments language-model generation with external evidence retrieved from a non-parametric corpus [35]. In chunk-based RAG, source documents are segmented into independently indexed text units that are ranked by semantic relevance and supplied as generation context [35,36]. Although this representation provides domain-specific evidence, it leaves relations among security risks, attacks, mitigations, and source evidence implicit. In addition, a fixed retrieve-then-generate policy cannot adjust when or how retrieval is performed in response to query complexity or generation-time signals. These limitations motivate two complementary directions: representing external knowledge relationally and adapting retrieval to changing evidence needs.
Graph-based RAG addresses the first direction by representing external knowledge as entities and relations and retrieving relation-connected subgraphs or graph-guided chunk neighborhoods. G-Retriever [37] and KG2RAG [36] demonstrate how graph structure can support subgraph retrieval and relation-aware organization of evidence. In cybersecurity, knowledge graphs are also used to integrate heterogeneous threat intelligence and support situational awareness, attack-path analysis, and knowledge inference [38]. Together, these studies show how explicit graph structure supports relation-aware retrieval and why it is suitable for security knowledge that links risks, attacks, mitigations, and source evidence.
Adaptive and self-reflective RAG methods address the second direction by adjusting retrieval and generation in response to query- and generation-time signals. FLARE [39] retrieves additional evidence when upcoming content is uncertain, Adaptive-RAG [40] selects retrieval strategies according to query complexity, and Self-RAG [41] uses reflection tokens to assess retrieved evidence and generated outputs. However, these representative methods adapt retrieval primarily within the current inference process; they do not use downstream task validation to persistently update retrieval preferences for subsequent queries.
Building on both directions, EvoGraphRAG combines role-specific, relation-aware graph retrieval with Critic-derived validation feedback for security-oriented use case refinement. The Red Team Agent retrieves threat-oriented graph neighborhoods, whereas the Blue Team Agent follows paths from anchored threats to candidate mitigations. Validation feedback updates graph edge weights, thereby adapting retrieval preferences for later retrieval rounds. Complementing this retrieval mechanism, RSSG supplies risk- and role-specific constraints for mapping retrieved evidence to flow-grounded threat anchors and SBP/SAF refinements. Together, EvoGraphRAG and RSSG form the security-oriented and flow-aware knowledge support mechanism that links retrieval, refinement, and validation.

3. Task Formulation

3.1. Use Case Flow Representation

Use case modeling is widely used to capture interaction scenarios between actors and a target system in functional requirements and organize them into action flows. A use case specification U C S usually contains one basic flow ( B F ) and zero or more alternative flows, denoted as the set AF :
U C S = B F , AF .
The B F describes the main success scenario in which the actor and the system interact along the normal path to achieve the use case goal, which is represented as an ordered sequence of basic flow steps b i :
B F = b 1 , b 2 , , b n .
Each alternative flow A F b p k AF describes a deviating or exceptional path guided by a branch point b p k BP , where BP is the set of branch points and b p k is a flow step located in either the B F or another alternative flow. The set of alternative flows is represented as
AF = A F b p k = a 1 b p k , a 2 b p k , , a r b p k b p k BP ,
where a 1 b p k , a 2 b p k , , a r b p k is the ordered sequence of steps.

3.2. Security-Augmented Use Case Flow Refinement Task

We define the Security-Augmented Use Case Flow Refinement Task as identifying flow-level security omissions in a use case specification and completing the missing security behavior as security-augmented refinements within the original use case flow structure. The goal is not to introduce a separate flow representation, but to make implicit or missing security behavior explicit while preserving the functional intent and structural conventions of the original use case.
To characterize how missing security behavior is completed within the use case flow structure, we introduce two role labels: Security Branch Point ( S B P ) and Security-augmented Alternative Flow ( S A F ). A security branch point s b p l is inserted at an anchored position in the existing use case flow:
s b p l = a n c h o r l , s t e p l ,
where a n c h o r l indicates the insertion position and s t e p l denotes the inserted security check or control. Similar to a branch point b p k that guides A F b p k , an inserted security branch point s b p l guides the corresponding security-augmented alternative flow S A F s b p l :
S A F s b p l = s a 1 s b p l , s a 2 s b p l , , s a q s b p l ,
where s a 1 s b p l , s a 2 s b p l , , s a q s b p l is the sequence of security-handling steps.
The output of the Security-Augmented Use Case Flow Refinement Task is:
U C S + = B F + , AF + ,
where B F + and AF + denote the updated basic flow and alternative-flow set after inserting S B P s and adding the corresponding S A F s .
Figure 1 illustrates the refinement structure with a simplified benchmark-derived example. The task preserves the original functional flow while inserting S B P s at anchored positions in the flow and adding corresponding S A F s to handle detected security conditions.

4. Approach

4.1. Multi-Agent Security-Augmented Flow Refinement (MA-SAFR)

As shown in Figure 2, MA-SAFR addresses the Security-Augmented Use Case Flow Refinement Task by decomposing it into three distinct but coupled reasoning objectives. First, a refinement approach must inspect the original use case flow and identify flow-level security omissions grounded in the existing use case behavior. Second, the identified omissions must be converted into concrete flow refinements by inserting security branch points and generating the corresponding security-augmented alternative flows. The first two objectives are tightly coupled: the identified omission determines where and why a refinement is needed, while the generated refinement must mitigate the threat implied by the omission and remain consistent with the anchored behavior and surrounding flow context. Potential failures in this coupling include ungrounded threats, defenses that do not cover the corresponding threat mechanisms, traceability gaps, incomplete branches, and modifications that change the original functional intent. These risks motivate the third objective: validation over threat validity, defense coverage, threat-defense traceability, branch closure, and flow consistency.
Motivated by this analysis, we instantiate MA-SAFR by assigning these objectives to three specialized agents: a Red Team Agent for security omission identification, a Blue Team Agent for security-augmented flow generation, and a Critic Agent for refinement validation.

4.1.1. Red Team Agent

Given an original use case specification, the Red Team Agent inspects the existing use case flows to identify security omissions and outputs a threat-record set TR = { t r 1 , t r 2 , , t r m } , which serves as an intermediate representation for passing anchored threat information to the downstream agents. Each threat record takes the following structured form:
t r j = t i d j , a n c h o r j , m e c h j , i m p a c t j ,
where t i d j is the threat identifier, a n c h o r j denotes the flow step where the omission is anchored, m e c h j describes how the threat can arise from the anchored behavior, and i m p a c t j describes the corresponding security consequence. Table 1 summarizes the prompt structure used by the Red Team Agent.

4.1.2. Blue Team Agent

Given the threat-record set TR produced by the Red Team Agent, the Blue Team Agent transforms each t r j TR into an S B P / S A F refinement pair. Specifically, it conditions generation on the anchored step a n c h o r j , threat mechanism m e c h j , security impact i m p a c t j , the original use case flow, and retrieved mitigation knowledge, and produces an s b p j and a corresponding S A F s b p j that mitigates the identified threat. The refinement pairs s b p j , S A F s b p j are then integrated into the original flow to obtain U C S + . Table 2 summarizes the prompt structure used by the Blue Team Agent.

4.1.3. Critic Agent

After the Red Team and Blue Team agents produce threat records and refinement pairs, the Critic Agent validates each tuple t r j , s b p j , S A F s b p j against the original use case flow. The validation follows five dimensions:
  • Threat validity checks whether each identified omission corresponds to a security-relevant concern grounded in the original flow;
  • Defense coverage checks whether the generated S B P / S A F mitigates the threat mechanism described in the corresponding threat record;
  • Threat–defense traceability checks whether the threat record, inserted S B P , and generated S A F are semantically connected;
  • Branch closure checks whether the S A F forms a complete security-handling path with a well-defined continuation or termination;
  • Flow consistency checks whether the added security behavior preserves the original functional intent of the use case.
The Critic Agent outputs a structured validation report containing an overall decision, dimension-level outcomes, and concise feedback for threats not grounded in the original flow, weak defenses, missing traceability, incomplete branches, or inconsistent flow modifications. Both the dimension-level outcomes and the overall decision are categorical rather than numerical. Table 3 summarizes the prompt structure used by the Critic Agent.
The Critic Agent assesses the generated refinements, and its validation results are used to derive feedback signals for subsequent graph evolution rather than to filter, revise, or regenerate those refinements.
Using UC0125 in Figure 1 as a compact illustration, the Red Team Agent identifies embedded prompt instructions in ingested email content as a prompt-injection threat anchored at BF1. The Blue Team Agent inserts an S B P after BF1 and generates an S A F that quarantines the injected content, reloads trusted knowledge-base entries, and returns to BF1. The Critic Agent then checks whether the resulting threat–refinement tuple is grounded, covers the threat mechanism, remains traceable and flow-consistent, and forms a closed branch.

4.2. EvoGraphRAG

MA-SAFR relies on external security knowledge to support both threat identification and defense generation. When external security knowledge is indexed as ordinary text chunks, standard chunk-based RAG retrieves isolated snippets whose relevance is mainly determined by textual similarity. Although such snippets may mention related risks or mitigations, they do not explicitly preserve the relations among risks, attack patterns, techniques, mitigations, and source evidence. For the Security-Augmented Use Case Flow Refinement Task, this limitation is critical: the Red Team Agent needs risk and attack knowledge that can be anchored to specific flow behavior, while the Blue Team Agent needs mitigation knowledge that is traceable to the identified threat and can be translated into an S B P / S A F refinement. Both needs require retrieval to preserve the relations between threat mechanisms, defense knowledge, and the flow context. Without relational retrieval, agents may select semantically similar but structurally irrelevant evidence, generate generic threat descriptions, or choose mitigations that are poorly aligned with the identified threat mechanism. EvoGraphRAG addresses this limitation by organizing security knowledge as a heterogeneous graph over risks, attack patterns, techniques, mitigations, and source evidence, and by retrieving role-specific graph neighborhoods for different agents. The graph structure makes risk–attack, attack–technique, risk–mitigation, and evidence-support relations explicit, while the evolutionary component updates edge weights from Critic Agent feedback so that knowledge paths leading to valid and traceable refinements are promoted and paths associated with threats not grounded in the original flow or weak defenses are down-weighted.

4.2.1. Graph Representation

EvoGraphRAG represents external security knowledge as a heterogeneous directed graph:
G = ( V , E , w ) ,
where V is the set of security knowledge nodes, E is the set of typed directed edges, and w : E R + assigns a positive weight to each edge. Each node v V belongs to one of five types: Risk, AttackPattern, Technique, Mitigation, or SourceEvidence. A Risk node represents a security risk category, an AttackPattern node describes how a risk may be exploited in a concrete scenario, a Technique node captures a more specific adversarial technique, a Mitigation node represents a security control or defense strategy, and a SourceEvidence node preserves the source material supporting the corresponding knowledge item.
Edges encode the relations needed for flow-level security refinement. The relation e x p l o i t s connects an attack pattern to the risk it exploits, b e l o n g s _ t o connects a technique to its broader risk category, i m p l e m e n t s connects a technique to the attack pattern it instantiates, m i t i g a t e d _ b y connects risks, attack patterns, or techniques to candidate mitigations, and s u p p o r t e d _ b y links graph nodes or relations to their source evidence. These relations allow EvoGraphRAG to retrieve not only semantically similar knowledge items, but also the surrounding risk–attack–mitigation evidence paths that explain why a knowledge item is relevant. The graph is constructed from external security knowledge sources and can be instantiated with different domain-specific security taxonomies, attack knowledge bases, and mitigation guidelines.

4.2.2. Role-Specific Retrieval and Reranking

Given the graph G , EvoGraphRAG performs role-specific retrieval for the Red Team and Blue Team agents according to their different knowledge needs. For the Red Team Agent, the query q R is built from the original requirement text and the functional flow steps. The retriever searches over threat-oriented nodes, including Risk, AttackPattern, and Technique nodes, and then expands the initial hits to related risks, attack patterns, techniques, mitigations, and source evidence. The returned graph neighborhood supports threat naming, mechanism explanation, and flow-step anchoring.
For the Blue Team Agent, the query q B is conditioned on both the original flow and a specific threat record t r j . It includes the anchored flow step, the threat mechanism, and the security impact. The retriever first identifies risk, attack-pattern, or technique nodes related to the threat, and then follows graph paths to candidate Mitigation nodes. The returned neighborhood is therefore mitigation-oriented and preserves the relation between the identified threat and the candidate defense knowledge used to generate the corresponding S B P / S A F refinement.
For both roles, EvoGraphRAG reranks candidate graph items using a role-specific scoring function:
S c o r e ρ ( c , q ρ ) = α ρ s s e m ( c , q ρ ) + β ρ s c t x ( c , q ρ ) + γ ρ s g r a p h ( c ) + δ ρ s p a t h ( c ) + τ ρ s t y p e ( c ) + λ ρ s s r c ( c ) + μ ρ s e v o ( c )
where ρ { R , B } denotes the retrieval role, c is a candidate graph item, and q ρ is the role-specific query. The term s s e m measures semantic similarity, s c t x measures contextual fit with the use case flow or anchored threat context, s g r a p h captures graph support from neighboring evidence, s p a t h measures the relevance of graph paths to candidate mitigations, s t y p e encodes role-specific node-type preference, s s r c reflects source priority, and s e v o incorporates the current edge weights updated from validation feedback, as described in Section 4.2.3. By setting the weights ( α ρ , β ρ , γ ρ , δ ρ , τ ρ , λ ρ , μ ρ ) differently for the two roles, EvoGraphRAG produces distinct ranking preferences: Red Team retrieval prioritizes threat-relevant nodes and graph-supported risk evidence, whereas Blue Team retrieval prioritizes mitigation paths connected to the identified threat mechanism and fitted to the anchored flow context.

4.2.3. Feedback-Based Graph Evolution

The evolutionary component of EvoGraphRAG updates graph edge weights according to validation feedback. After the threat records and S B P / S A F refinements have been generated, the Critic Agent evaluates each threat–refinement tuple along five dimensions: threat validity, defense coverage, threat–defense traceability, branch closure, and flow consistency. The validation outcome is then converted into feedback signals for the graph paths that were retrieved during generation. A knowledge path that contributes to a valid and traceable refinement receives positive feedback, whereas a path associated with a threat not grounded in the original flow, weak defense, missing traceability, incomplete branch, or inconsistent flow modification receives negative feedback.
Let F t denote the set of feedback events collected at evolution round t. Each feedback event is associated with one or more retrieved graph edges and carries a signed reward derived from the validation outcome. For an edge e E , EvoGraphRAG aggregates all feedback signals assigned to that edge into a clipped signal s ˜ t ( e ) . The edge weight is then updated by a multiplicative rule:
w t + 1 ( e ) = c l i p w t ( e ) · exp ( η · s ˜ t ( e ) ) , w min , w max ,
where η is the update rate, and w min and w max bound the updated edge weight. Positive feedback increases the weight of an edge, making graph paths containing that edge more likely to be retrieved in later rounds; negative feedback decreases the weight, reducing the retrieval priority of paths that repeatedly lead to invalid or weak refinements.
The graph evolution process does not rewrite node descriptions or add benchmark-derived knowledge to the graph; it only updates edge weights. Thus, EvoGraphRAG preserves the original graph structure while adapting retrieval preferences through edge-weight updates.

4.3. Risk-Specific Security Guidance Layer

Although EvoGraphRAG provides relationally structured security knowledge, it primarily determines what security knowledge is relevant to a use case flow. However, the output of the refinement task is not a standalone knowledge item or a set of explanatory sentences, but a structured refinement of the use case flow that introduces a context-dependent sequence of security actions. It must decide where the security concern emerges, where an S B P should be inserted, and how the corresponding S A F should organize detection, handling, and flow continuation while preserving basic control-flow continuity and data-dependency consistency. In addition, different risk types require different refinement strategies. Accordingly, MA-SAFR introduces a Risk-Specific Security Guidance (RSSG) layer that provides manually defined, risk- and role-specific guidance for mapping retrieved security evidence to flow-grounded threat anchors and structured S B P / S A F  refinements.
RSSG is organized by risk type and provides role-specific constraints for the Red Team and Blue Team agents. For the Red Team Agent, RSSG constrains threat identification and anchoring. It guides the agent to anchor a threat to the flow step where the unsafe behavior is introduced, triggered, or first becomes actionable. It also helps distinguish independent threats from duplicates by considering the anchor step, risk type, attack mechanism, exposed asset, and security impact. This improves the traceability between each threat record and the original use case flow, while reducing generic or duplicate threat generation.
For the Blue Team Agent, RSSG constrains how the identified threat is converted into a concrete flow refinement. It guides the agent to place the S B P at the anchored position before the unsafe behavior causes harm. It also specifies the expected security-handling pattern of the corresponding S A F , such as flagging the unsafe condition, blocking or isolating the unsafe item or action, applying a risk-specific remediation, and returning to the protected flow or terminating safely. These constraints prevent the generated refinement from degenerating into generic logging, vague administrator review, or unrelated fallback behavior. Table 4 shows examples of RSSG guidance for representative risk types.
By making risk-specific anchoring and refinement rules explicit, RSSG complements EvoGraphRAG and bridges the gap between retrieved security knowledge and structured use-case-flow refinement. The full RSSG rule set used in the Red Team and Blue Team prompts is included in the public replication package.

5. Benchmark and Experiments

5.1. SAFR-Bench

We construct SAFR-Bench, a flow-level benchmark for evaluating methods on the Security-Augmented Use Case Flow Refinement Task. Unlike existing security datasets and benchmarks that primarily target toxic or unsafe model behavior [29,30,31], automated red-teaming or jailbreak test cases [15,32], cybersecurity capability evaluation [42], or prompt-injection attacks against tool-using agents [5], SAFR-Bench focuses on flow-level security refinement: it requires security concerns to be anchored to concrete use case steps and translated into security checks and security-handling branches. SAFR-Bench organizes each case into four layers: requirement description, functional use case flow, threat records, and security-augmented use case flow, and Table 5 summarizes the key fields of these four layers. This four-layer design supports evaluation of threat anchoring, defense-branch generation, and end-to-end refinement. SAFR-Bench comprises 157 cases derived from OWASP and MITRE ATLAS sources, including 100 OWASP-derived and 57 MITRE-ATLAS-derived cases, and provides 235 threat records, each paired with a corresponding S B P / S A F refinement. Table 6 summarizes the scale, source distribution, data split, and flow-refinement complexity of SAFR-Bench. To improve annotation quality, we randomly selected 60 cases for expert review by 5 engineers with 6–10 years of experience in requirements analysis or software development.

5.1.1. SAFR-Bench Construction

The construction of SAFR-Bench follows a pipeline aligned with the four-layer schema in which each annotation remains traceable to its source.
We first collect source materials from the OWASP Top 10 for Large Language Model Applications 2025 [33] and MITRE ATLAS v5.5.0 [34], two publicly maintained security knowledge resources that provide complementary coverage of recurring LLM application risks, example scenarios, and concrete adversarial techniques that can be mapped to requirement-level system behaviors. These materials span heterogeneous LLM application contexts and draw on community-curated risks, real-world attack observations, publicly documented incidents, and realistic security demonstrations, thereby providing source-level breadth across risk types, attack mechanisms, and application settings.
To approximate realistic requirements artifacts, where security risks are usually implicit in functional behavior rather than stated as attacks, we rewrite each source item or scenario into a concise requirement description for an LLM-enabled application. The rewritten description specifies the user goal, system boundary, and actors, while removing explicit attacker intent, attack labels, and mitigation hints.
Then, we construct the functional use case flow layer. Each rewritten description is parsed into an ordered use case flow, where each step describes one subject–verb–object unit and records its step identifier, action sentence, subject, verb, object, and predecessor link (flow_from). For the first step, this field is set to null. We do not inject security checks, controls, or security-handling branches into this functional-flow layer, so that the security-refinement task remains separated from the functional-flow construction step.
Next, we build threat records for each case. For OWASP-derived cases, the source risk category provides the risk category and evidence used to instantiate the threat record. For MITRE ATLAS-derived cases, we extract candidate threats from case procedures and associated techniques, then retain only threats that can be mapped to a flow step where the omission becomes actionable for detection, blocking, or constraint. Attacker-side preparation, staging, or reconnaissance activities are excluded unless they correspond to behavior that the target system can plausibly detect, block, or constrain within the functional flow. Each retained threat record contains a threat identifier, threat name, primary anchor step (anchor_steps), threat mechanism, security impact, source knowledge identifier (source_knowledge_id), and supporting evidence (source_evidence).
Finally, we construct the security-augmented use case flow layer by converting each threat record into a corresponding S B P / S A F refinement pair. The S B P is placed at the insertion position indicated by the threat anchor and expresses the security check that must occur before the protected behavior proceeds. The associated S A F references the mitigated threat (mitigates), defines the entry condition (entry_condition) under which the security branch is triggered, and specifies the handling steps required to block, remediate, retry, return to the protected flow, or terminate safely. The resulting benchmark package includes the case registry, schema files, rewritten requirement descriptions, functional use case flows, threat records, and security-augmented use case flows.

5.1.2. Expert Review and Quality Control

To improve the reliability of SAFR-Bench, we conduct expert review on a subset of 60 randomly selected cases. The review is performed by five engineers with 6–10 years of experience in requirements analysis or software development. The reviewers examine the four benchmark layers jointly, and the review process is summarized as follows:
  • Review coverage. The expert-reviewed subset contains 60 cases from SAFR-Bench and is checked by five experienced engineers.
  • Review dimensions. The review covers requirement rewriting fidelity, functional-flow quality, threat validity, source grounding, anchor correctness, defense coverage, threat-defense traceability, branch closure, and flow consistency.
  • Adjudication outputs. Cases with quality issues are revised at the corresponding layer, including rewritten requirement descriptions, corrected functional-flow steps, revised threat records, adjusted anchors, updated S B P placement, rewritten S A F steps, and branch-closure fixes.
These review dimensions are operationalized as layer-specific checks. For the requirement-description layer, reviewers check whether the rewritten description preserves the security-relevant functional affordances of the source scenario while removing explicit attacker intent, attack labels, and mitigation hints. For the functional use case flow layer, they check whether each step captures a coherent subject–verb–object action, whether the step order follows the rewritten requirement description, and whether the functional flow avoids injecting security controls that are not stated in the requirement. For the threat record layer, reviewers assess threat validity, source grounding, and anchor correctness, with the anchor required to identify the primary defense-actionable flow step. For the security-augmented use case flow layer, reviewers assess defense coverage, threat-defense traceability, branch closure, and flow consistency. In particular, each S A F must be linked to the threat it mitigates, include an explicit entry condition triggered by the corresponding S B P , provide concrete handling steps, and define a valid branch closure.
Cases with identified quality issues are revised at the corresponding layer and then checked for cross-layer consistency. Anchor corrections update the associated threat records and downstream S B P placement; defense revisions update the corresponding S A F while preserving the original functional intent; and ambiguous but acceptable alternative anchors are recorded separately rather than replacing the canonical anchor. The resulting expert-reviewed subset provides a higher-confidence portion of SAFR-Bench for validating benchmark quality and supporting the evaluation reported in this study.

5.2. Evaluation Metrics

In the evaluation, we focus on three quality aspects of Security-Augmented Use Case Flow Refinement Task: identifying security omissions, converting the identified omissions into valid defenses, and avoiding invalid over-generation. Accordingly, we use threat-validity recall, pipeline recall, and pipeline precision.
Threat-validity recall. Threat-validity recall measures the proportion of reference threats that are correctly identified. A predicted threat is counted as valid only when it matches a reference threat with respect to both the anchor step and the security concern. More specifically, the security-concern match is judged in the context of the functional flow based on the threat mechanism, affected target, and security consequence.
Let T P i T denote the number of predicted threats in case i that are matched to reference threat records, and let F N i T denote the number of reference threats in case i that are missed. Threat-validity recall is computed as
R threat = i T P i T i ( T P i T + F N i T ) .
Threat-validity recall is reported because a missed reference threat cannot enter downstream refinement and therefore directly limits attainable pipeline coverage. Over-generation is evaluated at the complete-task level through pipeline precision, where unmatched predicted threats are counted as false positives.
Pipeline recall. Pipeline recall measures the proportion of reference threats for which the complete pipeline produces valid end-to-end defenses. A defense is counted as valid only when all of the following conditions hold: the corresponding predicted threat is matched to a reference threat, the generated S B P / S A F refinement covers the reference defense intent, the inserted security check is placed at an appropriate flow step, and the associated S A F provides a concrete and complete handling branch for the threat.
Let T P i pipe denote the number of valid end-to-end defenses in case i, each mitigating a distinct reference threat, and let F N i pipe denote the number of required defenses that are not validly produced for the remaining reference threats. Pipeline recall is computed as
R pipe = i T P i pipe i ( T P i pipe + F N i pipe ) .
Pipeline precision. Pipeline precision measures the proportion of predicted threats that yield valid end-to-end defenses through the complete pipeline. Let F P i pipe denote the number of predicted threats in case i that do not yield valid end-to-end defenses because the threat is unmatched or the corresponding defense is missing or invalid. Pipeline precision is computed as
P pipe = i T P i pipe i ( T P i pipe + F P i pipe ) .

5.3. Research Questions (RQs) and Comparison Settings

RQ1: How effectively can missing security behavior be identified and incorporated into functional use case flows of LLM-based agentic systems? RQ1 evaluates the overall effectiveness of the complete MA-SAFR pipeline. To isolate the key characteristics of MA-SAFR, we compare it with three baseline settings. SA-NoRAG uses a single agent to perform security-omission identification and flow refinement without external retrieval. MA-NoRAG keeps the multi-agent decomposition but disables external retrieval, allowing us to examine the effect of role-specific Red Team and Blue Team reasoning alone. MA-VanillaRAG keeps the multi-agent setting and retrieves conventional text chunks from the same security knowledge corpus, which tests whether unstructured retrieval is sufficient for the Security-Augmented Use Case Flow Refinement Task. The full setting, denoted as MA-SAFR, uses the proposed multi-agent pipeline together with EvoGraphRAG and RSSG.
RQ2: How does risk-specific security guidance affect threat identification and security refinement within functional use case flows? RQ2 studies the contribution of the RSSG layer by fixing the multi-agent architecture and EvoGraphRAG retrieval while varying whether risk-specific guidance is provided. The with-RSSG setting uses RSSG to provide risk-specific guidance for threat anchoring and S B P / S A F refinement. The without-RSSG setting removes these risk-specific rules and replaces them with a generic, risk-agnostic scaffold that preserves the basic task instructions and strict output constraints.
RQ3: How does feedback-driven adaptation of security knowledge retrieval affect the quality of security-augmented use case flow refinements? RQ3 examines how feedback-based edge-weight updates in EvoGraphRAG affect MA-SAFR performance. We compare retrieval using the base graph edge weights with retrieval using the same graph after its edge weights have been updated using Critic-derived validation feedback from the training split. Within each model-specific comparison, all other pipeline components are held fixed, and the updated graph is frozen before evaluation on the test split.

5.4. Experiment Settings

We conduct the experiments with three generation models: Qwen3.5-Plus [43], DeepSeek-V3.2 [44], and GPT-5.2 [45]. For all comparison settings, we use Qwen3.5-Flash as the fixed LLM-as-a-judge model for both threat matching and defense validity evaluation, so that all methods are evaluated under the same judging protocol. The fixed LLM-as-a-judge model is distinct from the Critic Agent in the proposed approach and uses the same predefined prompts and structured output schemas across all comparison settings.
All generation and judging calls use temperature 0.0 and a request timeout of 900 s. Generated outputs are parsed under a strict JSON protocol, and we do not apply retry-based regeneration, JSON repair, schema correction, or missing-field imputation.
For retrieval-based settings, we use top-3 retrieval by default. Both MA-VanillaRAG and EvoGraphRAG use the same external security knowledge corpus, which is constructed from source-level OWASP and MITRE ATLAS materials rather than from SAFR-Bench reference annotations. Specifically, the corpus excludes benchmark-specific threat records, anchor labels, S B P / S A F refinement pairs, security-augmented use case flows, evaluation labels, and test-set validation feedback.
For the feedback-based edge-weight update in EvoGraphRAG, we use the default values η = 0.08 , w min = 0.35 , and w max = 3.0 . We focus on these three parameters because η determines the magnitude of the weight adjustment, while w min and w max define the allowable range of the updated edge weights. To assess sensitivity around the default configuration, we vary one parameter at a time. For η , we halve and double its default value, evaluating η { 0.04 , 0.08 , 0.16 } while retaining the default weight bounds. For the weight bounds, we set w min = 1.0 and w max = 1.0 in separate configurations while keeping the other bound at its default value and η = 0.08 , thereby restricting downward and upward weight adjustments, respectively. To isolate parameter effects under a fixed model, the sensitivity analysis was conducted using Qwen3.5-Plus. Each configuration was evaluated over five independent runs, and the mean results are reported; all other experimental settings were held fixed.

5.5. Human Validation of LLM-Based Judging

Because evaluating generated threats and security-augmented flow branches requires semantic judgment, we use an LLM-based judge for scalable assessment and further validate its reliability through an independent human study.
The validation subset is sampled from the evaluation outputs of RQ1, RQ2 and RQ3, covering different generation models, method variants, benchmark sources, and both positive and negative judging outcomes. The sampled instances involve two judging tasks: threat matching, which checks whether a generated threat corresponds to a reference threat, and defense validity, which checks whether the generated security-augmented basic flow and alternative flow effectively mitigate the matched threat without violating the original flow semantics.
For each sampled instance, the human assessor reviews the functional flow, reference information, generated output, and judging rubric, while the LLM-based judging results are hidden. The assessor then independently evaluates the corresponding threat-matching and defense-validity decisions.
We measure agreement between the LLM-based judge and human assessment using percent agreement and Cohen’s κ [46]. The former reports the raw agreement ratio, while the latter accounts for chance agreement. Formally, percent agreement is computed as follows:
P o = 1 N i = 1 N I ( y i L L M = y i H u m a n ) ,
where N is the number of sampled instances. Cohen’s κ is computed as follows:
κ = P o P e 1 P e ,
where P o is the observed agreement and P e = c P L L M ( c ) P H u m a n ( c ) is the chance agreement estimated from the marginal label distributions.

6. Results and Discussion

6.1. RQ1: How Effectively Can Missing Security Behavior Be Identified and Incorporated into Functional Use Case Flows of LLM-Based Agentic Systems?

Table 7 presents the comparative results of MA-SAFR and the baselines on SAFR-Bench across three evaluation metrics. Overall, these results show that MA-SAFR delivers the best end-to-end refinement performance across all three generation models, indicating that the complete MA-SAFR pipeline improves the refinement of security-augmented use case flows.
First, the SA-NoRAG/MA-NoRAG comparison suggests that role-specific agent decomposition better supports multi-stage refinement. Across all three generation models, MA-NoRAG achieves higher threat-validity recall, pipeline recall, and pipeline precision than SA-NoRAG. By separating threat identification from defense construction, the multi-agent setting allows each agent to focus on a distinct refinement stage rather than handling all subtasks in a single generation pass.
Second, the MA-NoRAG/MA-VanillaRAG comparison examines the effect of adding chunk-level retrieval to the multi-agent setting. Across all three generation models, MA-VanillaRAG achieves higher threat-validity recall and pipeline precision than MA-NoRAG. Its effect on pipeline recall is less consistent: pipeline recall improves for DeepSeek-V3.2 and GPT-5.2 but slightly decreases for Qwen3.5-Plus. This pattern suggests that retrieved text chunks can provide useful security cues, but these cues do not always translate into more complete and valid S B P / S A F refinements.
Finally, the MA-VanillaRAG/MA-SAFR comparison examines the combined effect of replacing chunk-level retrieval with EvoGraphRAG and providing RSSG. Both settings use the same external security knowledge corpus and multi-agent decomposition; MA-VanillaRAG presents retrieved text chunks as background evidence, whereas MA-SAFR combines relation-aware graph retrieval with risk-specific refinement guidance. Across all three generation models, MA-SAFR achieves higher pipeline recall and pipeline precision than MA-VanillaRAG; threat-validity recall is also higher for Qwen3.5-Plus and GPT-5.2 but lower for DeepSeek-V3.2. For Qwen3.5-Plus and GPT-5.2, the simultaneous improvements in threat-validity recall and both pipeline metrics suggest that the combined mechanism supports both threat discovery and downstream refinement. For DeepSeek-V3.2, MA-VanillaRAG identifies more reference threats, whereas MA-SAFR achieves higher pipeline recall and pipeline precision. To examine this trade-off beyond the aggregate metrics, we further analyzed the matched-threat and valid-defense counts across the five runs. The two settings generate nearly the same number of threat records per run (109.8 for MA-VanillaRAG and 110.6 for MA-SAFR), indicating that the lower threat-validity recall of MA-SAFR is not caused simply by fewer predictions. The reduction therefore occurs at the threat-grounding stage, where fewer generated records satisfy the reference-anchor and semantic security-concern criteria. However, the mean proportion of matched reference threats converted into valid end-to-end defenses increases from 29.82 % under MA-VanillaRAG to 68.45 % under MA-SAFR, indicating that matched threats are more frequently carried through to jointly valid S B P / S A F refinements. This pattern suggests that, for DeepSeek-V3.2, the MA-SAFR configuration favors more constrained threat interpretations while substantially strengthening risk-specific handling and branch closure in downstream refinement. This result also indicates a model-specific trade-off between broader reference-threat coverage and downstream refinement alignment, and the contributions of RSSG and feedback-based retrieval adaptation to this trade-off are examined further in RQ2 and RQ3. Overall, across the three generation models, MA-SAFR provides a more consistent benefit for downstream threat-to-defense conversion than for threat discovery.
Although MA-SAFR achieves substantial relative improvements over the baselines, its absolute pipeline performance remains modest. At the current performance level, MA-SAFR should therefore be regarded as a human-in-the-loop decision-support tool that proposes traceable candidate refinements for requirements and security review, rather than as an autonomous replacement for security analysis. Accordingly, the relative improvements demonstrate comparative gains under the benchmark, while the absolute results help clarify the method’s current scope of practical applicability.

6.2. RQ2: How Does Risk-Specific Security Guidance Affect Threat Identification and Security Refinement Within Functional Use Case Flows?

Table 8 reports the relative changes introduced by RSSG compared with the without-RSSG setting. Across all three generation models, RSSG yields positive relative changes in both pipeline recall and pipeline precision, indicating that it improves the coverage of reference threats by valid defenses while more effectively controlling invalid over-generation across the complete pipeline. This pattern is particularly informative because RSSG is intended not merely to expand threat discovery, but to complement EvoGraphRAG by guiding the translation of retrieved security evidence into flow refinements.
For Qwen3.5-Plus and GPT-5.2, the improvement extends to threat-validity recall, suggesting that RSSG can support both threat discovery and downstream refinement. For DeepSeek-V3.2, RSSG decreases threat-validity recall while improving both pipeline metrics. Because RSSG jointly imposes risk-specific threat-anchoring constraints and structured S B P / S A F refinement requirements, this pattern suggests that, for DeepSeek-V3.2, RSSG narrows reference-threat coverage while strengthening threat–defense traceability and branch closure. Thus, its primary benefit in this setting lies in improving the refinement of matched threats rather than expanding threat discovery.
Taken together, under the reported settings, RSSG affects threat discovery differently across models, while its most consistent contribution lies in bridging relation-aware security knowledge retrieval and structured use-case-flow refinement, thereby improving downstream threat-to-defense conversion.

6.3. RQ3: How Does Feedback-Driven Adaptation of Security Knowledge Retrieval Affect the Quality of Security-Augmented Use Case Flow Refinements?

Table 9 reports the relative changes introduced by feedback-based edge-weight updates. Across all three generation models, the updates yield positive changes in pipeline recall and pipeline precision, indicating a consistent benefit for downstream threat-to-defense conversion. Their effect on threat discovery is less uniform: threat-validity recall improves for Qwen3.5-Plus and GPT-5.2 but remains unchanged for DeepSeek-V3.2. For Qwen3.5-Plus and GPT-5.2, the simultaneous improvements across all three metrics suggest that the updated retrieval preferences can support both threat discovery and downstream refinement. For DeepSeek-V3.2, feedback-based edge-weight updates leave threat-validity recall unchanged while improving both pipeline metrics. Therefore, unlike Qwen3.5-Plus and GPT-5.2, DeepSeek-V3.2 obtains no additional threat-coverage benefit from the updated retrieval preferences, although it still benefits in downstream refinement. Together with RQ2, this helps explain the mixed RQ1 result for DeepSeek-V3.2: although MA-SAFR covers fewer reference threats than MA-VanillaRAG, the controlled analyses suggest that RSSG and feedback-based retrieval adaptation primarily strengthen the conversion of matched threats into valid refinements rather than consistently expanding reference-threat coverage.
Each paired comparison keeps the graph topology, retriever, source knowledge, and remaining pipeline components fixed; the observed changes can therefore be attributed more directly to feedback-based edge-weight updates, which alter the retrieval priorities of existing risk–attack–mitigation paths without rewriting node descriptions or changing relation types. This prioritization can help the agents translate identified threats into valid S B P / S A F refinements by making paths associated with successful refinements more prominent during retrieval. Overall, feedback-based edge-weight updates have a model-dependent effect on threat discovery but a consistently positive effect on downstream refinement.

6.4. Parameter Sensitivity of EvoGraphRAG’s Edge-Weight Update

Table 10 first examines the update rate η , which determines how strongly validation feedback changes the edge weights. The default value η = 0.08 achieves the highest observed performance across all three metrics, while both the smaller and larger update rates yield lower results. Moreover, the reductions observed at η = 0.16 are consistently larger than those at η = 0.04 relative to the default, suggesting that performance is more sensitive to an overly large update rate within the tested range. This result indicates a trade-off: a smaller η may underuse the validation feedback, whereas a larger η may exert an excessively strong influence on retrieval preferences. Thus, η = 0.08 provides the best observed balance among the tested values.
Changing either weight bound also reduces performance relative to the default configuration. Raising w min to 1.0 limits the extent to which negative feedback can decrease edge weights, whereas lowering w max to 1.0 limits the extent to which positive feedback can increase them. Both variants underperform the default, with the restriction on negative weight adjustments producing a larger decrease in the pipeline metrics. Under the default configuration, none of the updated edge weights reached either bound; therefore, further widening the bounds would not change the evolved graph under the current update settings. Taken together, these results suggest that, within the tested settings, retaining the capacity for both downward and upward weight adjustments yields better observed performance than restricting either direction.

6.5. Computational Cost and Scalability Considerations

Table 11 reports the average LLM-generation cost of the four Qwen3.5-Plus settings, including the input and output token consumption and generation time within the pipeline. Retrieval is executed locally and does not introduce additional LLM-token consumption. Critic-based validation is performed during offline graph adaptation, with its cost amortized across subsequent cases, whereas the resulting edge-weight updates are applied locally. The reported online cost therefore excludes this overhead.
Among the four settings, MA-SAFR has the highest total token consumption and observed LLM-generation time, while its output-token consumption remains close to that of SA-NoRAG. This pattern is expected, given that relation-aware retrieval evidence and RSSG guidance enlarge the input context. This additional cost represents the computational trade-off associated with its improved refinement performance. The overhead also varies with the number and content length of the threat records passed from the Red Agent to the Blue Agent. Nevertheless, its observed LLM-generation time is 1.14 times that of SA-NoRAG (9.756/8.546), indicating that the increase in input-token consumption does not translate proportionally into generation latency in the evaluated setting.
From a deployment perspective, MA-SAFR is amenable to existing input-side optimizations because it repeatedly reuses substantial prompt components, including role instructions, refinement constraints, and output schemas. In cache-enabled deployments, prefix caching can reuse the computation of these stable prompt components [47], while retrieved-context compression and prompt compression can reduce the actual input-token count [48,49]; together, these techniques provide practical opportunities to reduce the computational cost of MA-SAFR during deployment.

6.6. Reliability of LLM-Based Judging

Table 12 reports the agreement between the LLM-based judge and the independent human assessment described in Section 5.5. Overall, the LLM-based judge shows meaningful agreement with the human assessment on both judging tasks, with higher consistency for threat matching than for defense validity.
For threat matching, the LLM-based judge agrees with the human assessment on 53 out of 60 instances, achieving an agreement rate of 88.33% and a Cohen’s κ of 0.767. This result indicates that the judge is largely reliable in determining whether a generated threat corresponds to a reference threat. For defense validity, the agreement rate is 81.67%, with a Cohen’s κ of 0.633. Although lower than that for threat matching, this result still indicates a degree of overall consistency in the judging protocol for large-scale evaluation.
The lower agreement on defense validity is expected because this task requires more complex semantic judgment. The assessor must determine not only whether the generated defense is relevant to the threat, but also whether the inserted S B P / S A F can effectively mitigate the threat, preserve the original flow semantics, and form a coherent branch. Therefore, defense validity is intrinsically more subjective than threat matching. These results support the use of the LLM-based judge for scalable evaluation, while also indicating that defense-validity judgments remain a source of evaluation uncertainty.
A qualitative review shows that threat-matching disagreements mainly arose at category boundaries or when related risks were expressed at different levels of abstraction, whereas defense-validity disagreements concerned whether alternative controls sufficiently covered the reference intent and whether the S A F provided complete handling and closure. The disagreements were bidirectional: the LLM-based judge was more permissive than the human assessor in 3 of the 7 threat-matching cases and 6 of the 11 defense-validity cases, and stricter in the remaining cases, suggesting no simple one-sided judging tendency in this sample. These disagreements indicate that the exact values of judge-dependent metrics are subject to evaluation uncertainty, particularly for defense validity, while the overall agreement still supports the use of the judging protocol for aggregate comparisons.

6.7. Failure Analysis

We perform a case-by-case diagnostic analysis of the failed or partially covered cases observed in our experiments. The analysis shows that threat identification failure accounts for the largest share, followed by incomplete coverage of security omissions in multi-threat cases and semantic misalignment.
The dominant limitation is threat identification failure, reflecting the difficulty of inferring implicit security threats from the functional behavior represented by use case flow steps. To reduce such omissions, future work could employ multi-pass flow-to-threat reasoning, in which the functional flow is revisited from complementary risk perspectives to identify security omissions not captured in an initial pass.
A second limitation is incomplete coverage of security omissions in multi-threat cases. In some partially covered cases involving chain-like or multiple related attack opportunities, MA-SAFR identifies the most salient threat but does not address all security omissions in the use case. This pattern points to the need for explicit modeling of threat dependencies, attack propagation paths, and residual risks, so that related threats and attack opportunities remaining after a control can be analyzed jointly rather than independently.
The third limitation concerns semantic misalignment among the identified threat, the generated S B P / S A F , and the original use case flow. In such cases, the refinement may describe a plausible security action while remaining inconsistent with the corresponding threat mechanism or the control-flow logic of the original use case. Addressing such inconsistencies may require a tighter threat–defense–flow review-and-revision loop that jointly examines the anchored threat mechanism, proposed defense, and resulting flow behavior and revises the candidate when misalignment is detected.

6.8. External Qualitative Case Studies

To complement the benchmark-based evaluation and examine whether the proposed refinement approach can be applied beyond the OWASP and MITRE ATLAS cases, we conduct two external qualitative case studies. The first is derived from an external clinical task in MedAgentBench involving retrieval from an electronic health record system (EHR) and medication ordering [50]. The second concerns Replit, an AI-powered software development platform, and is reconstructed from its official description of a former workflow in which development activities and live customer data shared a single database [51]. The source materials are normalized into our functional-flow representation without adding target threats or security controls.
We compare MA-SAFR with MA-VanillaRAG using Qwen3.5-Plus, temperature 0.0, retrieval depth k = 3 , and five runs per setting. Because the cases do not provide reference threat records or S B P / S A F refinements, we perform qualitative analysis rather than compute benchmark metrics.
MedAgentBench case. The source task asks a clinical agent to retrieve a patient’s most recent serum magnesium observation within the preceding 24 h and, if the value is low, create an intravenous (IV) magnesium replacement order according to the supplied dosing instructions. We normalize the task into the following functional flow:
  • BF1, the clinician requests magnesium assessment and conditional IV magnesium replacement;
  • BF2, the clinical agent queries the EHR using the patient identifier and magnesium code;
  • BF3, the EHR returns the matching observations and their measurement times;
  • BF4, the clinical agent filters the observations to the preceding 24 h and selects the most recent eligible value;
  • BF5, the clinical agent classifies the deficiency severity;
  • BF6, the clinical agent selects the corresponding dose and infusion duration;
  • BF7, the clinical agent submits the active IV magnesium medication request;
  • BF8, the EHR creates the order and returns its status.
If no eligible observation is available or the selected value is not low, the task terminates without submitting an order.
Replit case. Replit reported that its former workflow used a single database for development activities and live customer data. We normalize the account into the following functional flow:
  • BF1, the user asks Replit Agent to modify a database-backed application;
  • BF2, Replit Agent changes the application code and database state during development;
  • BF3, Replit Agent previews and tests the updated application;
  • BF4, Replit Agent modifies during development the same database that stores live customer data;
  • BF5, the user requests deployment;
  • BF6, Replit deploys the updated application using the same database;
  • BF7, the live application continues to read and write customer data in that database.
Table 13 presents one representative schema-valid output from a repeatedly observed threat theme for each case and setting. The threat records and refinements are condensed for readability without changing their security intent.
Table 13 highlights three differences between the two methods. First, graph-based retrieval leads MA-SAFR to follow explicit risk–mitigation relations and produce specific, traceable controls, such as medication-order authorization and destructive database-operation checks. Flat semantic retrieval allows MA-VanillaRAG to make broader inferences; however, the resulting threat, S B P , and S A F may be only loosely connected. In the medical case, the threat detected by MA-VanillaRAG concerns an incorrect severity classification, whereas the S B P merely exposes the selected value without specifying the verification criterion, and the S A F invokes a mismatch without defining how it is detected or corrected.
Second, although both methods employ Red and Blue agents, MA-SAFR maintains a clearer separation between diagnostic threats and prescriptive refinements. In the medical case, MA-VanillaRAG places the recommendation for comprehensive data validation inside the Red-Agent threat record, whereas such prescriptive content should be produced by the Blue Agent.
Third, the RSSG constraints in MA-SAFR keep its S B P / S A F refinements close to the affected flow step and provide explicit blocking, correction, and re-entry behavior. Without these constraints, MA-VanillaRAG allows broader design changes. This flexibility can be beneficial, but it can also produce under-specified scope expansion. For example, in the Replit case, we observed that MA-VanillaRAG expanded a local refinement of the BF2 code-modification step into a system-level security redesign by introducing an external guardrail service to scan generated code for broadly defined malicious patterns and prompt-injection artifacts, without specifying concrete detection criteria.
For requirements engineers, each of the above threat anchors and S B P / S A F pairs translates an implicit security omission into a reviewable candidate change at the corresponding flow step and provides concrete guidance for specifying preventive and failure-handling behavior.
However, the effectiveness of MA-SAFR is influenced by the coverage and domain relevance of its security knowledge graph. When domain-specific knowledge is limited, graph retrieval may overemphasize generic agent-security patterns and produce precise, traceable controls that do not fully address the domain-specific root cause. For example, in another MedAgentBench run, MA-SAFR applied a generally valid agent-security data-minimization control but masked partial timestamps required by the clinical task.

7. Threats to Validity

7.1. External Validity

Threats to external validity arise mainly from two aspects. First, SAFR-Bench comprises 157 cases and 235 threat records derived from the OWASP LLM Top 10 2025 and MITRE ATLAS v5.5.0, providing source-level breadth across heterogeneous LLM application risks and attack scenarios. However, its requirement descriptions and use case flows are reconstructed artifacts and may underrepresent the ambiguity, incompleteness, domain terminology, and organizational context of real requirements. Although the external qualitative case studies in Section 6.8 extend the evaluation beyond SAFR-Bench, they only partially alleviate this limitation, as their limited scale cannot establish broad generalizability across application domains and requirement styles.
Second, experimental generalizability is affected by model coverage and dependence on external security knowledge. The experiments cover three representative LLMs, and improvements across these evaluated models yield preliminary evidence of cross-model generalizability. However, the results may not generalize to other proprietary models, smaller open-source models, future model versions, or different decoding configurations. In addition, EvoGraphRAG is sensitive to the coverage and structure of its external security knowledge graph; changes in knowledge sources, graph construction, relation schemas, or risk taxonomies may affect retrieval and downstream refinement. Although SAFR-Bench and the external security knowledge used for retrieval are both derived from OWASP and MITRE ATLAS, the retrieval corpus excludes benchmark-specific threat records and anchor labels, reference S B P / S A F refinements, evaluation labels, and test-set validation feedback, avoiding direct overlap with the reference outputs. Future work will further evaluate MA-SAFR on more diverse requirement datasets from additional application domains and extend SAFR-Bench to cover broader security risks and emerging attack scenarios.

7.2. Internal Validity

Threats to internal validity first arise from LLM generation variability and potential confounding among comparison settings. LLM outputs are sensitive to prompt design and may vary across repeated runs even under identical inputs. To mitigate this threat, we kept the prompt templates fixed within each setting and set the temperature to 0.0 for all generation models. To further reduce run-specific variation, we report results averaged over five independent runs. All methods were evaluated using consistent generation and judging settings. In particular, MA-VanillaRAG and EvoGraphRAG used the same external security knowledge corpus and retrieval depth, while the RQ2 RSSG ablation and the RQ3 controlled edge-weight comparison varied only the target component with the remaining pipeline fixed.
A second concern is potential bias in LLM-based evaluation. Prior work has demonstrated the effectiveness of LLM-as-a-judge [52]. We further validated our judging protocol through an independent human assessment, obtaining Cohen’s κ values of 0.767 for threat matching and 0.633 for defense validity. In addition, we used Qwen3.5-Flash, which was not among the three evaluated generation models, as the fixed judge for all methods. These results support the reliability of the judging protocol, although uncertainty remains for complex defense-validity decisions, as discussed in Section 6.6.
Benchmark construction represents another potential source of internal bias. Scenario rewriting, flow parsing, threat-record construction, and S B P / S A F annotation involve human judgment and may therefore introduce annotation bias. We mitigated this risk through source grounding, a unified annotation schema, cross-layer consistency checks, and expert review of 60 randomly selected cases by 5 experienced engineers. Nevertheless, because only a subset of SAFR-Bench was reviewed, annotation errors may remain in the unreviewed cases. Future work will extend expert review to the full benchmark and incorporate additional independent reviewers and adjudication to further reduce residual annotation bias.

7.3. Construct Validity

Threats to construct validity mainly concern how valid threats, valid defenses, and refinement quality are operationalized. A predicted threat is considered valid only when it matches a reference threat with respect to both its anchor step and security concern. Retaining the canonical primary anchor strengthens flow-level traceability and keeps comparisons consistent, but may undercount predictions with plausible alternative anchors or reasonable formulations at different levels of abstraction. Similarly, an end-to-end defense is considered valid only if the corresponding threat is matched, the generated S B P / S A F pair covers the reference defense intent, the S B P is appropriately placed, and the S A F specifies concrete handling. Although aligned with Security-Augmented Use Case Flow Refinement Task, this definition may not capture global policies, architectural constraints, or runtime guardrails. The Critic Agent evaluates five dimensions: threat validity checks whether an omission is security-relevant and grounded in the flow; defense coverage assesses whether the refinement mitigates the threat mechanism; threat-defense traceability links the threat, S B P , and S A F ; branch closure requires a complete continuation or termination path; and flow consistency preserves the original functional intent. For quantitative evaluation, we use three complementary metrics: threat-validity recall measures threat coverage; pipeline recall measures successful threat-to-defense conversion; pipeline precision accounts for invalid over-generation. However, these task-level measures do not directly assess real-world attack resistance, output readability, engineering adoptability, implementation and maintenance costs, or user-experience impact. Within the scope of Security-Augmented Use Case Flow Refinement Task, the evaluation metrics operationalize key aspects of the validation dimensions for flow-level security refinement.

8. Conclusions and Future Work

This paper formulated the Security-Augmented Use Case Flow Refinement Task, which aims to transform security omissions implicit in the functional use case flows of LLM-enabled agentic systems into traceable and actionable security refinements. To address this task, MA-SAFR coordinates three specialized agents: a Red Team Agent for threat anchoring, a Blue Team Agent for S B P / S A F construction, and a Critic Agent for refinement validation. The framework combines EvoGraphRAG for relation-aware retrieval and feedback-based graph evolution with the RSSG layer, which provides risk- and role-specific guidance for grounding threats and constructing S B P / S A F refinements. The SAFR-Bench supports the systematic evaluation of threat discovery, threat anchoring, and end-to-end security-augmented use case flow refinement.
Across the three evaluated generation models, MA-SAFR achieved the strongest end-to-end refinement performance among the compared settings, indicating the comparative benefit of the complete framework under the evaluated settings. The controlled RSSG comparison shows that RSSG consistently improves the conversion of identified threats into valid S B P / S A F refinements. The controlled edge-weight comparison further shows that feedback-based edge-weight updates consistently improve downstream threat-to-defense conversion, although their effect on threat discovery varies across models. The sensitivity analysis shows that the default edge-weight update configuration achieves the highest observed performance among the tested settings, while the computational-cost analysis characterizes the online generation overhead and the two external qualitative cases provide preliminary evidence of applicability beyond SAFR-Bench. The failure analysis highlights three remaining challenges: identifying security omissions implicit in functional behavior, covering all security omissions in multi-threat cases, and maintaining semantic alignment among identified threats, generated defenses, and the original flow.
Future work will investigate three complementary directions across more diverse application domains: multi-pass flow-to-threat reasoning to reduce missed threats; coverage-aware refinement for multi-threat and attack-chain scenarios by modeling threat dependencies, attack propagation paths, and residual risks; and tighter threat–defense–flow review and revision to reduce semantic misalignment.

Author Contributions

Conceptualization, G.W., J.W. and Z.S.; methodology, G.W. and B.L.; software, G.W. and B.L.; validation, G.W., B.L. and Z.S.; formal analysis, G.W. and B.L.; investigation, G.W.; resources, G.W. and J.W.; data curation, G.W.; writing—original draft preparation, G.W.; writing—review and editing, B.L. and J.W.; visualization, G.W.; supervision, J.W.; project administration, G.W. and B.L.; funding acquisition, J.W. All authors have read and agreed to the published version of the manuscript.

Funding

This research was supported in part by the Engineering Research Center of Integration and Application of Digital Learning Technology, Ministry of Education under Grant 1431005.

Data Availability Statement

The full prompts, scripts, benchmark data, and experimental artifacts are available in the public replication package at https://github.com/WGYbuaa/MA-SAFR (accessed on 15 July 2026).

Conflicts of Interest

Author Guangyu Wang was employed by the company Xi’an Aeronautics Computing Technique Research Institute. The remaining authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

References

  1. Wang, L.; Ma, C.; Feng, X.; Zhang, Z.; Yang, H.; Zhang, J.; Chen, Z.; Tang, J.; Chen, X.; Lin, Y.; et al. A survey on large language model based autonomous agents. Front. Comput. Sci. 2024, 18, 186345. [Google Scholar] [CrossRef] [Scilit]
  2. Zhou, S.; Xu, F.F.; Zhu, H.; Zhou, X.; Lo, R.; Sridhar, A.; Cheng, X.; Ou, T.; Bisk, Y.; Fried, D.; et al. Webarena: A realistic web environment for building autonomous agents. In Proceedings of the International Conference on Learning Representations 2024 (ICLR 2024), Vienna, Austria, 7–11 May 2024; pp. 15585–15606. [Google Scholar]
  3. Schick, T.; Dwivedi-Yu, J.; Dessì, R.; Raileanu, R.; Lomeli, M.; Hambro, E.; Zettlemoyer, L.; Cancedda, N.; Scialom, T. Toolformer: Language models can teach themselves to use tools. Adv. Neural Inf. Process. Syst. 2023, 36, 68539–68551. [Google Scholar] [CrossRef] [Scilit]
  4. Yao, S.; Zhao, J.; Yu, D.; Du, N.; Shafran, I.; Narasimhan, K.; Cao, Y. React: Synergizing reasoning and acting in language models. arXiv 2022, arXiv:2210.03629. [Google Scholar]
  5. Debenedetti, E.; Zhang, J.; Balunovic, M.; Beurer-Kellner, L.; Fischer, M.; Tramèr, F. Agentdojo: A dynamic environment to evaluate prompt injection attacks and defenses for llm agents. Adv. Neural Inf. Process. Syst. 2024, 37, 82895–82920. [Google Scholar] [CrossRef] [Scilit]
  6. Greshake, K.; Abdelnabi, S.; Mishra, S.; Endres, C.; Holz, T.; Fritz, M. Not what you’ve signed up for: Compromising real-world LLM-integrated applications with indirect prompt injection. In Proceedings of the 16th ACM Workshop on Artificial Intelligence and Security; Association for Computing Machinery: New York, NY, USA, 2023; pp. 79–90. [Google Scholar]
  7. Ruan, Y.; Dong, H.; Wang, A.; Pitis, S.; Zhou, Y.; Ba, J.; Dubois, Y.; Maddison, C.; Hashimoto, T. Identifying the risks of lm agents with an lm-emulated sandbox. In Proceedings of the International Conference on Learning Representations 2024 (ICLR 2024), Vienna, Austria, 7–11 May 2024; pp. 27031–27098. [Google Scholar]
  8. Zhang, H.; Huang, J.; Mei, K.; Yao, Y.; Wang, Z.; Zhan, C.; Wang, H.; Zhang, Y. Agent security bench (asb): Formalizing and benchmarking attacks and defenses in LLM-based agents. In Proceedings of the International Conference on Learning Representations 2025 (ICLR 2025), Singapore, 24–28 April 2025; pp. 35331–35366. [Google Scholar]
  9. Sindre, G.; Opdahl, A.L. Eliciting security requirements with misuse cases. Requir. Eng. 2005, 10, 34–44. [Google Scholar] [CrossRef] [Scilit]
  10. Haley, C.; Laney, R.; Moffett, J.; Nuseibeh, B. Security requirements engineering: A framework for representation and analysis. IEEE Trans. Softw. Eng. 2008, 34, 133–153. [Google Scholar] [CrossRef] [Scilit]
  11. Wang, G.; Li, B.; Wu, J.; Shao, Z. BFGen: Basic Flow Generation for Refining Requirements via LLM and Relational Graph Attention Networks. In Proceedings of the 2025 25th International Conference on Software Quality, Reliability and Security (QRS); IEEE: Piscataway, NJ, USA, 2025; pp. 120–131. [Google Scholar]
  12. Shostack, A. Experiences Threat Modeling at Microsoft. MODSEC@ MoDELS 2008, 2008, 35. [Google Scholar]
  13. Mai, P.X.; Goknil, A.; Shar, L.K.; Pastore, F.; Briand, L.C.; Shaame, S. Modeling security and privacy requirements: A use case-driven approach. Inf. Softw. Technol. 2018, 100, 165–182. [Google Scholar] [CrossRef] [Scilit]
  14. Lian, X.; Wang, S.; Zou, H.; Liu, F.; Wu, J.; Zhang, L. Incorporating verification standards for security requirements generation from functional specifications. Proc. ACM Softw. Eng. 2025, 2, 1710–1732. [Google Scholar] [CrossRef] [Scilit]
  15. Perez, E.; Huang, S.; Song, F.; Cai, T.; Ring, R.; Aslanides, J.; Glaese, A.; McAleese, N.; Irving, G. Red teaming language models with language models. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing; Association for Computational Linguistics: Abu Dhabi, United Arab Emirates, 2022; pp. 3419–3448. [Google Scholar]
  16. Zhao, L.; Alhoshan, W.; Ferrari, A.; Letsholo, K.J.; Ajagbe, M.A.; Chioasca, E.V.; Batista-Navarro, R.T. Natural language processing for requirements engineering: A systematic mapping study. ACM Comput. Surv. (CSUR) 2021, 54, 55. [Google Scholar]
  17. Wang, G.; Wu, J.; Yang, H.; Sun, Q.; Yue, T. Test architecture generation by leveraging BERT and control and data flows. In Proceedings of the International Conference on Engineering of Complex Computer Systems; Springer: Cham, Switzerland, 2024; pp. 125–145. [Google Scholar]
  18. Souag, A.; Mazo, R.; Salinesi, C.; Comyn-Wattiau, I. Reusable knowledge in security requirements engineering: A systematic mapping study. Requir. Eng. 2016, 21, 251–283. [Google Scholar] [CrossRef] [Scilit]
  19. Ansari, M.T.J.; Pandey, D.; Alenezi, M. STORE: Security threat oriented requirements engineering methodology. J. King Saud Univ.-Comput. Inf. Sci. 2022, 34, 191–203. [Google Scholar] [CrossRef] [Scilit]
  20. Rouland, Q.; Hamid, B.; Jaskolka, J. Specification, detection, and treatment of STRIDE threats for software components: Modeling, formal methods, and tool support. J. Syst. Archit. 2021, 117, 102073. [Google Scholar] [CrossRef] [Scilit]
  21. Van Landuyt, D.; Mollaeefar, M.; Raciti, M.; Verreydt, S.; Kalash, A.; Bissoli, A.; Preuveneers, D.; Bella, G.; Ranise, S. A comparative benchmark study of LLM-based threat elicitation tools. Future Gener. Comput. Syst. 2026, 177, 108243. [Google Scholar] [CrossRef] [Scilit]
  22. Shahid, W.B.; Naqvi, B.; Afzal, H. LLMPathy: A Multi-Agent LLM Approach for Eliciting Inclusive Security Requirements. In Proceedings of the 2025 IEEE 33rd International Requirements Engineering Conference Workshops (REW); IEEE: Piscataway, NJ, USA, 2025; pp. 243–248. [Google Scholar]
  23. Shinn, N.; Cassano, F.; Gopinath, A.; Narasimhan, K.; Yao, S. Reflexion: Language agents with verbal reinforcement learning. Adv. Neural Inf. Process. Syst. 2023, 36, 8634–8652. [Google Scholar] [CrossRef] [Scilit]
  24. Madaan, A.; Tandon, N.; Gupta, P.; Hallinan, S.; Gao, L.; Wiegreffe, S.; Alon, U.; Dziri, N.; Prabhumoye, S.; Yang, Y.; et al. Self-refine: Iterative refinement with self-feedback. Adv. Neural Inf. Process. Syst. 2023, 36, 46534–46594. [Google Scholar] [CrossRef] [Scilit]
  25. Gou, Z.; Shao, Z.; Gong, Y.; Shen, Y.; Yang, Y.; Duan, N.; Chen, W. Critic: Large language models can self-correct with tool-interactive critiquing. In Proceedings of the International Conference on Learning Representations 2024 (ICLR 2024), Vienna, Austria, 7–11 May 2024; pp. 57734–57811. [Google Scholar]
  26. Hong, S.; Zhuge, M.; Chen, J.; Zheng, X.; Cheng, Y.; Wang, J.; Zhang, C.; Yau, S.; Lin, Z.; Zhou, L.; et al. MetaGPT: Meta programming for a multi-agent collaborative framework. In Proceedings of the International Conference on Learning Representations 2024 (ICLR 2024), Vienna, Austria, 7–11 May 2024; pp. 23247–23275. [Google Scholar]
  27. Qian, C.; Liu, W.; Liu, H.; Chen, N.; Dang, Y.; Li, J.; Yang, C.; Chen, W.; Su, Y.; Cong, X.; et al. Chatdev: Communicative agents for software development. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Bangkok, Thailand, 11–16 August 2024; pp. 15174–15186. [Google Scholar]
  28. Yu, X.; Torbunov, D.; Mandal, S.; Ren, Y. AutoSizer: Automatic Sizing of Analog and Mixed-Signal Circuits via Large Language Model (LLM) Agents. arXiv 2026, arXiv:2602.02849. [Google Scholar]
  29. Gehman, S.; Gururangan, S.; Sap, M.; Choi, Y.; Smith, N.A. Realtoxicityprompts: Evaluating neural toxic degeneration in language models. In Proceedings of the Findings of the Association for Computational Linguistics: EMNLP 2020, Online, 16–20 November 2020; pp. 3356–3369. [Google Scholar]
  30. Hartvigsen, T.; Gabriel, S.; Palangi, H.; Sap, M.; Ray, D.; Kamar, E. Toxigen: A large-scale machine-generated dataset for adversarial and implicit hate speech detection. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Dublin, Ireland, 22–27 May 2022; pp. 3309–3326. [Google Scholar]
  31. Wang, B.; Chen, W.; Pei, H.; Xie, C.; Kang, M.; Zhang, C.; Xu, C.; Xiong, Z.; Dutta, R.; Schaeffer, R.; et al. DecodingTrust: A Comprehensive Assessment of Trustworthiness in {GPT} Models. In Proceedings of the 37th Conference on Neural Information Processing Systems (NeurIPS 2023) Track on Datasets and Benchmarks, New Orleans, LA, USA, 10–16 December 2023. [Google Scholar]
  32. Mazeika, M.; Phan, L.; Yin, X.; Zou, A.; Wang, Z.; Mu, N.; Sakhaee, E.; Li, N.; Basart, S.; Li, B.; et al. HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusal. In Proceedings of the 41st International Conference on Machine Learning; Salakhutdinov, R., Kolter, Z., Heller, K., Weller, A., Oliver, N., Scarlett, J., Berkenkamp, F., Eds.; PMLR (Proceedings of Machine Learning Research): Cambridge, MA, USA, 2024; Volume 235, pp. 35181–35224. [Google Scholar]
  33. OWASP Gen AI Security Project. OWASP Top 10 for LLM Applications 2025. 2024. Available online: https://genai.owasp.org/resource/owasp-top-10-for-llm-applications-2025/ (accessed on 9 July 2026).
  34. The MITRE Corporation. MITRE ATLAS v5.5.0; The MITRE Corporation: McLean, VA, USA, 2026. [Google Scholar]
  35. Lewis, P.; Perez, E.; Piktus, A.; Petroni, F.; Karpukhin, V.; Goyal, N.; Küttler, H.; Lewis, M.; Yih, W.t.; Rocktäschel, T.; et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Adv. Neural Inf. Process. Syst. 2020, 33, 9459–9474. [Google Scholar]
  36. Zhu, X.; Xie, Y.; Liu, Y.; Li, Y.; Hu, W. Knowledge graph-guided retrieval augmented generation. In Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), Albuquerque, NM, USA, 29 April–4 May 2025; pp. 8912–8924. [Google Scholar]
  37. He, X.; Tian, Y.; Sun, Y.; Chawla, N.V.; Laurent, T.; LeCun, Y.; Bresson, X.; Hooi, B. G-retriever: Retrieval-augmented generation for textual graph understanding and question answering. Adv. Neural Inf. Process. Syst. 2024, 37, 132876–132907. [Google Scholar] [CrossRef] [Scilit]
  38. Sikos, L.F. Cybersecurity knowledge graphs. Knowl. Inf. Syst. 2023, 65, 3511–3531. [Google Scholar] [CrossRef] [Scilit]
  39. Jiang, Z.; Xu, F.F.; Gao, L.; Sun, Z.; Liu, Q.; Dwivedi-Yu, J.; Yang, Y.; Callan, J.; Neubig, G. Active retrieval augmented generation. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing; Association for Computational Linguistics: Singapore, 2023; pp. 7969–7992. [Google Scholar]
  40. Jeong, S.; Baek, J.; Cho, S.; Hwang, S.J.; Park, J.C. Adaptive-rag: Learning to adapt retrieval-augmented large language models through question complexity. In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 1: Long Papers), Mexico City, Mexico, 16–21 June 2024; pp. 7036–7050. [Google Scholar]
  41. Asai, A.; Wu, Z.; Wang, Y.; Sil, A.; Hajishirzi, H. Self-rag: Learning to retrieve, generate, and critique through self-reflection. In Proceedings of the International Conference on Learning Representations 2024 (ICLR 2024), Vienna, Austria, 7–11 May 2024; pp. 9112–9141. [Google Scholar]
  42. Bhatt, M.; Chennabasappa, S.; Nikolaidis, C.; Wan, S.; Evtimov, I.; Gabi, D.; Song, D.; Ahmad, F.; Aschermann, C.; Fontana, L.; et al. Purple llama cyberseceval: A secure coding benchmark for language models. arXiv 2023, arXiv:2312.04724. [Google Scholar]
  43. Qwen Team. Qwen3.5: Towards Native Multimodal Agents. 2026. Available online: https://qwen.ai/blog?id=qwen3.5 (accessed on 30 July 2026).
  44. Liu, A.; Mei, A.; Lin, B.; Xue, B.; Wang, B.; Xu, B.; Wu, B.; Zhang, B.; Lin, C.; Dong, C.; et al. Deepseek-v3. 2: Pushing the frontier of open large language models. arXiv 2025, arXiv:2512.02556. [Google Scholar]
  45. OpenAI. Introducing GPT-5.2. 2025. Available online: https://openai.com/index/introducing-gpt-5-2/ (accessed on 8 July 2026).
  46. Artstein, R.; Poesio, M. Survey Article: Inter-Coder Agreement for Computational Linguistics. Comput. Linguist. 2008, 34, 555–596. [Google Scholar] [CrossRef] [Scilit]
  47. Zheng, L.; Yin, L.; Xie, Z.; Sun, C.; Huang, J.; Yu, C.H.; Cao, S.; Kozyrakis, C.; Stoica, I.; Gonzalez, J.E.; et al. Sglang: Efficient execution of structured language model programs. Adv. Neural Inf. Process. Syst. 2024, 37, 62557–62583. [Google Scholar] [CrossRef] [Scilit]
  48. Xu, F.; Shi, W.; Choi, E. RECOMP: Improving retrieval-augmented LMs with context compression and selective augmentation. In Proceedings of the International Conference on Learning Representations 2024 (ICLR 2024), Vienna, Austria, 7–11 May 2024; pp. 43478–43502. [Google Scholar]
  49. Jiang, H.; Wu, Q.; Lin, C.Y.; Yang, Y.; Qiu, L. Llmlingua: Compressing prompts for accelerated inference of large language models. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing; Association for Computational Linguistics: Singapore, 2023; pp. 13358–13376. [Google Scholar]
  50. Jiang, Y.; Black, K.C.; Geng, G.; Park, D.; Zou, J.; Ng, A.Y.; Chen, J.H. MedAgentBench: A virtual EHR environment to benchmark medical LLM agents. NEJM AI 2025, 2, AIdbp2500144. [Google Scholar] [CrossRef] [Scilit]
  51. The Replit Team. Introducing a Safer Way to Vibe Code with Replit Databases. 2025. Available online: https://replit.com/blog/introducing-a-safer-way-to-vibe-code-with-replit-databases (accessed on 23 August 2026).
  52. Li, Y.; Ji, Y.; Chen, X.; Shen, Z.; Ge, J.; Luo, B. FURINA: A Multi-Agent Framework for Automated Patch Correctness Assessment. ACM Trans. Softw. Eng. Methodol. 2026, accepted. [Google Scholar] [CrossRef] [Scilit]
Figure 1. A simplified example adapted from SAFR-Bench case UC0125. The original functional flow describes a GenAI email assistant (labeled “Asst.”) that generates context-aware replies. The security-augmented refinements insert S B P s and add corresponding S A F s for handling detected prompt-injection and sensitive-data leakage conditions.
Figure 1. A simplified example adapted from SAFR-Bench case UC0125. The original functional flow describes a GenAI email assistant (labeled “Asst.”) that generates context-aware replies. The security-augmented refinements insert S B P s and add corresponding S A F s for handling detected prompt-injection and sensitive-data leakage conditions.
Electronics 15 04135 g001
Figure 2. Overview of MA-SAFR.
Figure 2. Overview of MA-SAFR.
Electronics 15 04135 g002
Table 1. Prompt structure of the Red Team Agent.
Table 1. Prompt structure of the Red Team Agent.
ComponentDescription
Task SpecificationDefines the role of the Red Team Agent, the security-omission identification objective, and the strict threat-record output interface.
InputProvides the original functional use case flow as the primary evidence for threat identification.
Retrieved KnowledgeProvides retrieved security evidence from the knowledge base to refine threat mechanisms and impacts.
RSSG GuidanceSupplies risk-specific rules for threat coverage, duplicate merging, and anchor-step selection (Section 4.3).
Table 2. Prompt structure of the Blue Team Agent.
Table 2. Prompt structure of the Blue Team Agent.
ComponentDescription
Task SpecificationDefines the role of the Blue Team Agent, the flow-completion objective, and the strict S B P / S A F output interface.
InputProvides the original functional use case flow together with one threat record, including its anchored step, threat mechanism, and security impact.
Retrieved KnowledgeProvides retrieved security evidence from the knowledge base to support mitigation selection and defense formulation.
RSSG GuidanceSupplies risk-specific rules for S B P placement, S A F trigger specification, security-handling logic, and branch closure (Section 4.3).
Table 3. Prompt structure of the Critic Agent.
Table 3. Prompt structure of the Critic Agent.
ComponentDescription
Task SpecificationDefines the role of the Critic Agent, the refinement-validation objective, and the structured validation output interface.
InputProvides the original functional use case flow, the threat records generated by the Red Team Agent, and the S B P / S A F refinements generated by the Blue Team Agent.
Validation CriteriaChecks threat validity, defense coverage, threat-defense traceability, branch closure, and flow consistency, with concise reasons for detected issues.
Table 4. Examples of RSSG guidance.
Table 4. Examples of RSSG guidance.
Risk TypeRed Team GuidanceBlue Team Guidance
Prompt injectionAnchor to the step where untrusted instructions, documents, prompts, or directives first enter the system.Insert an S B P before the model follows the untrusted content; the S A F flags injected instructions, requires revision or removal, and returns to the protected step.
Sensitive information disclosureAnchor to the step where sensitive data is read for an unauthorized context or crosses a trust boundary.Insert an S B P before disclosure; the S A F redacts, minimizes, or restricts the sensitive data and resumes the protected flow when safe.
Excessive agency or tool misuseAnchor to the step where the system invokes a tool, changes state, sends messages, or crosses a permission boundary.Insert an S B P before the high-risk action; the S A F requires scoped authorization, constrains the action, or terminates the unsafe operation.
Table 5. Schema of SAFR-Bench.
Table 5. Schema of SAFR-Bench.
LayerArtifactFields
Requirement DescriptionCase metadata and source textuse_case_id; dataset;
source_knowledge_id; source_requirement_text
Functional Use Case FlowUse case flow stepstep_id; step_sentence;
subject; verb; object; flow_from
Threat RecordsThreat recorduse_case_id; threat_id; threat_name;
anchor_steps; threat_mechanism; security_impact;
source_knowledge_id; source_evidence
Security-Augmented Use Case FlowSecurity branch point (SBP)step_id; anchor; step_sentence
Security-augmented alternative flow (SAF)saf_id; mitigates; entry_condition;
source_evidence; SAF_steps
SAF stepstep_id; step_sentence
Table 6. Overview of SAFR-Bench.
Table 6. Overview of SAFR-Bench.
StatisticValue
Number of cases157
Source distribution100 OWASP-derived cases and 57 MITRE-ATLAS-derived cases
Data split80 training, 20 development, and 57 test cases
Use case flow steps855 in total; 5.45 per case on average
Threat records235 in total; 1.50 per case on average
S B P / S A F refinement pairs235 in total; 1.50 per case on average
Table 7. Comparative results of MA-SAFR and baseline settings for security-augmented use case flow refinement (RQ1): threat-validity recall, pipeline recall, and pipeline precision. Values are reported as mean ± sample standard deviation over five independent runs. Bold indicates the best results for each model. The Improvement rows report relative changes from the strongest non-MA-SAFR baseline for each model and metric.
Table 7. Comparative results of MA-SAFR and baseline settings for security-augmented use case flow refinement (RQ1): threat-validity recall, pipeline recall, and pipeline precision. Values are reported as mean ± sample standard deviation over five independent runs. Bold indicates the best results for each model. The Improvement rows report relative changes from the strongest non-MA-SAFR baseline for each model and metric.
ModelSetting R threat R pipe P pipe
Qwen3.5-PlusSA-NoRAG(17.28 ± 2.90)%(6.17 ± 2.47)%(6.17 ± 1.81)%
MA-NoRAG(20.99 ± 2.76)%(12.35 ± 1.95)%( 8.77 ± 1.04)%
MA-VanillaRAG(25.93 ± 1.75)%(11.11 ± 1.51)%(10.59 ± 1.82)%
MA-SAFR(34.57 ± 1.23)%(29.63 ± 1.51)%(21.82 ± 1.94)%
Improvement+33.33%+140.00%+106.06%
DeepSeek-V3.2SA-NoRAG(28.40 ± 1.95)%(1.23 ± 1.75)%(0.52 ± 0.75)%
MA-NoRAG(30.86 ± 3.15)%(8.64 ± 3.38)%(3.04 ± 1.10)%
MA-VanillaRAG(37.04 ± 2.76)%(11.11 ± 1.95)%(8.26 ± 1.80)%
MA-SAFR(23.46 ± 2.31)%(16.05 ± 1.51)%(11.82 ± 1.66)%
Improvement−36.67%+44.44%+43.13%
GPT-5.2SA-NoRAG(24.05 ± 2.00)%(12.66 ± 2.37)%(4.37 ± 1.05)%
MA-NoRAG(25.32 ± 2.83)%(17.72 ± 2.97)%(6.25 ± 1.46)%
MA-VanillaRAG(29.11 ± 1.79)%(21.52 ± 2.69)%(7.59 ± 1.26)%
MA-SAFR(31.65 ± 1.27)%(22.78 ± 0.90)%(8.78 ± 0.71)%
Improvement+8.70%+5.88%+15.70%
Table 8. Relative effect of RSSG on MA-SAFR compared with the without-RSSG setting (RQ2). Values are relative changes (%).
Table 8. Relative effect of RSSG on MA-SAFR compared with the without-RSSG setting (RQ2). Values are relative changes (%).
Model Δ rel R threat Δ rel R pipe Δ rel P pipe
Qwen3.5-Plus+16.67%+26.32%+32.06%
DeepSeek-V3.2−26.92%+18.18%+52.56%
GPT-5.2+8.57%+14.81%+17.84%
Table 9. Effect of feedback-based edge-weight updates in EvoGraphRAG (RQ3). Values are relative changes (%).
Table 9. Effect of feedback-based edge-weight updates in EvoGraphRAG (RQ3). Values are relative changes (%).
Model Δ rel R threat Δ rel R pipe Δ rel P pipe
Qwen3.5-Plus+16.67%+9.09%+11.07%
DeepSeek-V3.20.00%+6.67%+11.30%
GPT-5.2+6.06%+7.41%+6.25%
Table 10. Parameter sensitivity of EvoGraphRAG’s edge-weight update (%).
Table 10. Parameter sensitivity of EvoGraphRAG’s edge-weight update (%).
IDVaried Parameter η w min w max R threat R pipe P pipe
E1 η 0.040.353.0 30.86 25.43 18.41
E2Default0.080.353.0 34.57 29.63 21.82
E3 η 0.160.353.0 29.88 24.20 16.98
E4 w min 0.081.003.0 31.11 23.70 16.73
E5 w max 0.080.351.0 31.11 26.17 19.30
Table 11. Average LLM-generation cost of the comparison settings using Qwen3.5-Plus.
Table 11. Average LLM-generation cost of the comparison settings using Qwen3.5-Plus.
SettingInput Tokens per CaseOutput Tokens per CaseTotal Tokens per CaseLLM-Generation Time per Case (s)
SA-NoRAG886.63440.141326.778.546
MA-NoRAG866.33333.441199.776.847
MA-VanillaRAG2874.49318.823193.327.015
MA-SAFR5503.14443.335946.479.756
Table 12. Human validation results of LLM-based judging.
Table 12. Human validation results of LLM-based judging.
Judging TasknAgreementDisagreementPercent AgreementCohen’s κ
Threat matching6053788.33%0.767
Defense validity60491181.67%0.633
Table 13. Representative threat records and security-flow refinements for the external qualitative cases.
Table 13. Representative threat records and security-flow refinements for the external qualitative cases.
Case and SettingThreat RecordGenerated SBP / SAF Refinement
MedAgentBench MA-SAFRExcessive agency in automated medication ordering, anchored at BF7. The clinical agent can directly submit an active IV medication order without an independent authorization or safety boundary.SBP: Before BF7, validate the proposed dose and infusion duration against approved safety limits and require clinician verification before submission. SAF: Block and quarantine an unsafe or unverified order, present its parameters and rationale to the clinician, and retry BF7 after confirmation or correction.
MedAgentBench MA-VanillaRAGIncorrect magnesium-deficiency classification, anchored at BF5. An erroneous severity classification can cause an inappropriate dose and medication order; therefore, the data should be comprehensively validated to prevent such errors.SBP: Before BF5, expose the selected value for verification. SAF: Halt the workflow when a mismatch is detected, and continue to BF6 after correction.
Replit MA-SAFRLive-data corruption through development changes, anchored at BF4. Agent-generated database operations can be applied directly to the database containing live customer data.SBP: Before BF4, validate database operations and block destructive commands such as unscoped deletion, truncation, or schema removal. SAF: Quarantine the unsafe operation, request a corrected change, revalidate it, and return to BF4 after the operation satisfies the safety policy.
Replit MA-VanillaRAGMalicious code injection via an untrusted user request, anchored at BF2. Hidden prompt-injection instructions in the initial request can cause Replit Agent to generate malicious code or execute unauthorized database commands during application modification.SBP: Before BF2, submit the proposed code and database changes to an external non-LLM guardrail that scans for malicious patterns, unauthorized database instructions, and prompt-injection artifacts. SAF: If suspicious instructions or database commands are detected, block the proposed changes, prevent the agent from accessing the development environment with the tainted context, alert the user, and require a revised clean request before the workflow can continue.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Wang, G.; Li, B.; Wu, J.; Shao, Z. Security-Augmented Use Case Flow Refinement for LLM-Based Agentic Systems. Electronics 2026, 15, 4135. https://doi.org/10.3390/electronics15184135

AMA Style

Wang G, Li B, Wu J, Shao Z. Security-Augmented Use Case Flow Refinement for LLM-Based Agentic Systems. Electronics. 2026; 15(18):4135. https://doi.org/10.3390/electronics15184135

Chicago/Turabian Style

Wang, Guangyu, Bangqi Li, Ji Wu, and Zhijun Shao. 2026. "Security-Augmented Use Case Flow Refinement for LLM-Based Agentic Systems" Electronics 15, no. 18: 4135. https://doi.org/10.3390/electronics15184135

APA Style

Wang, G., Li, B., Wu, J., & Shao, Z. (2026). Security-Augmented Use Case Flow Refinement for LLM-Based Agentic Systems. Electronics, 15(18), 4135. https://doi.org/10.3390/electronics15184135

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Article metric data becomes available approximately 24 hours after publication online.
Back to TopTop