Back to skill

Security audit

Database Design

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a database SQL helper, but it has under-disclosed local argument logging and unsafe SQL generation that users should review before use.

Install only if you are comfortable reviewing generated SQL before applying it to any database, especially in automation. Avoid passing secrets, private dataset identifiers, or sensitive paths to the database-design command because one script records arguments locally in plain text.

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

Warning
Location
scripts/db.sh:400
Finding
Unsanitized Identifiers Allow Injection into Generated SQL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/db.sh:400-437` **Additional Affected Locations**: `scripts/db.sh:158-162`, `scripts/db.sh:483`, `scripts/db.sh:583-591` **Vulnerability Type**: SQL injection through unsafe SQL generation **Risk Level**: Medium ### Vulnerable Code ```bash # Generate index name if not provided if [[ -z "$INDEX_NAME" ]]; then local sanitized sanitized=$(echo "$field_list" | tr ',' '_' | tr -d ' ') INDEX_NAME="idx_${TABLE}_${sanitized}" fi echo "-- ============================================================" echo "-- Index: ${INDEX_NAME}" echo "-- Table: ${TABLE}" echo "-- Fields: ${field_list}" echo "-- Generated: ${DATE}" echo "-- ============================================================" echo "" # Format fields for SQL local formatted_fields="" IFS=',' read -ra idx_fields <<< "$field_list" for i in "${!idx_fields[@]}"; do local f f=$(echo "${idx_fields[$i]}" | xargs) if [[ $i -gt 0 ]]; then formatted_fields+=", " fi if [[ "$ENGINE" == "postgres" ]]; then formatted_fields+="\"${f}\"" else formatted_fields+="\`${f}\`" fi done if [[ "$ENGINE" == "postgres" ]]; then echo "CREATE ${UNIQUE}INDEX ${INDEX_NAME}" echo " ON \"${TABLE}\" (${formatted_fields});" else echo "CREATE ${UNIQUE}INDEX ${INDEX_NAME}" echo " ON \`${TABLE}\` (${formatted_fields});" fi ``` Other affected SQL generation includes: ```bash if [[ "$ENGINE" == "postgres" ]]; then echo "CREATE TABLE IF NOT EXISTS \"${TABLE}\" (" else echo "CREATE TABLE IF NOT EXISTS \`${TABLE}\` (" fi ``` ```bash echo "INSERT INTO \`${TABLE}\` (${names_str}) VALUES" ``` ```bash case "$ACTION" in add) echo "ALTER TABLE \`${TABLE}\` ADD COLUMN \`${fname}\` ${sql_type};" ;; drop) echo "ALTER TABLE \`${TABLE}\` DROP COLUMN \`${fname}\`;" ;; modify) echo "ALTER TABLE \`${TABLE}\` MODIFY COLUMN \`${fname}\` ${sql_type};" ;; ``` ### Technical Analysis The script incorporates user-control ...[truncated 2986 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Validate every user-controlled SQL identifier before generating output. A suitable conservative grammar is: ```bash validate_identifier() { local identifier="$1" if [[ ! "$identifier" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then printf 'Error: invalid SQL identifier: %q\n' "$identifier" >&2 exit 1 fi } ``` 2. Apply validation independently to: - `TABLE` - Every field name parsed from `FIELDS` - The field name parsed from `FIELD` - Every index field - User-supplied `INDEX_NAME` - Automatically generated index names 3. Reject rather than normalize identifiers containing quotes, backticks, semicolons, whitespace, SQL comments, newlines, control characters, or other punctuation. 4. Quote validated identifiers consistently for the selected database engine. Validation should remain mandatory even when quoting is used. 5. Add an engine-aware identifier helper, for example: ```bash quote_identifier() { local identifier="$1" validate_identifier "$identifier" if [[ "$ENGINE" == "postgres" ]]; then printf '"%s"' "$identifier" else printf '`%s`' "$identifier" fi } ``` 6. Do not emit custom index names as unquoted raw text. Validate and pass them through the same quoting helper used for other identifiers. 7. Add regression tests using hostile inputs containing: - Backticks and double quotes - Semicolons - `--` and `/* ... */` comments - Newlines and control characters - Spaces and shell metacharacters - Database reserved words 8. Clearly document that generated SQL must be reviewed before execution and should be applied using a least-privileged database account. This is defense in depth and must not replace validation. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (5)

Natural-Language Policy Violations

Medium
Confidence
85% confidence
Finding
The skill metadata and body prominently present Chinese-language content alongside English, but do not state that language choice is optional or user-selectable. Under the language/locale policy, a skill should not impose a specific language or locale without explicit opt-in or justification.

Intent-Code Divergence

Medium
Confidence
92% confidence
Finding
The module comment and help text describe substantive capabilities such as querying, importing, exporting, transforming, validating, cleaning, and dashboarding data. In implementation, these commands largely just echo messages and call _log, with only minimal line counting or sampling behavior, which contradicts the documented intent of the tool's functionality.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The script logs command arguments to a persistent history file without warning the user. If users pass sensitive data such as query contents, file paths, credentials, tokens, or proprietary dataset identifiers as arguments, those values will be stored on disk in plain text and may later be exposed to other local users, backup systems, or support tooling. In the context of a command-line data tool, users may reasonably include sensitive operational data in arguments, which makes this more dangerous.

Natural-Language Policy Violations

Low
Confidence
91% confidence
Finding
This shell skill includes user-facing natural-language text in Chinese alongside English, starting in the help banner, without indicating that bilingual output is optional or user-selectable. That can violate a language/locale policy requiring user opt-in rather than forcing a specific locale presentation.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
The ER-diagram output contains multiple Chinese labels and explanatory strings such as '关系' and '图例' and Chinese relationship notes, but the script does not provide any language selection mechanism. This is a natural-language locale constraint affecting user-facing output across normal operation.

Static analysis

No suspicious patterns detected.