T09 · Insecure Skill Coding Practices
- Location
scripts/migration_generator.py:466- Finding
Unvalidated Schema Values Are Embedded in Executable Migration SQL
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This database skill is coherent, but its migration generator can emit destructive and injectable SQL with weak rollback safeguards, so users should review it carefully before installing.
Install only if you will treat generated migrations as drafts. Review all SQL before applying it, avoid running migrations from untrusted schema JSON, use backups and least-privileged database roles, and be especially cautious when a generated plan contains DROP TABLE or DROP COLUMN.
scripts/migration_generator.py:466Unvalidated Schema Values Are Embedded in Executable Migration SQL
scripts/migration_generator.py:930Destructive Table Migration Provides a Nonfunctional Rollback
The code substantially aligns with part of the declared description: it analyzes existing schemas for normalization, naming, constraints, data types, and missing indexes, and generates ERD output. However, the declared purpose is materially broader than the actual implementation. The code does not design schemas from scratch, compare or choose database engines, generate migration scripts, or interpret EXPLAIN plans. Its primary behavior is limited to static analysis of SQL DDL / JSON schema input and ERD/report generation. Because several prominent declared capabilities are absent, the description does not accurately represent what the supplied code chunk actually does.
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.
Phase 1: Expand
-- Add new column without constraints
ALTER TABLE users ADD COLUMN new_email VARCHAR(255);
-- Backfill data in batches
The skill instructs the agent to read reference files and run local scripts that take schema/query files as inputs, but it does not declare any explicit tool scope or permissions. That creates an authorization gap where the agent may access files beyond the minimally intended set, increasing the chance of unintended file reads or writes if a user supplies paths or if the runtime grants broad filesystem access.
The code generates destructive column-drop migration steps that can permanently remove data, but it does not require any explicit acknowledgement, confirmation gate, or prominent warning in the generated output. In a migration-generation skill, users may trust generated SQL and execute it directly, so silent generation of data-loss operations materially increases the chance of accidental destructive changes.
The table-drop generation emits DROP TABLE statements even though rollback is explicitly incomplete ('implementation needed'), making the operation effectively irreversible in practice. In the context of a database design and migration skill, this is especially dangerous because the tool presents itself as generating safe migrations and rollback scripts, which may cause users to overtrust a data-destructive plan.
This code writes generated ERD or analysis output to a user-specified path via open(..., 'w'), which can overwrite existing files. Although this is part of the tool's purpose, there is no confirmation prompt or explicit warning in the code comments/docstring near the write paths that output files may be overwritten.
No suspicious patterns detected.