Manuscript Offprint

arXiv:2608.25817

SkillShield: Prompt-Space Security Skills for LLM Coding Agents

Xiaodong Wu, Zhimin Zhao, Qi Li, Xiangman Li, Yu Shi, Bram Adams, Jianbing Ni

Abstract

A coding agent edits files and executes shell commands with its developer's privileges, allowing malicious requests to translate directly into harmful actions or functional malware. Existing defenses have complementary limitations: weight-level alignment is unavailable to API-only deployers, whereas input filters and execution-boundary monitors require auxiliary classification or checking components along the agent's trajectory. We therefore introduce SKILLSHIELD, a system-prompt defense that synthesizes security skills offline from known attacks or recorded agent failures. These skills are injected into the system prompt at session start and remain active throughout the tool-use loop. Unlike a reference monitor, they protect the system by defining the security policies the model should follow during execution. Due to the limited system-prompt space, we examine three fixed-budget provisioning scopes: all-classes, with one skill covering all threat classes, per-bundle, with one skill targeting a related subset, and per-class, with one skill dedicated to a single known class and used as the upper-bound reference. None requires runtime request classification or routing. Across six large language models on RedCode, the default all-classes skill reduces malware-generation severity from 3.37 to 0.58 and achieves a 43.6% execution attack success rate, comparable to Llama Guard 3's 42.7% without its separate 8B classifier. The per-bundle and class-fixed per-class settings further reduce this rate to 36.2% and 14.5%, respectively. Under two non-adaptive jailbreak families, SKILLSHIELD continues to outperform all baselines on malware generation. Across 731 benign task descriptions, SKILLSHIELD yields a mean safety-refusal rate of 0.14%. These results demonstrate the potential of prompt-space security skills to prevent harmful actions and malware generation for LLM coding agents.

1 Introduction

Large language model (LLM)-based coding agents such as Claude Code [7], Codex [29], and OpenCode [5] combine language models with tools, code execution, and operating-system access. Conventional code assistants such as GitHub Copilot [15] suggest code for human approval. Coding agents can also inspect repositories, edit files, invoke compilers and tests, execute shell commands, and debug failures iteratively [37, 38]. They now operate in development environments that contain credentials, dependency managers, build systems, and version-control state [21].

Coding agents perform these actions with the developer's privileges and also process untrusted project content [16, 33, 44]. A malicious GitHub issue can therefore instruct an agent diagnosing a build failure to fetch and execute a remote script, and the agent may comply [4, 18]. Because agent-generated tool calls may be executed without human approval, a harmful action can reach the execution boundary before a human intervenes. Runtime monitors can still block such candidate actions, but doing so requires inspecting each one along the trajectory. We instead study an earlier control point: placing security policy in the context that generates every action, so the model can be steered before a harmful call is produced. The need is substantial. Across six LLMs, undefended agents comply with 46–80% of malicious code-execution requests, and DeepSeek-V3.2 [25] also produces malware with an average judge score of 7.76 out of 10 [17].

Existing defenses address this risk at four stages of the agent pipeline (Figure 1). At the model level, alignment [8, 30, 32] requires access to model weights and costly retraining, which excludes API-only deployers. At the input stage, safety filters [27, 28] can reject harmful user requests, but they cannot protect against malicious instructions encountered later during the agent's interaction with repository content or tool output. At the execution stage, runtime verifiers [22, 26] inspect candidate actions before execution and provide a stronger enforcement boundary, but they add a model or checking component to the tool-use loop. In prompt space, defenses place security instructions in the agent context. Existing methods use boundary reminders, provenance delimiters, or authentication tags to distinguish untrusted data from instructions [20, 36, 40]. These methods use general rules across tasks and leave open how threat-specific policies should be synthesized and scoped within a finite prompt budget. We investigate this question for API-only deployments. The system prompt can govern action formation throughout the multi-step loop and be updated without retraining or an additional runtime component.

We therefore propose SKILLSHIELD, a prompt-space defense that injects security skills into a coding agent's system prompt. A skill is a natural-language instruction document that extends agent behavior without modifying model weights [1]. SKILLSHIELD derives security skills from structured attack data. Proactive mining extracts observed attack patterns, whereas reactive learning captures the framings behind recorded agent failures. Each skill is injected in full at session start and remains active throughout the interaction. Because the prompt budget is fixed, increasing coverage forces more threat classes to share the same space, reducing the detail available to each class, while narrowing scope preserves class-specific detail at the cost of covering fewer threats. To capture this tradeoff, we study three deployment scopes that reflect how much threat information is known before a session begins. General-purpose agents use an all-classes skill, deployments exposing a known mechanism family use a corresponding per-bundle skill, and per-class skills apply when the exact threat class is known in advance and provide an upper bound on fine-grained provisioning. All configurations use the same prompt budget and require no request-time classification or routing.

