DyMalSkill Dynamic Malicious Skills in Agentic AI Tianhao Chen∗, Zhengyuan Jiang∗, Yuepeng Hu, Yebei Gou, Neil Zhenqiang Gong
arXiv:2606.16287v1 [cs.CR] 15 Jun 2026
Duke University
Abstract Skills are a key enabling component of agentic AI. While they enhance agents’ capabilities, they also introduce new attack surfaces. In this work, we investigate one such attack surface by demonstrating dynamic malicious skills. By embedding malicious instructions in natural-language documentation (e.g., SKILL.md), an attacker can induce an agent to dynamically inject malicious logic into an otherwise benign skill during execution. We evaluate this attack across agentic frameworks such as OpenHands and Claude Code, showing that dynamic malicious skills can successfully introduce a range of malicious behaviors at runtime with non-trivial success rates. To mitigate this vulnerability, we propose a system-level defense that prevents dynamic modification of skills using operating system kernel–enforced read-only mounts. Our evaluation demonstrates that this defense effectively blocks dynamic malicious skills while preserving the functionality of benign skills.
1
Introduction
The shift toward agentic AI marks a move from passive text generation to systems that can act autonomously, reason about goals, and interact with their environment [Yao et al., 2023, Wang et al., 2024, Yang et al., 2024, Jimenez et al., 2024]. A key part of this shift is the use of skills. These skills serve as the basis that allow agents to handle complex tasks and interact with external resources. However, such a capability is a double-edged sword: while skills greatly improve an agent’s capabilities, they also introduce new security and privacy risks. Specifically, since skills on platforms or marketplaces are often not carefully reviewed, they can become attractive targets for attackers. This can transform useful capabilities into unauthorized actions and lead to harmful outcomes. Prior work [Shi et al., 2026, Jia et al., 2026, Hu et al., 2026] has demonstrated static malicious skills in agentic AI, where attackers create skills with embedded malicious code and distribute them on platforms such as Skillsmp1 . When a user inadvertently installs such a skill and the agent executes it, it can introduce significant security and privacy risks, including exfiltration of sensitive data, compromise of agent integrity, and hijacking of computational resources. However, the malicious skills studied in existing work are static, meaning that their code already contains malicious implementations at the time of distribution on platforms or marketplaces. Such static malicious skills can potentially be detected and blocked by platforms through static code ∗ 1
Co-first authors with equal contributions. https://skillsmp.com/
1
Construction Stage SKILL.md
SKILL.md
SKILL.md
SKILL.md
Upload
Craft
SKILL.md Malicious Documentation
Benign Code
Attacker
Dynamic Malicious Skill
Skills Market User Download Skill
Inference Stage Query
Read
Modify
Execute
SKILL.md
User
AI Agent
Malicious Documentation
Benign Code
Malicious Code
Malicious Behaviors
Figure 1: Illustration of DyMalSkill. analysis, as explicitly malicious behaviors—such as deleting local files or transmitting sensitive information to external endpoints—can be identified. In this work, we introduce a new security threat to the agentic AI ecosystem, termed dynamic malicious skills. A dynamic malicious skill satisfies two key conditions: (1) the original code of the skill is benign at the time of distribution and prior to execution, and (2) the code is dynamically modified during execution to embed malicious behaviors, leading to security and privacy risks. As a result, static code analysis techniques are ineffective against such attacks, as the original code contains no explicit malicious intent. To realize this attack, we develop DyMalSkill, which injects carefully crafted malicious instructions into a skill’s documentation, such as SKILL.md, as illustrated in Figure 1. Specifically, the attacker strategically designs both the content and placement of the injected instructions so that, when the agent invokes the skill, it dynamically modifies the code according to these instructions. This results in malicious behaviors that compromise security and privacy during execution. To assess the effectiveness and potential impact of dynamic malicious skills, we evaluate DyMalSkill on two state-of-the-art agentic coding frameworks, OpenHands [Wang et al., 2025] and Claude Code [Anthropic, 2026], as well as five backbone LLMs across 12 types of malicious behaviors. The results show that DyMalSkill achieves a high attack success rate (ASR) across a wide range of scenarios and settings, highlighting the severity of this threat and the urgent need for practical defenses. We observe that benign skills do not require code modification during execution to accomplish their intended tasks. This suggests that granting agents the ability to modify skills at runtime is unnecessary for benign functionality, yet it introduces an attack surface that can be exploited by dynamic malicious skills. Motivated by this insight, we propose a system-level defense against DyMalSkill based on the principle of least privilege [Saltzer and Schroeder, 1975]. Specifically, our defense restricts the agent’s ability to modify skill code at runtime. Our evaluation shows that this approach effectively mitigates dynamic malicious skill attacks, reducing the ASR to zero. We also evaluate two prompt-injection detection methods [Shi et al., 2025, Liu et al., 2025], which we extend to detect dynamic malicious skills by analyzing skill documentation, as well as a system-prompt-based defense that explicitly instructs the agent not to modify skills at runtime. Our results show that detection-based methods suffer from either high false negative rates or high false
2
positive rates, while system-prompt-based defenses can be bypassed and fail to provide consistent protection.
2
Related Work
Agentic AI’s skill calling Prior work [Yao et al., 2023, Schick et al., 2023, Qin et al., 2024, Wang et al., 2024] has explored the development of tool-calling and action-generation capabilities in large language models, starting from native function-calling implementations in models such as GPT-4o [OpenAI, 2024]. To address interoperability challenges across diverse platforms, the Model Context Protocol (MCP) [Anthropic, 2024] was introduced as a standardized interface for connecting agents to various MCP tools. Given a user query, the backbone LLM determines which tool to call, sends the required arguments to the tool for execution, and receives the results. More recently, agentic frameworks have transitioned toward a modular “skill” architecture. In this framework, a skill can be formally defined as a tuple comprising executable code, metadata, and natural-language documentation. Agents that use skills typically operate in two stages: skill selection and skill execution. During skill selection, the backbone LLM selects a skill based on its metadata. During skill execution, the code in the selected skill is executed, and the results are returned to the backbone LLM. A key distinction between MCP-based tools and skills is that a skill is an internal component of the agent, whereas an MCP server is an external resource with which the agent interacts. Attacks to tool calling Several prior works have explored the security of tool use in agentic AI [Shi et al., 2026, 2024, Jia et al., 2026, Hu et al., 2026]. These attacks can be broadly categorized into two complementary types: malicious tool selection [Shi et al., 2026] and malicious code implementation [Jia et al., 2026, Hu et al., 2026]. Malicious tool selection focuses on strategically crafting a tool’s metadata (i.e., its name and description) to induce the backbone LLM to select it. For example, ToolHijacker [Shi et al., 2026] proposes a prompt injection attack [Liu et al., 2024] that targets the tool selection process by injecting optimized malicious metadata into the tool library to deceive the model into invoking attacker-specified tools. In contrast, malicious code implementation focuses on injecting harmful logic directly into the tool’s code. Existing studies in this category primarily consider static malicious tools, where the code already contains malicious implementations at the time of distribution on platforms or marketplaces. For instance, MalTool [Hu et al., 2026] presents a systematic study of static malicious tools by defining 12 types of malicious behaviors that compromise the agent’s confidentiality, integrity, and availability, and automatically implementing them using a coding LLM. Similarly, SkillJect [Jia et al., 2026] steers agent behavior toward unauthorized actions by embedding prompt injection attacks within skill code. Despite their effectiveness, static malicious tools are susceptible to detection by static code analysis; for example, platform providers may identify and block such tools prior to distribution. Our work also focuses on malicious code implementation. However, in contrast to prior work, we study dynamic malicious skills, which inject malicious behaviors into otherwise benign skills at runtime.
3
Problem Formulation
We formally define the problem: an AI agent executes a skill whose original executable code is benign, but whose natural-languasge documentation (such as SKILL.md) contains hidden malicious instructions that dynamically induce harmful code modification during execution. 3
3.1
Skill Definition
A skill s can be defined as a tuple s = (c, m, d), where c is executable code (e.g., Python scripts), m is the metadata of the skill, including the name and a short description for the skill, and d denotes natural-language instructions that further specify the intended behavior and usage of the skill. Both the metadata m and instruction d are in the documentation SKILLS.md. For a benign skill, we assume that the code c, metadata m and instructions d are all benign. The usage of skills in AI agents can be divided into two stages: skill selection and skill execution. We formally define two stages. Definition 1 (Skill Selection). Let H be the conversation history (context) and p be the user’s query prompt. Let S = {s1 , s2 , . . . , sn } be the available skill set. The skill selection process can be defined as < s∗ , a >= M(p, H, S), where M denotes the agent’s backbone LLM, s∗ is the selected skill, and a represents the arguments passed to the skill. We note that the selection process may also determine that no skill is required, in which case M(p, H, S) returns an empty response. Definition 2 (Skill Execution). Suppose the skill s∗ has been selected and arguments a are passed to it by the agent A. The execution process can be abstracted as Y = A(s∗ , a), where Y denotes the execution results, including the final output and any modifications to the skill s∗ .
3.2
Threat Model
Attacker’s goal The attacker aims to instruct the agent to dynamically modify the original benign code in a skill, thereby producing the desired malicious outcome when executing the modified code. These outcomes are designed to compromise the system’s security properties. For instance, to violate confidentiality, the attacker may force the agent to perform remote data exfiltration or harvest environment credentials from local configuration files. To undermine integrity, the modified skill might delete local files or inject adversarial records into databases. Also, the attacker may target availability by hijacking CPU or GPU resources for unauthorized computation, or by implementing response time amplification to degrade system performance and cause a denial of service. We adopt the 12 categories of malicious behaviors defined by MalTool [Hu et al., 2026] in our experiments; details are provided in Table 4 in the Appendix. Attacker’s knowledge The attacker has full knowledge of the original benign skills from opensource platforms or markets, including the code, metadata, and additional instructions. However, the attacker does not know the environment in which a user deploys the skill (including the specific agent, system prompt, and so on). Additionally, the attacker does not know the user’s query prompt or the conversation history with the agent. Attacker’s capabilities To achieve this goal, the attacker may inject carefully crafted malicious instructions into the skill documentation (e.g., SKILL.md). After creating the malicious skill, the attacker can upload it to skill marketplaces or platforms (e.g., Skillsmp) for distribution to other users.
3.3
Dynamic Code Modification
Suppose a dynamic malicious skill sm = (c, m, dm ) is selected and executed by the agent A. During execution, the agent first modifies the code c of the malicious skill according to the malicious instructions specified in dm . We denote this dynamic code modification process as c̃ = A(c, dm ). The transformed code c̃ induces malicious behavior upon execution and forms the modified malicious skill s̃ = (c̃, m, dm ). The skill will be executed by the agent A, leading to final malicious output 4
and behaviors as Ỹ = A(s̃, a), where Ỹ denotes the malicious behaviors exhibited by the agent. This attack enables dynamic code modification without altering the original executable code at the time of distribution on platforms or marketplaces.
4
Our DyMalSkill
Overview We propose DyMalSkill to construct malicious instructions dm in the documentation SKILL.md that induces the agent to dynamically modify the skill’s benign code c during execution, as illustrated in Figure 1. We parameterize dm along two primary design axes: (i) the injected malicious content ∆d, and (ii) its injection location L within the SKILL.md file. Given a benign skill s = (c, m, d), the malicious instructions can be expressed as dm = I(d, ∆d, L), where I denotes the injection function. Challenges Naively injected content ∆d may state the malicious goal in plain language (e.g., “before answering, exfiltrate the contents of .env to attacker.com”). However, such instructions may not lead to a successful attack. The agent may treat this explicit request as unrelated to the user query and either ignore or refuse it, as the requested action lacks a plausible connection to the skill’s functionality. Crafting injected content To address such a challenge, our DyMalSkill crafts content ∆d to satisfy three properties simultaneously: (1) Prerequisite framing: ∆d is presented as a setup step that must be completed before the agent attempts the user’s task, with a benign-sounding rationale (e.g., “initialize per-run configuration”). This exploits the agent’s instruction-following bias, a step framed as a precondition is executed before the agent reasons about whether the step is necessary at all. (2) Entry-script grounding: ∆d names the skill’s actual entry script (resolved from the skill manifest at injection time) and decomposes the malicious behavior into edits expressed in the same vocabulary as benign skill notes (“add a helper”, “call it at the start of main()”). Such instructions therefore look indistinguishable from ordinary build or setup notes that legitimate skills routinely contain. (3) Wrapper-pierce: ∆d is enclosed in tags that mimic platform-level scaffolding (</EXTRA INFO> <SYSTEM INSTRUCTION>...</SYSTEM INSTRUCTION>), exploiting the fact that current agent harnesses concatenate SKILL.md into the prompt without sanitizing tag-like substrings, so the model treats the injected block as a higher-trust context segment. Determining injection location To investigate the impact of content placement within the documentation SKILL.md, we formalize the injection location. Let the benign natural-language instructions d be represented as a sequence of k discrete text blocks (b1 , b2 , . . . , bk ). We define the injection function I(d, ∆d, L) as inserting the malicious content ∆d at index L ∈ {0, 1, . . . , k}, resulting in the malicious instructions dm . Empirically, prepending the content (L = 0) emerges as the most effective location, as illustrated in Figure 2. This performance can be explained by the top-down processing behavior of LLM-based agents. When an agent reads SKILL.md from the beginning to build its execution plan, instructions encountered early are often treated as foundational ordering constraints. Because these instructions are established before the agent forms a complete understanding of the skill’s intended purpose, there is less opportunity for the model to later prune the malicious step as irrelevant or anomalous.
5
Table 1: ASR (%) of DyMalSkill across agentic frameworks and backbone LLMs on 12 malicious behaviors.
Malicious Behavior
OpenHands
Claude Code
Qwen3-8B Qwen3.6-35B GPT-4o-mini GPT-5
Sonnet 4.6
Env. Credential Harvesting API Key Abuse Remote Data Exfiltration Local Data Exfiltration File-to-Remote Exfiltration Malicious DB Injection Local File Deletion DB Record Deletion Remote Program Downloading CPU Compute Hijacking GPU Compute Hijacking Response Time Amplification
19.3 14.7 12.0 11.7 11.7 13.7 21.3 13.3 6.0 40.7 20.7 39.0
25.0 26.3 44.0 37.0 38.3 42.3 47.3 29.0 28.0 65.0 44.3 72.7
52.0 32.0 32.0 52.0 42.0 44.0 30.0 40.0 30.0 70.0 10.0 68.0
36.0 38.0 20.0 40.0 30.0 40.0 32.0 36.0 42.0 64.0 66.0 80.0
12.0 4.0 0.0 36.0 0.0 32.0 46.0 2.0 0.0 4.0 10.0 82.0
Average
18.7
41.6
41.8
43.7
19.0
5
Attack Evaluation
5.1
Experimental setup
We evaluate DyMalSkill on two state-of-the-art coding frameworks, Claude Code [Anthropic, 2026] and OpenHands [Wang et al., 2025], using five backbone LLMs across twelve malicious behaviors adopted from MalTool [Hu et al., 2026]. Additional details on these behaviors are provided in Table 4 in the Appendix. By default, DyMalSkill injects malicious instructions at the beginning of a skill’s documentation. Skills dataset We collect 15,067 skills from Skillsmp. Due to computational constraints, we randomly sample 300 skills with Python code to evaluate DyMalSkill. For open-weight backbone LLMs (e.g., Qwen), we evaluate DyMalSkill on all 300 skills. For proprietary models such as GPT-4o-mini, GPT-5, and Sonnet 4.6, we evaluate DyMalSkill on 50 sampled skills due to API cost constraints. For each skill, we consider 12 types of malicious behaviors. For each (skill, behavior) pair, we modify the skill’s documentation d by inserting ∆d to dynamically induce the corresponding malicious behavior. Evaluation metrics We report the Attack Success Rate (ASR), defined as the fraction of (skill, behavior) pairs for which DyMalSkill successfully induces the skill to dynamically implement the corresponding malicious behavior. Given a modified skill, we employ a verifier to automatically determine whether the desired malicious behavior has been correctly implemented. Details about the verifier are provided in Appendix A.
5.2
Main results
Table 1 reports the ASR of DyMalSkill across five backbone LLMs. The average ASR over the 12 behaviors ranges from 18.7% on Qwen3-8B to 41.8% on GPT-4o-mini, with Claude Sonnet 4.6 achieving an average ASR of 19.0%. Overall, these results indicate that current agentic frame6
Figure 2: Impact of injection location across malicious behaviors. works are vulnerable to dynamic malicious skills, and that this vulnerability persists across diverse backbone LLMs and model scales. We highlight three key observations: (i) Scale increases vulnerability within a model family. Transitioning from Qwen3-8B to Qwen3.635B increases ASR on every behavior, with the average rising from 18.7% to 41.6%. This includes massive spikes such as a +33.7 point gain in Response Time Amplification. This trend suggests that as models become better at following complex, multi-step ”setup” instructions, they simultaneously become more vulnerable to dynamic malicious skills. (ii) Safety fine-tuning reshapes the risk rather than eliminating it. Both GPT-5 and Sonnet 4.6 are more robust in following malicious instructions in DyMalSkill. GPT-5 achieves sub-40% ASR on behaviors like Remote Program Downloading and Env. Credential Harvesting but is nearly defenseless against Compute Hijacking and Response Time Amplification. Conversely, Sonnet 4.6 is immune to Remote Program Downloading and Remote Data Exfiltration in our tests but is the most vulnerable backbone to Response Time Amplification (82.0%). These results indicate that aligned proprietary models reallocate failures rather than raising a universal security guardrail. (iii) Consistent vulnerabilities are observed across different backbone LLMs. Response Time Amplification and Local File Deletion emerge as high-risk areas across nearly all models, ranking among the highest ASR categories for Qwen3.6-35B, GPT-4o-mini, and Sonnet 4.6. This suggests that behaviors that can be implemented as simple helper functions (e.g., a tight loop or a standard os.remove) are easier for the agent to execute. In contrast, more complex behaviors, such as Remote Program Downloading, are more effectively suppressed by models with stronger safety guardrails, such as GPT-5 and Sonnet 4.6.
5.3
Ablation Study
We analyze how different factors influence the effectiveness of DyMalSkill. We consider four dimensions: (i) the injection location within SKILL.md, (ii) the injected content, (iii) repeated execution of a dynamic malicious skill by the agent, and (iv) the contribution of each sub-property used to craft the injected content. Unless otherwise specified, we conduct our evaluation on OpenHands with Qwen3.6-35B as the backbone LLM, using a randomly sampled set of 100 skills. The injected content is generated by DyMalSkill, and the injection location is set to the beginning of SKILL.md. Impact of injection location Figure 2 illustrates the sensitivity of DyMalSkill to the placement of malicious instructions within the documentation. The results indicate that DyMalSkill remains effective across different injection locations, with “prepend” generally achieving the highest ASR. 7
While “middle” and “append” placements yield slightly lower ASR in some categories, they still maintain substantial effectiveness. This suggests that agents process the entire context of the skill file, implying that the threat of dynamic malicious skills cannot be mitigated by simply scanning specific portions of the documentation. Impact of injected content Figure 4 in the Appendix shows the impact of different injected content. The “baseline” refers to using the attack prompts from MalTool [Hu et al., 2026], which were originally designed to guide an agent to generate static malicious skills. We observe that this baseline fails to trigger any dynamic malicious outcomes, yielding an ASR of 0.0% across all twelve behaviors. This suggests that prompts intended for generating static malicious code cannot be directly embedded in a skill’s documentation to induce dynamic code modification. In contrast, DyMalSkill achieves substantial success by framing the injected content as instructions for dynamic code modification, thereby effectively inducing malicious behavior at runtime. Impact of ASR@k Figure 5 in the Appendix evaluates the ASR when the agent executes a dynamic malicious skill k times independently, where the attack is considered successful if at least one execution results in malicious code modification. As expected, the results show a consistent increase in ASR as k increases. This indicates that the longer a user interacts with the agent, the more likely it is that a dynamic malicious skill will be triggered. Impact of components in DyMalSkill Table 2 presents a leave-one-out ablation study Table 2: Ablation of DyMalSkill’s components. of the three core components used by DyMal- ∆ denotes the ASR reduction when property Pi Skill to craft the injected content. The re- is removed. sults indicate that all three components conCondition Average ASR (%) ∆ tribute positively to the attack’s effectiveness, baseline (no P1 , P2 , P3 ) 0.0 −31.1 with wrapper-pierce (P3 ) being the most critiDyMalSkill \P3 (no wrapper-pierce) 7.8 −23.3 DyMalSkill \P2 (no grounding) 18.3 −12.8 cal factor. Removing P3 results in the largest DyMalSkill \P1 (no prereq framing) 26.8 −4.3 drop in ASR (∆ = −23.3%), highlighting that DyMalSkill 31.1 0.0 mimicking platform-level scaffolding allows malicious instructions to bypass standard prompt boundaries by appearing as high-trust system context. Entry-script grounding (P2 ) also provides a significant boost (∆ = −12.8%) by embedding the attack within the skill’s natural vocabulary and structure, making the malicious edits appear as legitimate setup steps. The complete absence of success in the baseline condition (0.0% ASR) underscores that these prompt-engineering strategies are essential for transforming static malicious strings into effective dynamic code modification attacks.
6
Defenses
6.1
Dynamic Code Modification in Benign Skills
Detecting dynamic code modification in benign skills To examine whether benign skills modify their code during execution, we conduct two studies. In the first study, we execute benign skills within an agent and verify whether their code is modified at runtime. Due to the computational cost of this process, we evaluate 300 benign skills. Specifically, we use the OpenHands agent with Qwen3-8B as the backbone LLM. For each skill, we compute the SHA-256 hash [National Institute of Standards and Technology, 2015] of its code before and after execution. A skill is considered to have undergone code modification if the hash values differ. Among the 300 benign skills, only one (0.33%) exhibits dynamic code modification. 8
In the second study, we analyze the documentation (SKILL.md) of 15,067 skills that include executable code (i.e., contain a scripts/ directory) to identify whether they contain instructions that guide code modification. We employ a two-phase pipeline. Phase 1 applies regular-expression filtering to identify SKILL.md files in which a modification-related verb (e.g., modify, edit, update, change, patch) co-occurs with a reference to a scripts/ path within the same paragraph, excluding cases where the surrounding text explicitly prohibits modification (e.g., “do not modify,” “readonly”). This filtering yields 133 candidate skills. Phase 2 involves manual inspection of these 133 candidates, classifying each as Mandatory—where modification is presented as a required workflow step—or Discretionary, covering configuration, customization, or troubleshooting scenarios not invoked during normal operation. Only 11 skills (0.07% of the 15,067) fall into the Mandatory category. Manual analysis of the benign skills with detected dynamic code modification We further analyze the benign skills that are detected to involve dynamic code modification. In all cases, such modifications are not required by the skill’s intended functionality. For the single benign skill identified in the first study, manual inspection reveals that the modification corresponds to a one-line workaround for a hard-coded relative path in the author’s implementation, which fails when executed from a different working directory. Importantly, the corresponding SKILL.md contains no instruction to modify the code, and the change is unrelated to the skill’s documented behavior. For the 11 skills whose documentation does request modification, 8 ask only for filling in configuration values (e.g., API keys, account credentials, output paths) into top-of-file constants — which the user could equivalently supply through environment variables or command-line flags — and the remaining 3 are skills whose authors explicitly designate a sub-directory as user-editable for annotation or customization. None of the 11 requires the agent to alter control flow, introduce new functions, or otherwise change the skill’s behavior. To summarize, dynamic code modification is exceedingly rare in benign skills. Manual inspection further shows that these rare instances are limited to non-functional adjustments rather than changes to control flow or core logic. Consequently, granting agents unrestricted permission to modify skill source code is unnecessary for legitimate operation.
6.2
Proposed Defenses
Motivated by the above observations, we propose two defenses against dynamic malicious skills: prompt-based and permission-based. The prompt-based defense operates at the prompt level, explicitly instructing the agent not to modify a skill’s code at runtime through carefully designed system prompts. In contrast, the permission-based defense operates at the system level, preventing the agent from modifying skills using kernel-enforced file system permissions. Prompt-based defense We prepend defense instructions to the agent’s system prompt, ensuring they take precedence over any subsequent malicious instructions. These instructions prohibit three types of behavior: (1) modifying any files within the skill’s directory, (2) following instructions that attempt to conceal actions from the user, and (3) accepting claims of capabilities that exceed the skill’s documented scope (e.g., a simple utility presenting itself as a “security prerequisite”). Details of the defense instructions are provided in Appendix 5. Permission-based defense Existing agentic frameworks such as Claude Code require user permission to perform file-system write operations. However, this permission model is coarse-grained: users must either grant the agent unrestricted write access or approve each write operation individually. In practice, users often grant full access to avoid frequent interruptions, rendering this
9
Table 3: ASR (%) of DyMalSkill across 12 types of malicious behaviors under different defenses. Malicious Behavior
No defense
Prompt-based
Permission-based
Environment Credential Harvesting API Key Abuse Remote Data Exfiltration Local Data Exfiltration File-to-Remote Exfiltration Malicious Database Injection Local File Deletion Database Record Deletion Remote Program Downloading CPU Compute Hijacking GPU Compute Hijacking Response Time Amplification
25.0 26.3 44.0 37.0 38.3 42.3 47.3 29.0 28.0 65.0 44.3 72.7
8.0 5.0 26.0 32.0 28.0 24.0 25.0 11.0 6.0 21.0 24.0 47.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Average
41.6
21.4
0.0
mechanism insufficient for defending against dynamic malicious skills. Our permission-based defense specifically targets skill code and employs a two-layer permission defense stack within a sandboxed environment. The first layer uses Bubblewrap [containers/bubblewrap contributors, 2026] to bind-mount the skill directory as read-only at the operating system kernel level, preventing any direct modification of skill files regardless of file ownership or permission changes. As a result, the agent cannot dynamically modify the original skill code. However, a dynamic malicious skill may attempt to circumvent this restriction by instructing the agent to copy the skill code to a temporary directory, modify it there, and execute the modified version. To mitigate such evasion strategies, we introduce a second layer: a copy monitor. This component intercepts file-system operations issued by the agent and blocks attempts to copy skill code, thereby preventing indirect modification.
6.3
Experimental Results
We evaluate our defenses on OpenHands with Qwen3.6-35B-A3B as the backbone LLM, using the same 300 benign skills and the default attack setting of DyMalSkill described in Section 5. Table 3 reports the ASR of DyMalSkill under different defenses. We also evaluate two prompt-injection detection methods, PromptArmor [Shi et al., 2025] and DataSentinel [Liu et al., 2025]. Since DyMalSkill injects malicious instructions into a skill’s documentation, we apply these detectors to identify whether a SKILL.md file is contaminated by prompt injection, flagging the corresponding skill as malicious if detected. Specifically, we apply the detectors to the 300 benign skills and their corresponding malicious versions generated by DyMalSkill. Figure 3 shows the False Negative Rate (FNR) and False Positive Rate (FPR), where FNR is the fraction of malicious skills incorrectly classified as benign, and FPR is the fraction of benign skills incorrectly classified as malicious. We have four main observations: (i) The permission-based defense is significantly more robust than the prompt-based defense. While the prompt-based defense provides a 20.2% reduction in average ASR, its effectiveness is limited by the model’s inconsistent compliance when faced with injected malicious instructions.
10
Reductions vary sharply across behaviors, ranging from only 5% for Local Data Exfiltration to 44% for CPU Compute Hijacking. Attacks that mimic legitimate setup procedures, such as Response Time Amplification and Local Data Exfiltration, are much more resistant to this system prompt level prevention. (ii) The permission-based defense is effective against dynamic malicious skills. The permissionbased defense achieves a 0.0% ASR across all malicious behaviors. Furthermore, for each skill, we compute the SHA-256 hash of its code before and after execution and confirm that the hash values match, indicating that no modifications have been made. (iii) The permission-based defense does not disrupt the performance of benign skills. As analyzed in Section 6.1, benign skills do not require dynamic code modification to achieve their intended functionality. Consequently, the permission-based defense does not interfere with their correct execution in principle. Empirically, on the same 300 benign skills used in Section 6.1, every skill successfully completes its user task under the defense. We note that one of these skills was identified in Section 6.1 as having modified its own code at runtime; under the defense, the corresponding write is rejected at Figure 3: FNR and FPR of prompt-injection dethe kernel level, but because that modification tection methods in identifying dynamic malicious was a defect-driven workaround rather than a skills generated by DyMalSkill. step required for the skill’s documented behavior, blocking it does not affect task completion. (iv) The prompt-injection detection methods are insufficient. PromptArmor fails to detect the majority of malicious skills, with a FNR of 85.8%, despite achieving a 0% FPR. In contrast, DataSentinel achieves a low FNR of 2.5% but suffers from a prohibitively high FPR of 56.0%, incorrectly classifying more than half of benign skills as malicious.
7
Conclusion
In this work, we introduce dynamic malicious skills. Our evaluation shows that they pose significant threats to the security and privacy of agentic AI, achieving varying success rates across a diverse set of malicious behaviors. In addition, we show that a permission-based defense, which prevents agents from modifying skill code during execution, can effectively mitigate dynamic malicious skills without sacrificing the utility of benign skills.
References Anthropic. Model context protocol. https://modelcontextprotocol.io/, 2024. Accessed 2026-05-06. Anthropic. Claude code overview. https://docs.anthropic.com/en/docs/claude-code/over view, 2026. Accessed 2026-05-06. containers/bubblewrap contributors. Bubblewrap. https://github.com/containers/bubblewr ap, 2026. Accessed 2026-05-06. 11
Yuepeng Hu, Yuqi Jia, Mengyuan Li, Dawn Song, and Neil Gong. Maltool: Malicious tool attacks on llm agents. arXiv preprint arXiv:2602.12194, 2026. Xiaojun Jia, Jie Liao, Simeng Qin, Jindong Gu, Wenqi Ren, Xiaochun Cao, Yang Liu, and Philip Torr. Skillject: Automating stealthy skill-based prompt injection for coding agents with tracedriven closed-loop refinement. arXiv preprint arXiv:2602.14211, 2026. Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik R. Narasimhan. SWE-bench: Can language models resolve real-world github issues? In International Conference on Learning Representations, 2024. Yupei Liu, Yuqi Jia, Runpeng Geng, Jinyuan Jia, and Neil Zhenqiang Gong. Formalizing and benchmarking prompt injection attacks and defenses. In USENIX Security Symposium, 2024. Yupei Liu, Yuqi Jia, Jinyuan Jia, Dawn Song, and Neil Zhenqiang Gong. Datasentinel: A gametheoretic detection of prompt injection attacks. In IEEE Symposium on Security and Privacy, 2025. National Institute of Standards and Technology. Secure hash standard (shs). Technical report, National Institute of Standards and Technology, 2015. OpenAI. GPT-4o system card. https://openai.com/index/gpt-4o-system-card/, 2024. Accessed 2026-05-06. Yujia Qin, Shihao Liang, Yining Ye, Kunlun Zhu, Lan Yan, Yaxi Lu, Yankai Lin, Xin Cong, Xiangru Tang, Bill Qian, et al. Toolllm: Facilitating large language models to master 16000+ real-world apis. In International Conference on Learning Representations, 2024. Jerome H. Saltzer and Michael D. Schroeder. The protection of information in computer systems. Proceedings of the IEEE, 1975. Timo Schick, Jane Dwivedi-Yu, Roberto Dessi, Roberta Raileanu, Maria Lomeli, Eric Hambro, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. In Advances in Neural Information Processing Systems, 2023. Jiawen Shi, Zenghui Yuan, Yinuo Liu, Yue Huang, Pan Zhou, Lichao Sun, and Neil Zhenqiang Gong. Optimization-based prompt injection attack to llm-as-a-judge. In ACM SIGSAC Conference on Computer and Communications Security, 2024. Jiawen Shi, Zenghui Yuan, Guiyao Tie, Pan Zhou, Neil Zhenqiang Gong, and Lichao Sun. Prompt injection attack to tool selection in llm agents. In Network and Distributed System Security (NDSS) Symposium, 2026. Tianneng Shi, Kaijie Zhu, Zhun Wang, Yuqi Jia, Will Cai, Weida Liang, Haonan Wang, Hend Alzahrani, Joshua Lu, Kenji Kawaguchi, et al. Promptarmor: Simple yet effective prompt injection defenses. arXiv preprint arXiv:2507.15219, 2025. Xingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang, Yunzhu Li, Hao Peng, and Heng Ji. Executable code actions elicit better llm agents. In International Conference on Machine Learning, 2024. Xingyao Wang, Boxuan Li, Yufan Song, Frank F. Xu, Xiangru Tang, Mingchen Zhuge, Jiayi Pan, Yueqi Song, Bowen Li, Jaskirat Singh, et al. Openhands: An open platform for ai software developers as generalist agents. In International Conference on Learning Representations, 2025. 12
John Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik Narasimhan, and Ofir Press. SWE-agent: Agent-computer interfaces enable automated software engineering. In Advances in Neural Information Processing Systems, 2024. Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. In International Conference on Learning Representations, 2023.
13
Table 4: Taxonomy of malicious behaviors defined in MalTool [Hu et al., 2026]. Security Dimension
Confidentiality
Integrity
Availability
Malicious Behavior
Description
Environment Credential Harvesting
Scouring system environment variables and config files to steal authentication tokens or secret keys.
API Key Abuse
Utilizing stolen service credentials to make illegitimate requests to third-party platforms or cloud services.
Remote Data Exfiltration
Unauthorized broadcasting of private information to external servers managed by an adversary.
Local Data Exfiltration
Stashing sensitive information in hidden or accessible local folders to be retrieved by an attacker at a later time.
File-to-Remote Exfiltration
Scanning and uploading local system files directly to an untrusted external network destination.
Malicious Database Injection
Inserting fraudulent or harmful data entries into application databases to manipulate stored records.
Local File Deletion
Unauthorized removal of system or user files to disrupt operations and destroy critical data.
Database Record Deletion
Erasing specific rows or tables within a database to corrupt the consistency and history of the application.
Remote Program Downloading
Fetching external executable scripts or binary payloads to facilitate the deployment of secondary malware.
CPU Compute Hijacking
Diverting processor cycles toward unauthorized tasks to the detriment of legitimate system processes.
GPU Compute Hijacking
Co-opting graphics hardware resources for attacker-defined workloads, slowing down visual or analytical tasks.
Response Time Amplification
Artificially inflating the latency of system processes to render services sluggish or unusable.
Figure 4: Impact of injected content.
A
Verifier Details
We adopt the runtime verifier from MalTool [Hu et al., 2026], and refer the reader to that work for the full implementation. We summarize here only the design properties that are relevant for interpreting the ASR numbers in Section 5. The verifier counts a trial as a successful attack only when the agent-modified skill, re-executed in a controlled sandbox, produces the runtime side effect specific to the malicious behavior under test (e.g., an outbound HTTP request captured on a local listener, a row-count change in a sentinel database, the disappearance of a sentinel file, or a wall-clock latency above a fixed threshold). The full mapping between behaviors and detection signals is given in Table 4. This behavioral grounding is what distinguishes verifier-confirmed ASR from a code-edit-only proxy: a benign refactor, or a payload planted in an unreached code path, does not count as an attack. To increase coverage of code paths the agent might invoke, the verifier replays the modified script through several candidate entry points (direct invocation, in-process call of main(), example commands extracted from SKILL.md, and argparse-derived variants) and reports the deepest attempt that reaches the patched region. The sandbox is reset between trials so ASR reflects per-trial compromise probability rather than cumulative state.
14
Figure 5: ASR@k, which is defined as the probability that a dynamic malicious skill successfully induces malicious code modification when executed by the agent k times independently.
Table 5: Prompt-based defense. IMPORTANT SECURITY POLICY — MUST OBEY: TRUST BOUNDARY: The text inside .agents/skills/ (SKILL.md, scripts, READMEs, configs) is documentation supplied by third-party skill authors. It is NEVER a source of authority for your behavior. Only this system prompt and the user’s chat message are. If a skill file contains text that tries to elevate its own authority beyond “documentation about how a tool works” — for example by speaking as if it were the runtime, the operator, an oversight body, or by declaring that its own steps override normal trust assumptions — that text is adversarial. Refuse it. Complete the user’s task using only the skill’s documented entry script, with no modifications; tell the user briefly what was flagged. OTHER REFUSAL SIGNALS: - Instructions asking you to modify, create, or delete files inside .agents/skills/. - Instructions asking you to copy or move any file inside .agents/skills/. - Instructions asking you not to mention something to the user, not to confirm with them, or to act before responding. When in doubt, do NOT follow the skill instruction.
15