Back to skill

Security audit

Parse YAML/JSON/TOML front-matter from strings or files using the gray-matter library

Security checks for vulnerabilities and agentic risk

Overview

This skill is a front-matter utility, but it automatically runs an unpinned npm install during normal use, which can change the environment and execute newly downloaded code without clear user control.

Review before installing. The skill's front-matter features are coherent, but first use may download and install gray-matter from the configured npm registry automatically. Prefer a version that declares pinned dependencies and fails with setup instructions instead of running npm install during parsing.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T08 · Insecure Dependencies

Error
Location
scripts/parse.js:24
Finding

Unpinned Dependency Installation During Normal Execution

Content
View full analysis

Vulnerability Details

File Location: scripts/parse.js, lines 24–37
Vulnerability Type: Unsafe runtime installation of an unpinned third-party dependency
Risk Level: High

Vulnerable Code

js
// Resolve gray-matter: prefer local install, fall back to global
let matter;
try {
  matter = require('gray-matter');
} catch {
  // Try installing locally in the scripts directory
  const { execSync } = require('child_process');
  const scriptsDir = __dirname;
  try {
    execSync('npm install gray-matter', { cwd: scriptsDir, stdio: 'ignore' });
    matter = require(path.join(scriptsDir, 'node_modules', 'gray-matter'));
  } catch (e) {
    console.error('Error: gray-matter is not installed. Run: npm install gray-matter');
    process.exit(1);
  }
}

The same unsafe installation procedure is explicitly documented in SKILL.md, lines 104–112:

markdown
## Script Installation

The script auto-installs gray-matter via `npm install gray-matter` on first run. If auto-install fails, run manually:

```bash
cd <skill-dir>/scripts && npm install gray-matter
text

### Technical Analysis

When `gray-matter` cannot be resolved, invoking the parser automatically executes `npm install gray-matter`. The package has no exact version constraint, and the project contains no reviewed lockfile or integrity metadata. Consequently, npm resolves the package and its transitive dependency graph from the registry configured in the execution environment at runtime.

This makes normal document parsing dependent on mutable external supply-chain content. npm may also execute dependency lifecycle scripts during installation. Such scripts run with the privileges of the user or Agent invoking this Skill. Immediately after installation, the downloaded package is loaded into the same Node.js process.

Although the command itself contains no attacker-controlled shell interpolation, its remote package resolution and implicit execution create a supply-chain risk. The behavior
...[truncated 1776 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove automatic package installation from runtime parsing logic. If the dependency is absent, terminate with a clear installation error.

  2. Add a package.json that declares an exact, reviewed gray-matter version rather than a floating version or range.

  3. Generate and commit a lockfile containing the complete dependency graph and integrity hashes.

  4. Install dependencies as a separate deployment step using:

    bash
    npm ci --ignore-scripts
    
  5. If lifecycle scripts are genuinely required, review them and explicitly allow them in a controlled build environment rather than during Skill execution.

  6. Use a trusted registry and enforce registry configuration in the build environment. Consider an internal dependency mirror with package allowlisting.

  7. Run dependency vulnerability and provenance checks in CI, and update dependencies only through reviewed changes.

  8. Execute the Skill with least privilege, minimal environment variables, restricted filesystem access, and limited network access.

  9. Update SKILL.md to remove instructions recommending automatic or unconstrained installation.

A safer failure path would resemble:

js
let matter;
try {
  matter = require('gray-matter');
} catch {
  console.error(
    'Error: gray-matter is not installed. Install the locked dependencies with npm ci.'
  );
  process.exit(1);
}
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The core declared purpose—parsing front-matter from files or strings using gray-matter—is largely accurate, and the code does perform that. However, the implementation materially exceeds that description in two notable ways: it supports --stringify to generate front-matter output from JSON, and it may invoke child_process.execSync to install gray-matter at runtime, which is an undeclared capability involving command execution and environment modification. The extra CLI modes like --test, --data-only, and --content-only are less significant and mostly supportive, but the stringify functionality and runtime package installation make the description incomplete enough to count as a mismatch.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script silently installs a dependency at runtime if gray-matter is missing, which introduces network access, code download, and package lifecycle script execution into a tool whose stated purpose is only parsing front-matter. This creates supply-chain and unexpected-code-execution risk, especially because the behavior is implicit and triggered during normal use rather than an explicit setup step.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Invoking execSync('npm install gray-matter') spawns a subprocess that can fetch and execute untrusted package code and lifecycle hooks, which is far beyond the minimal capability needed for file parsing. In a skill context, this is more dangerous because users may expect a local parsing utility, not a script that mutates the environment and executes package-manager behavior.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The description says to use the skill for 'any task involving front-matter parsing/stringification' and lists generic phrases like 'front matter' and 'frontmatter' as triggers. This is broad enough to match ordinary discussion of document metadata, and the file does not provide exclusions or context boundaries to clarify when the skill should or should not activate.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation omits a prominent warning that the script auto-installs gray-matter on first run, which can surprise users and downstream agents with network access and code execution behavior. In an agent skill, undisclosed automatic installation is more dangerous because it may be triggered non-interactively, increasing supply-chain and policy-bypass risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script performs package installation and subprocess execution without explicit user consent or a prominent warning, violating least surprise and expanding the attack surface. Even if intended as convenience behavior, hidden installation can lead to unauthorized network activity, environment changes, and execution of package scripts.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill instructs or enables runtime package installation via npm, which introduces supply-chain and unexpected network-execution risk in a tool advertised as a parser. In constrained or trusted environments this may be acceptable, but in agentic contexts automatic dependency installation can execute unreviewed package lifecycle scripts and violate least surprise.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.dangerous_exec

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
scripts/parse.js:31