SkillGate Guardrails for agent tools

A skill file is code an agent will obey. What if it is lying?

Agent Skills and MCP servers hand an agent new instructions and new tools, and a poisoned one can tell it to leak a key or run a shell command.

A local, deterministic prototype with two layers. The scanner reads a skill folder or an MCP server definition without executing anything, applies 46 frozen rules and returns findings with file-and-line evidence, a 0 to 100 risk score and an allow, review or block verdict. The guard is an MCP server that checks every tool call against a deny-by-default policy, asks a human when the policy says so, and logs each decision with secrets redacted.

Role
Sole builder: fixtures, rule catalog, scoring, scanner, guard, evaluation and generated README. Developed with AI coding assistance.
Type
Independent prototype
Status
Public repository · runs locally, $0, no model calls
Stack
  • Python
  • MCP Python SDK 2.x
  • Python ast
  • PyYAML
  • unittest

At a glance

Problem
Public scans have found malicious and flawed skills in the wild, and tool descriptions can carry instructions the model follows. An agent installs both on trust.
Built
A 46-rule static scanner with a frozen scoring formula, and an MCP guard proxy with a deny-by-default policy, human confirmation and a redacted decision log.
Evidence
30 frozen fixtures (15 poisoned, 15 clean) and 12 scripted tool calls, all hashed before any scanner or guard code existed, graded against an outside ledger.

Scope. A prototype scanner and allowlist guard, not a security audit. The fixtures and the rules share an author, so the scanner results show the rules implement their spec consistently on 30 hand-written cases, not how they generalise to real skills.

The workflow problem

An Agent Skill is a folder with a SKILL.md that an agent reads as instructions; an MCP server gives it tools with descriptions the model also reads. Either can hide an instruction to print a credential, pipe an installer into a shell, or send notes to an outside address. Defending against that takes two separate checks: one before install, on what the files say, and one at runtime, on what each tool call actually tries to do.

What makes it hard

  • The scanner must never run what it scans

    It reads files, parses Python with ast and never imports, executes or fetches anything. An audit-hook test confirms it opens nothing outside the fixture while scanning.

  • No model calls

    Deterministic rules give the same verdict every time, cost nothing and can be unit tested rule by rule. The price is that novel or obfuscated attacks get through.

  • The guard can't grade itself

    The downstream tools run in a separate process and write every invocation to a ledger the guard never reads, with a loopback canary as a second outside observer.

  • Results must not be tuned

    Rule logic was committed before it ever ran on a fixture. Later changes are bug fixes only, each logged, and severities were not raised after seeing a miss.

My approach

Data came first: 30 fixtures, 12 guard tasks, the policy, a deprecated-server denylist, the rule catalog and the score formula were committed and hashed before any scanner or guard code, and both eval runners refuse to run if a hash changes. The scanner applies rules grouped by a public skills-risk taxonomy plus three MCP categories, then scores findings with a frozen formula. The guard proxies an MCP client to a fake downstream server: policy check, then confirmation if required, then a redacted log line, and only then the tool.

System architecture

Each stage is labeled by what it is: interface, deterministic logic, stored data, generated data, or the language model. The list reads in the order data flows.

  1. 01 DataSkill or MCP serverSKILL.md and its scripts, or an MCP config, tool list and Python server source
  2. 02 Deterministic logicScanner46 deterministic rules with file-and-line evidence; reads files only, never executes
  3. 03 Deterministic logicRisk scoreFrozen formula; one critical finding blocks, one high needs review; exit codes 0, 2, 3
  4. 04 Deterministic logicGuard (MCP server)Deny-by-default policy on tool and arguments, human confirmation for risky tools, redacted JSONL log
  5. 05 Stored dataDownstream toolsFake MCP server in a separate process, temp directory only, writing every call to an outside ledger

The scanner runs before install and the guard runs on every call; neither depends on the other. The guard enforces policy, it does not sandbox: once a call is allowed, it can't contain what a malicious tool does.

Walkthrough

