arXiv(opens in a new tab)cs.CRSep 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2609.01487

Defense-as-Skill: Evolving Runtime Guard Skill for Skill-Augmented Agents

Xiaofang Yang, Ziqi Miao, Dianbo Sui, Jing Shao, Lijun Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Skill-augmented agents load reusable skills as persistent runtime context, improving task performance but also giving malicious skills a durable channel for steering future actions. Such skills may leak secrets, corrupt code, bypass approvals, or stage data for exfiltration only after a concrete user task and workspace state make the unsafe action appear useful. This makes pre-install vetting insufficient and calls for runtime, task-conditioned protection. We propose Defense-as-Skill, a defense paradigm that implements the runtime guard itself as an installable, inspectable, and editable skill. Our guard, SkillSonar, runs alongside untrusted task skills and checks sensitive actions against the user's task boundary, routing each action to an allow, replan, or confirmation decision without modifying the underlying agent runtime. To study this setting, we construct SCOPE-R, a task-conditioned dataset covering 6 risk families and 21 sub-categories, with 206 attack-confirmed malicious instances and 43 benign tasks. We then improve SkillSonar on the SCOPE-R training subset using runtime guard-skill evolution, a Monte-Carlo Tree Search procedure that evolves the on-disk guard skill from feedback on the rollouts. Across Claude Code and OpenClaw, the evolved guard substantially reduces attack success while maintaining a favorable safety–utility trade-off. On repeated GLM-5 runs, SkillSonar reduces ID ASR from 0.482 to 0.104 and OOD ASR from 0.606 to 0.115. Further analyses demonstrate transfer across victim models, held-out risk families, and external benchmarks, as well as retained protection against adaptive attackers. Ablations further show that explicit safety responsibility assignment and the skill-native representation are both important to the observed gains.

1 Introduction

Agents are increasingly moving from one-off tool-use loops toward systems that can load reusable skills: packaged instructions, scripts, resources, and workflow guidance that remain available throughout a task. Claude Code [2] and OpenClaw [17] are typical examples. We refer to this emerging class as skill-augmented agents (SAAs). Skills improve agent capabilities by packaging task-relevant instructions, knowledge, and workflows into reusable components that agents can load and follow during execution [27, 24]. The same mechanism, however, can turn a malicious skill into a persistent trigger for high-impact harms, such as leaking secrets, corrupting code, bypassing approvals, or staging data for exfiltration.

This risk is different from ordinary prompt injection or static package scanning. A malicious or compromised skill does not need to cause harm at install time; it can wait until the user task, workspace state, and available tools make an unsafe action appear useful. Pre-install vetting is therefore necessary but insufficient. As in Figure 1 (a), the critical failure often appears only after skill

Preprint.

Figure

Figure 1: Overview of runtime skill safety and SCOPE-R. (a) Runtime guarding after skill loading. After a skill is loaded, SkillSonar checks its induced tool-use actions at runtime, allowing safe actions while constraining, replanning, or confirming risky ones. (b) Dataset overview. SCOPE-R builds attack-confirmed skill risks from benign task–skill pairs.

loading, when a task-conditioned skill starts shaping concrete tool-use actions. The key question is whether each concrete action still serves the user's intended task, or whether a loaded skill has pushed the agent across a safety boundary. Prior works highlight both agent safety evaluation and skill-file vulnerabilities [3, 20, 13, 12], but many practical runtime defenses rely on external classifiers, hosted guard models, or platform-specific permission gates. Such defenses are often not deployable as ordinary skill artifacts, making them harder to inspect, edit, and transfer across SAAs workflows.

We propose Defense-as-Skill, which implements the runtime guard itself as an installable, inspectable, and editable skill. Our guard, SkillSonar, is installed and loaded like an ordinary skill, but is assigned a distinct safety responsibility through an explicit instruction requiring the agent to consult it before taking actions. Thus, our intended deployment setting does not assume that simply installing a safety skill is sufficient for the agent to discover and invoke it reliably. However, in our experiments, we find that, unlike ordinary capability skills that are used to directly solve the task, safety-related skills require such explicit invocation. Capability skills are typically semantically aligned with the user's request and can therefore be selected through ordinary task–skill matching; for example, a coding skill is naturally relevant to a code-modification task. In contrast, unsafe actions may arise within almost any task even when the task itself contains no explicit safety-related intent, making a safety skill easy to overlook if invocation depends only on semantic relevance. We therefore treat the explicit invocation instruction as part of the deployment setting: it assigns SkillSonar a persistent safety responsibility rather than serving merely as an experimental convenience. Rather than making a one-time judgment before a skill is loaded, SkillSonar checks proposed actions during execution, including tool calls, file operations, shell commands, data access, external side effects, and user-visible outputs. It then decides whether to allow the action, narrow or replan it, or request confirmation based on whether the action remains within the user's task boundary. Because the guard uses the same skill mechanism as the agent workflow, it can be inspected, edited, evolved, and deployed without modifying the underlying SAAs runtime.

Making the guard a skill also makes it measurable and improvable in the same runtime setting. To support both guard optimization and evaluation, we construct SCOPE-R, as shown in Figure 1(b), a task-conditioned safety dataset in which each instance pairs a benign user task, a loaded skill, and a risk annotation. Benign instances test whether the guard preserves task completion, while malicious instances test whether the skill induces unsafe behavior. SCOPE-R covers six runtime risk families: Specification Integrity, Capability Control, Operational Side Effects, Privacy & Data Flow, Execution Safety, and Resource & Reliability. To improve the guard, we introduce runtime guard-skill evolution, which treats each guard skill as an optimizable policy artifact: candidate guards are edited on disk, evaluated in concrete task–skill rollouts, and selected using attack success, task utility, confirmation burden, and token cost.

Our main contributions are as follows: (1) We introduce SCOPE-R, a dataset for SAA-targeted attacks. SCOPE-R organizes attacks into six top-level risk families and 21 sub-categories. Starting from benign task–skill pairs from PinchBench, an attack agent and judge agent loop rewrites skills until the attack succeeds against a victim agent or a budget is exhausted. We retain only attack-success-confirmed malicious instances, yielding 206 malicious instances and 43 benign tasks. (2) We implement SkillSonar, a concrete skill-native runtime guard that checks sensitive actions against the user's task boundary and maps each action to an allow, replan, or confirmation decision. It can run across SAAs workflows without modifying the underlying agent runtime. (3) We propose runtime guard-skill evolution algorithm, a Monte-Carlo Tree Search procedure that make the guard skill evolve through feedback from concrete rollouts. Across Claude Code and OpenClaw harnesses, SkillSonar reduces attack success while can preserve benign utility, maintain modest token overhead, and transfer to held-out OOD attacks.

References (24)