We evaluate SKILLSHIELD on RedCode [18], the only publicly available and established coding-agent benchmark that jointly measures harmful tool execution and malware generation. Four questions organize the evaluation. Q1: Are prompt-space security skills effective? Yes. The all-classes skill reduces execution attack success rate (ASR) from 67.4% to 43.6% and malware-generation severity from 3.37 to 0.58, while per-class provisioning further lowers execution ASR to 14.5% when the threat class is known in advance. Q2: What limits coverage in one finite prompt? Broader provisioning weakens protection because class-specific security detail is lost when more threats share the same prompt budget. Concatenating class-specific text within the same budget recovers 59% of the gap of 29 percentage points between per-class and all-classes provisioning. Q3: Does a fixed policy remain effective under non-adaptive jailbreaks? Partially. Malware-generation protection remains strong under persona and American Standard Code for Information Interchange (ASCII)-art attacks, but execution protection degrades under persona framing, although per-class provisioning retains an advantage of 12 percentage points over the strongest baseline. Q4: Does prevention increase benign refusal? Little. Across 731 SWE-Bench Pro task descriptions [13], safety-grounded refusal remains at or below 0.68% in 32 of the 36 configurations we evaluated.

We provide the first systematic study of fixed-budget security policies synthesized from attack data for a coding agent's system prompt, using agent skills as the packaging format. Our work contributes security-policy synthesis and provisioning. Our code will be released publicly upon publication. The main contributions are listed below.

• We develop SKILLSHIELD, a prompt-space first line of defense for API-only coding agents. SKILLSHIELD synthesizes security policy offline from known attacks or recorded failures and places the policy in the operator-controlled system prompt. It requires no model-weight changes, auxiliary model, or runtime check.

• We identify deployment scope and synthesis quality as key determinants of prompt-space security. Narrower scopes strengthen in-scope protection, while directly combining class-specific policy text recovers much of the loss at broader scopes.

• We evaluate security across models, agents, and jail-breaks. Across six LLMs and three harnesses, per-bundle skills surpass the strongest clean-input baseline. Under jail-breaks, the defense retains its malware-generation advantage and loses its execution advantage.

• We measure the benign refusal cost of prompt-space prevention. Proactive skills introduce little safety-grounded refusal across 731 benign SWE-Bench Pro task descriptions. End-to-end benign task success remains outside the scope of our evaluation.

References (33)

  • IPIGuard: A novel tool dependency graph-based defense against indirect prompt injection in LLM agents
  • Jailbreaking leading Safety-Aligned LLMs with simple adaptive attacks
  • AgentHarm: A benchmark for measuring harmfulness of LLM agents
  • Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedback
  • Constitutional AI: Harmlessness from AI Feedback
  • Jail-breaking black box large language models in twenty queries
  • SecureVibeBench: Benchmarking secure vibe coding of AI agents via reconstructing Vulnerability-Introducing scenarios
  • Can AI agents solve long-horizon software engineering tasks? arXiv preprint arXiv:2509.16941, 2025 (opens arXiv in a new tab)
  • A wolf in sheep's clothing: Generalized nested jailbreak prompts can fool large language models easily
  • Not what you’ve signed up for: Compromising Real-World LLM-integrated applications with indirect prompt injection
  • The Innovation, 7(6):101253, 2026
  • RedCode: Risky code execution and generation benchmark for code agents
  • What is in your safe data? identifying benign data that breaks safety
  • Defending against indirect prompt injection attacks with spotlighting
  • Large language models for software engineering: A systematic literature review
  • The task shield: Enforcing task alignment to defend against indirect prompt injection in LLM agents
  • ArtPrompt: ASCII art-based jailbreak attacks against aligned LLMs
  • The menlo report: Ethical principles guiding information and communication technology research
  • DeepSeek-V3.2: Pushing the Frontier of Open Large Language Models
  • AGrail: A lifelong agent guardrail with effective and adaptive safety detection
  • Fine-tuning aligned language models compromises safety, even when users do not intend to! In International Conference on Learning Representations (ICLR), 2024
  • Direct preference optimization: Your language model is secretly a reward model
  • Identifying the risks of LM agents with an LM-emulated sandbox
  • SecRepoBench: Benchmarking code agents for secure code completion in Real-World repositories
  • Fath: Authentication-based test-time defense against indirect prompt injection attacks (opens arXiv in a new tab)
  • An open platform for AI software developers as generalist agents
  • SWE-agent: Agent-Computer interfaces enable automated software engineering
  • ReAct: Synergizing reasoning and acting in language models
  • Benchmarking and defending against indirect prompt injection attacks on large language models
  • Jailbreak attacks and defenses against large language models: A survey (opens arXiv in a new tab)
  • GPT-4 is too smart to be safe: Stealthy chat with LLMs via cipher
  • InjecAgent: Benchmarking indirect prompt injections in Tool-Integrated large language model agents
  • CVE-Bench: A benchmark for AI agents' ability to exploit Real-World web application vulnerabilities