Back to skill

Security audit

Migration Validator

Security checks for vulnerabilities and agentic risk

Overview

The skill is a SQL migration validator, but its validator executes migration SQL rather than only parsing it, which can cause filesystem-backed database side effects.

Review before installing or running this skill in CI or against shared repositories. Use it only in a tightly isolated environment with disposable files, or require changes so it uses a non-executing SQL parser or a strict SQLite authorizer and reports failure when validation errors occur.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/validate.py:20
Finding

Migration Validator Executes Untrusted SQL with Filesystem Access

Content
View full analysis

Vulnerability Details

File Location: scripts/validate.py, lines 20–27
Vulnerability Type: Unsafe execution of untrusted migration scripts
Risk Level: High

Vulnerable Code

python
with open(filepath) as f:
    sql = f.read()
try:
    conn = sqlite3.connect(":memory:")
    cur = conn.cursor()
    cur.executescript(sql)
    conn.close()
except Exception as e:
    validation_errors.append({"migration": m, "error": str(e)})

Technical Analysis

The Skill claims to validate SQL syntax, but it passes every discovered .sql migration to SQLite's executescript(). This API executes all statements rather than merely parsing them.

Using an in-memory primary database does not create a security boundary. SQLite statements such as ATTACH DATABASE can open or create database files on disk. Subsequent statements can then create or alter objects in the attached file. No SQLite authorizer, statement allowlist, filesystem isolation, or privilege restriction is applied.

Consequently, anyone able to introduce or modify a migration file can cause side effects during validation, before the migration has been approved for normal execution.

Attack Path

  1. An attacker gains the ability to add or modify a .sql file in the configured migration directory, such as through a compromised contribution or CI input.
  2. The attacker inserts statements similar to:
    sql
    ATTACH DATABASE '/writable/path/attacker.db' AS target;
    CREATE TABLE target.payload(data TEXT);
    INSERT INTO target.payload VALUES ('attacker-controlled content');
    
  3. The validator enumerates the migration directory and reads the malicious file.
  4. cur.executescript(sql) executes all supplied statements.
  5. SQLite creates or modifies the targeted database file using the validator process's filesystem permissions.
  6. The validator may still return "status": "completed" because that status is unconditiona ...[truncated 594 chars]
Remediation
View remediation

Remediation Suggestions

  1. Replace executescript() with a non-executing SQL parser capable of checking the intended SQLite grammar.
  2. If SQLite execution is unavoidable, install a sqlite3.Connection.set_authorizer() callback before processing input and deny, at minimum:
    • ATTACH and DETACH;
    • data mutation operations;
    • schema creation, alteration, and deletion;
    • transaction and pragma operations not explicitly required;
    • extension-related or other filesystem-affecting functionality.
  3. Use an explicit allowlist of statements accepted by the migration policy rather than attempting to block only known-dangerous statements.
  4. Validate each migration in a fresh, isolated process or container with no network access, a read-only filesystem, no sensitive mounted paths, and a dedicated unprivileged account.
  5. Ensure every opened connection is closed through a context manager or finally block, including when executescript() raises an exception.
  6. Return a failed validation status when any validation error occurs rather than always returning "completed".
  7. Add regression tests containing ATTACH DATABASE and other side-effecting statements to confirm that validation cannot create or modify disk files.
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill describes scanning a migrations directory and reading SQL files, but it does not declare any explicit tool scope such as permissions or allowed-tools. That creates an authorization gap where an agent may read files more broadly than intended, increasing the risk of unintended workspace data exposure if the implementation or runner grants default file access.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language content of the skill body is entirely in Chinese, while the manifest fields are in English. This creates a language policy concern because users are not offered a language choice or informed that the skill documentation is Chinese-only.

Content

No source excerpt is available for this finding.