Example One tool call: a note sent to an outside address

  1. Input

    A scripted client asks the notes server's send_note tool to send a note to an address that isn't on the policy's two-address allowlist.

    • Guard task g01
    • Expected: deny
  2. System processing

    The guard checks the tool, then each argument. send_note is allowed only with confirmation and only to listed recipients, so the "to" argument fails before anything is forwarded.

    • Policy rule: allowlist:to
  3. Output

    Denied and logged with arguments redacted. The downstream ledger shows no call. Sent straight to the tools with no guard, the same request executed.

    • Guarded: not reached
    • No guard: executed
  4. Next action

    A send to a listed address still pauses for a human: accepting runs it, declining doesn't, and both cases are graded on the ledger.

    • Confirm tasks: 2 of 2 correct

Key engineering decisions

  1. Freeze the fixtures, labels and score formula before writing code.

    Why
    A SHA-256 manifest makes it impossible to adjust a fixture or threshold after seeing a result, and labels are read only by the eval runners.
    Tradeoff
    Real misses stay in the results, such as one poisoned fixture scored REVIEW instead of BLOCK, because raising its rule's severity afterwards would be tuning.
  2. Grade the guard on an outside ledger, against a no-guard baseline.

    Why
    A guard that reports its own blocks could be wrong without anyone noticing. Matching ledger entries by tool and argument hash shows what actually reached a tool.
    Tradeoff
    The downstream server is fake, so the result covers its known tools only.
  3. Suppress warnings that are negated, and report every suppression.

    Why
    Clean skills often warn against a risky action ("never share an API key"). Without negation handling those were false positives.
    Tradeoff
    "Don't worry, just run curl ... | bash" is suppressed the same way. That false negative is pinned in a test.

Reliability and evaluation

What this measures. Two frozen suites run locally with zero model calls: 30 scanner fixtures (15 poisoned across 10 categories, 15 clean near-misses) and 12 scripted guard calls (6 must-block, 4 must-allow, 2 must-confirm), each also sent with no guard as a baseline.

Test conditions

  • Fixtures are original, inert simulations on reserved domains with fake canary secrets; none is executable.
  • The fixtures and rules share an author, so expect lower numbers on a real corpus.
  • Guard overhead was measured over stdio, 20 rounds of the 4 must-allow calls in each mode.
Selected results, each with its denominator
MeasureResultOut of
Poisoned flagged15 / 15right category, file and line on all 15
Clean flagged0 / 155 stayed clean only through a suppression
Must-block calls stopped6 / 6all 6 executed without the guard
Guard overhead0.8 msmedian per call over stdio

Observed findings

  • Without the guard, all 6 must-block calls reached the tools, one exfiltration attempt reached the canary and a fake secret came back to the caller. With it, none did.
  • Severity, not detection, caused the one verdict miss: a log analyzer passing user input to a shell was found at the right line, but one high-severity rule gives REVIEW, not BLOCK.
  • Credential and download language is the hardest place for a rule: every clean near-miss that warns against a risky action stayed ALLOW only because a negation heuristic suppressed it, and that heuristic is easy to fool.
  • Line-based matching misses statements split across lines, so a payload built by concatenation or spread over two lines would get through.

Source: README results blocks, generated from reports/scanner_eval.json and reports/guard_eval.json

Limitation. Thirty hand-written fixtures and twelve calls against a fake server. The numbers show the design works as specified; they say little about real-world detection rates.

What I learned

Writing the fixtures before the rules made the honest findings possible. The interesting results weren't the 15 of 15; they were the clean skills that passed only because of a heuristic I know how to defeat, and the miss I chose not to tune away. A guard result also only meant something once there was a baseline showing the same calls going through without it.

Current boundary and next step

Status: Public repository · runs locally, $0, no model calls.

Not yet validated or not built

  • Static rules miss obfuscated and novel attacks, other natural languages and semantic social engineering.
  • The guard is policy enforcement, not a sandbox, and its wrappers cover the fake server's known tools.
  • The deprecated-server denylist is three illustrative entries, not a live registry.
  • Confirmation is only as trustworthy as the client answering it.

Most valuable next experiment

Run the scanner on a sample of real public skills with hand labels to measure detection outside my own fixtures, and add multi-line matching for split statements.

Source and navigation

Screenshots for this project are pending approval.

Talk about this work

Questions about the design, the tradeoffs or the evaluation are welcome.