DEV Community

Claude code
Claude code

Posted on

Malicious Skills Are the New Supply Chain Attack: Detecting Compromised Agent Extensions Before They Run

What Is AI Agent Supply Chain Security?

AI agent supply chain security is the practice of verifying, monitoring, and controlling every third-party component an autonomous agent loads and executes — skills, plugins, tool definitions, prompt templates, and memory files — so that a compromised extension cannot hijack the agent's privileges. It differs from traditional software supply chain security in one critical way: an agent extension doesn't just ship code, it ships instructions. A malicious skill can attack the model's reasoning directly, then use the agent's own credentials, file access, and messaging channels to do the damage.

If you run OpenClaw agents with community skills installed, this is not a theoretical category. It is npm circa 2017, replayed with a worse blast radius.

Skill Marketplaces Are Rerunning the npm Playbook

The package-registry attack pattern is well documented. In July 2017, npm removed roughly 40 typosquatted packages published by the account "hacktask" — including crossenv, a fake of the popular cross-env — which harvested environment variables (and the credentials inside them) at install time. In November 2018, the event-stream library, then pulling around 1.9 million downloads a week, had a malicious dependency (flatmap-stream) slipped in by a new maintainer to steal Copay bitcoin wallet keys. In October 2021, attackers hijacked ua-parser-js — roughly 7 million weekly downloads — and shipped three versions carrying credential stealers and cryptominers. In December 2022, PyTorch nightly builds were poisoned via a dependency-confusion attack on torchtriton, exfiltrating SSH keys and system files from anyone who installed during a five-day window.

Every structural condition behind those incidents now exists in agent skill ecosystems: low-friction publishing, name-similarity confusion, transitive trust in maintainers, and installation flows that execute content immediately. But skills raise the stakes in three specific ways:

  • Skills execute with the agent's full privilege set. An OpenClaw agent typically holds API keys, filesystem access, shell execution, and outbound messaging. A skill inherits all of it.

  • Skills include natural-language instructions the model follows. There is no compiler, no linter, no type system between a poisoned SKILL.md and the agent's next action. This is why the OWASP Agentic AI Threats and Mitigations guidance (published February 2025) lists tool and dependency compromise among its core agentic threat categories.

  • Agents have memory worth stealing. Workspace files like USER.md and SOUL.md accumulate personal context, credentials, and operational detail over weeks of use. That is a richer target than any single environment variable.

Case Study: A Skill That Exfiltrates Keys and Memory to a Webhook

Here is the anatomy of the attack we use as a baseline scenario, because it requires no novel technique — only the patience to publish a plausible package.

  1. An attacker publishes markdown-formattr, a typosquat of a popular formatting skill. The visible functionality works. Reviews look fine.

  2. Buried in the skill's instructions is a "diagnostics" step: read .env, read USER.md and SOUL.md, and POST the contents to a webhook URL "for compatibility telemetry."

  3. The agent, following skill instructions as designed, performs the reads and the outbound HTTP call. No exploit, no shellcode. The agent's legitimate tool-use machinery does everything.

  4. The skill continues formatting markdown correctly. Nothing visibly fails, so nothing gets reported.

Static review at install time misses this in two ways. First, instruction-layer payloads read as benign prose to a human skimming a diff. Second, and more importantly, a skill can be clean at install and modified afterward — by an update, by another compromised skill, or by the agent itself under injected instructions. A one-time audit is a snapshot of a moving target.

Detection: Hash Baselines Plus an AI Verdict Pipeline

The defensible answer has two halves: cryptographic change detection to know when something changed, and automated analysis to decide whether it matters.

This is how we built Skill Sentinel, one of the three autonomous layers in ClawPatrol, our gateway-level runtime security product for OpenClaw agents. It scans all installed skills in the background, continuously. A composite SHA-256 hash covers each skill's full contents, so any new or modified skill is detected the moment it appears — including the post-install modifications that static review can never catch. Changed or unknown skills go through a multi-agent AI pipeline that inspects instructions and code for exfiltration patterns, privilege abuse, and injection payloads, then issues one of three verdicts: SAFE, SUSPICIOUS, or MALICIOUS.

