Back to skill

Security audit

Test Data Generator

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed local test-data generator with some review-worthy hygiene issues but no hidden, persistent, or exfiltrating behavior.

Install only if you are comfortable with a Chinese-locale test-data generator. Review generated SQL before importing it, use least-privileged test database accounts, and avoid custom templates from untrusted sources. Pin or remove the pytest dependency if reproducible installs matter.

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
generator.py:331
Finding

SQL Injection Through Unvalidated Table and Column Identifiers

Content
View full analysis

Vulnerability Details

File Location: generator.py, lines 331-354
Vulnerability Type: SQL injection in generated database statements
Risk Level: Medium

python
def to_sql(self, data: List[Dict[str, Any]], db_type: str = "mysql", table_name: str = None) -> str:
    """转换为SQL INSERT语句"""
    if not data:
        return ""
    if table_name is None:
        table_name = self.template_name

    sql_statements = []
    for record in data:
        columns = ", ".join(record.keys())
        values = []
        for v in record.values():
            if v is None:
                values.append("NULL")
            elif isinstance(v, bool):
                values.append("1" if v else "0")
            elif isinstance(v, (int, float)):
                values.append(str(v))
            elif isinstance(v, str):
                # 转义单引号
                escaped = v.replace("'", "''")
                values.append(f"'{escaped}'")
            else:
                values.append(f"'{str(v)}'")
        values_str = ", ".join(values)
        sql_statements.append(f"INSERT INTO {table_name} ({columns}) VALUES ({values_str});")

Technical Analysis

The SQL exporter escapes single quotes in string values, but it does not validate or safely quote SQL identifiers. Both table_name and the keys from each generated record are concatenated directly into executable SQL syntax.

Record keys originate from template field names. Custom templates loaded by generate_from_template can therefore supply attacker-controlled column identifiers. The table_name argument is also directly controllable when to_sql is used as a module API.

Escaping SQL values does not protect SQL identifiers. An identifier containing closing delimiters, parentheses, semicolons, comments, or other SQL syntax can alter the structure of the generated statement. The ineffective PostgreSQL branch elsewhere in this method also do ...[truncated 1288 chars]

Remediation
View remediation

Remediation Suggestions

  1. Validate all table and column identifiers before SQL generation. A conservative allowlist is:

    python
    IDENTIFIER_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
    

    Reject every identifier that does not match the policy.

  2. Apply database-specific identifier quoting after validation:

    • MySQL: backtick-quoted identifiers, with embedded backticks rejected.
    • PostgreSQL: double-quoted identifiers, with embedded double quotes rejected or correctly doubled.
  3. Do not attempt to protect identifiers with value-escaping logic. Keep identifier validation and value serialization as separate operations.

  4. Restrict custom templates to a documented schema and validate the fields object, field names, field definitions, enum values, and numeric bounds before generation.

  5. Add tests covering malicious table and field names containing semicolons, comments, parentheses, quotes, backticks, whitespace, and SQL keywords. Verify that unsafe identifiers are rejected rather than emitted.

  6. Clearly warn users that generated SQL should be reviewed and imported with a least-privileged database account that cannot administer users or unrelated schemas.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (7)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill title and all instructional content are written in Chinese, and the field definitions explicitly constrain generated data to Chinese-specific values such as Chinese names and phone numbers. There is no indication that users can opt into another language/locale or that the skill is intentionally limited to a China-specific compliance or regional use case.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module description and generated datasets are explicitly Chinese-language and China-locale specific, as shown by the Chinese-only description and the hard-coded Chinese names, provinces, phone formats, genders, product labels, and comments throughout the file. This forces a specific language/locale behavior without user opt-in or a documented region-specific justification, which matches the policy-violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The README content is entirely in Chinese, including headings, usage descriptions, field explanations, and examples, with no indication that other languages are supported. This can violate language/locale policy expectations when a skill imposes a specific language without user opt-in or documented justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The user-facing description, examples, help text, status messages, and errors are presented in Chinese only. This imposes a specific language on all users without opt-in or an alternative locale, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
94% confidence
Finding

The dependency is specified as pytest>=7.0.0, which allows installation of any future version and does not guarantee reproducible or reviewed builds. Unpinned requirements increase supply-chain risk because a later vulnerable or breaking release could be pulled in without notice.

Content

Scanner excerpt · requirements.txt (reported line 1)May include surrounding context.

text
pytest>=7.0.0

Unverifiable Dependency: pytest has 2 known advisory(ies) (CVE-2025-71176 (pytest has vulnerable tmpdir handling); CVE-2025-71176 (pytest has vulnerable tmpdir handling)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
84% confidence
Finding

The manifest does not pin the pytest version, so it is not possible to verify whether the resolved package version includes known advisories. This creates uncertainty in the dependency security posture and may allow installation of an affected release in some environments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code file contains user-facing natural-language text in Chinese (for example the module docstring and subsequent test docstrings/comments), with no indication that language selection is optional or intentionally region-scoped. Under the policy, forcing a specific language without user opt-in can be a locale/language policy violation.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.