Back to skill

Security audit

Douyin Title Generator V2

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a Douyin title generator, but its PowerShell wrapper can turn crafted title inputs into local command execution.

Install only if you are comfortable reviewing or avoiding the PowerShell wrapper. Prefer running the Python script directly with trusted inputs, and do not pass untrusted text into generate.ps1 until Invoke-Expression is replaced with argument-array process invocation.

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
generate.ps1:37
Finding

PowerShell Command Injection Through Invoke-Expression

Content
View full analysis

Vulnerability Details

File Location: generate.ps1, lines 37-46 and execution sinks at lines 64 and 73
Vulnerability Type: PowerShell command injection
Risk Level: High

Vulnerable Code

powershell
# Build the Python command
$pythonCmd = "python main.py --topic `"$Topic`" --style `"$Style`" --count $Count"

if (-not [string]::IsNullOrWhiteSpace($Audience)) {
    $pythonCmd += " --audience `"$Audience`""
}

if (-not [string]::IsNullOrWhiteSpace($Trending)) {
    $pythonCmd += " --trending `"$Trending`""
}

# Execute the Python script
Invoke-Expression $pythonCmd

# Export results
if ($Export) {
    if ([string]::IsNullOrWhiteSpace($ExportPath)) {
        $ExportPath = "douyin_titles_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"
    }

    # Capture the output and save it
    $output = Invoke-Expression $pythonCmd
    $output | Out-File -FilePath $ExportPath -Encoding UTF8
}

Technical Analysis

The script concatenates the user-controlled $Topic, $Style, $Audience, and $Trending parameters into a string intended to represent a command. It then passes that string to Invoke-Expression, which reparses the entire value as PowerShell source code.

Escaped double quotes in the constructed string do not establish a security boundary. A crafted parameter can terminate the intended quoted argument and introduce PowerShell separators, expressions, or additional commands. Consequently, data supplied as a title-generation parameter can be interpreted as executable PowerShell syntax.

The same unsafe command is evaluated again when export mode is enabled, potentially executing an injected payload twice.

Attack Path

  1. An attacker prepares a malicious value for one of the string parameters, such as Topic, Style, Audience, or Trending.
  2. The victim or an automated wrapper invokes generate.ps1 with that attacker-controlled value.
  3. The script interpolates the value into $pythonCmd without preserving it as a discrete proce ...[truncated 887 chars]
Remediation
View remediation

Remediation Suggestions

Remove Invoke-Expression and invoke Python with a PowerShell argument array so every user value remains a single process argument:

powershell
$pythonArgs = @(
    "main.py",
    "--topic", $Topic,
    "--style", $Style,
    "--count", $Count
)

if (-not [string]::IsNullOrWhiteSpace($Audience)) {
    $pythonArgs += @("--audience", $Audience)
}

if (-not [string]::IsNullOrWhiteSpace($Trending)) {
    $pythonArgs += @("--trending", $Trending)
}

$output = & python @pythonArgs
if ($LASTEXITCODE -ne 0) {
    throw "The title generator failed with exit code $LASTEXITCODE."
}

$output

if ($Export) {
    if ([string]::IsNullOrWhiteSpace($ExportPath)) {
        $ExportPath = "douyin_titles_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt"
    }

    $output | Out-File -LiteralPath $ExportPath -Encoding UTF8
}

Additional hardening measures:

  1. Execute the generator only once and reuse the captured output for display and export.
  2. Use -LiteralPath when writing to a caller-supplied export path.
  3. Validate Count against a reasonable positive upper bound to prevent excessive resource consumption.
  4. Restrict Style, Audience, and Trending to documented allowlists when arbitrary values are unnecessary.
  5. Resolve main.py relative to $PSScriptRoot so execution does not depend on the current working directory.
  6. Add regression tests containing quotes, semicolons, subexpressions, and newline characters to verify that parameters are treated only as data.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The script builds a shell command string from user-controlled parameters and executes it with Invoke-Expression. In PowerShell, this enables command injection if an attacker supplies crafted values containing metacharacters or additional commands, allowing arbitrary code execution on the host instead of merely generating titles.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The entire skill description, usage instructions, and examples are presented only in Chinese, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking audience. This creates a natural-language locale constraint without user opt-in, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The module title, description, and all user-facing strings are written only in Chinese, which imposes a specific language on users. Under the policy, locale or language restrictions should either be optional for the user or clearly documented as justified for a region-specific tool.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains natural-language descriptions and output strings entirely in Chinese, including the skill name, usage text, and generated report, with no indication that users may choose another language. Under the policy rule for language or locale constraints, forcing a specific language without opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script’s user-facing strings, usage examples, and status/error messages are entirely in Chinese, including required parameter guidance and completion output. Under the policy rule, forcing a specific language without user opt-in is a natural-language policy concern unless the locale restriction is explicitly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The natural-language strings and comments in this script are entirely in Chinese, which can impose a language constraint on users without any opt-in or justification. The policy explicitly calls for flagging language or locale restrictions when no user choice or documented rationale is provided.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

This markdown file describes collecting information from ClawHub and GitHub to identify user demand, but it does not include any warning about respecting platform terms, privacy, or avoiding collection of sensitive user data. Under the markdown-specific warning criterion, this is a user-facing behavior that could affect privacy and should be disclosed if the skill or workflow relies on such scanning.

Content

No source excerpt is available for this finding.