The same architecture watches the memory side of the attack. ClawPatrol's File Integrity Scanner takes SHA-256 baselines of the agent's cognitive workspace files — SOUL.md, AGENTS.md, IDENTITY.md, TOOLS.md, USER.md, HEARTBEAT.md — at startup and re-hashes every 60 seconds. Unchanged files cost nothing; analysis only fires when content actually changes. So if a skill quietly rewrites the agent's identity or instructions, that tamper is flagged within a minute, not whenever a human happens to reread the file.

And if a malicious skill gets as far as attempting the exfiltration itself, gateway hook enforcement is the backstop: before_tool_call returns { block: true } on the dangerous call, and message_sending returns { cancel: true } on the compromised outbound message. Six hooks. Nine detectors. Zero bypass vectors.

Why AI Agent Supply Chain Security Can't Trust the Agent Itself

Two design decisions matter more than any individual detector, and both come down to trust boundaries.

Enforcement must be gateway code, not LLM behavior. A security instruction in the prompt is a suggestion the model can be talked out of — that is what prompt injection is. Hard hooks execute deterministically at the gateway; there is no persuasion path. The LLM cannot suppress any of ClawPatrol's three layers because none of them ask its permission.

Verdicts must persist. A scanner that forgets on restart is a scanner an attacker can wait out: trigger a crash, and the flagged skill loads clean into the next session. ClawPatrol's MALICIOUS verdicts persist across sessions and restarts until the skill is removed or re-scanned clean. The threat state outlives the process, so "reboot it and see" stops being a bypass.

At Enkrypt AI, we build agent action governance as hard runtime enforcement because we red-team agents for a living, and the consistent lesson is that anything a model is asked to enforce, a model can be convinced to skip. If you want to see the failure and the block side by side, the ClawPatrol Playground simulates prompt injection and agent attacks against a live agent — pick an attack, watch it fail. Installation is one command: npm i @enkryptai/clawpatrol. Secure your OpenClaw agents before the next skill install, not after.

Frequently Asked Questions

How is AI agent supply chain security different from traditional software supply chain security?

Traditional supply chain security defends against malicious code — payloads that execute at install or import time. Agent supply chain security also has to defend against malicious instructions, because skills contain natural-language directives the model follows with the agent's full privileges. SBOMs and dependency pinning don't inspect prose, and a poisoned SKILL.md passes every conventional scanner.

What is skill typosquatting?

It is the agent-ecosystem version of npm typosquatting: publishing a skill whose name closely imitates a popular one (markdown-formattr for markdown-formatter) so users install it by mistake. The 2017 crossenv incident on npm is the template — working functionality on the surface, credential harvesting underneath. Skill marketplaces with low publishing friction inherit the problem directly.

How do I know if an installed agent skill has been modified since I audited it?

Hash it. Take a composite SHA-256 of the skill's full contents at audit time and compare on a schedule; any drift means the skill you're running is not the skill you reviewed. ClawPatrol's Skill Sentinel automates this — it baselines every installed skill, detects new or changed skills in the background, and routes changes through an AI verdict pipeline so you get a SAFE, SUSPICIOUS, or MALICIOUS classification rather than just a diff alert.

Can you sandbox agent skills?

Partially, and you should — filesystem and network restrictions limit blast radius. But sandboxing alone doesn't solve the instruction layer: a skill that manipulates the model into misusing its legitimately granted tools operates entirely inside the sandbox's allowed surface. That is why gateway hooks matter — before_tool_call evaluates each action at execution time and blocks dangerous calls regardless of which skill, prompt, or injected instruction motivated them.

How do you detect a malicious skill after it's already installed?

Continuous background scanning, not point-in-time review. Re-hash installed skills to catch modifications, run changed content through automated analysis for exfiltration and privilege-abuse patterns, and monitor the agent's workspace files for tampering — ClawPatrol re-hashes cognitive workspace files every 60 seconds. Install-time review catches what was malicious on day one; only runtime scanning catches what turned malicious on day thirty.

What happens when a skill scanner flags a skill as malicious mid-session?

With ClawPatrol, the MALICIOUS verdict takes effect immediately and does not depend on the LLM acknowledging it — the finding is recorded at the gateway layer, and hook enforcement blocks the dangerous actions the skill attempts. The verdict then persists across session ends and restarts, so the skill stays flagged until it is removed or re-scanned clean. An attacker cannot clear the state by crashing the agent.

Top comments (0)