Back to skill

Security audit

Telegram语音消息技能包:基于实际踩坑经验的完整解决方案,帮助AI助手正确发送Telegram语音消息。解决WAV格式错误、缺少asVoice参数、TTS音频URL过期等常见问题。

Security checks for vulnerabilities and agentic risk

Overview

The skill has a legitimate Telegram voice-message purpose, but it includes unsafe runnable scripts and examples that could allow command execution or unauthenticated message sending.

Install only if you are prepared to review and harden the scripts first. Avoid the webhook, remote config, eval, shell=True, and named-pipe examples as written; keep Telegram/TTS tokens scoped and separate from media-processing subprocesses, and do not expose any listener publicly without authentication and rate limits.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (4)

T03 · Remote Payload Retrieval and Execution

Error
Location
docs/api-integration.md:793
Finding

Remote Configuration Is Converted into Shell Code and Executed

Content
View full analysis
/tmp/remote_config.sh source /tmp/remote_config.sh } ``` ### Technical Analysis The function accepts a caller-controlled configuration URL, downloads JSON from that location, converts its keys and values into shell statements, and executes the generated file with `source`. The generated assignments are not safely shell-escaped. A configuration value containing shell syntax, command substitution, or statement separators can therefore alter the generated script and execute commands. Because `source` runs in the current shell, the payload inherits the invoking process's environment, working directory, filesystem access, and credentials. The implementation provides no trusted-origin allowlist, response signature, checksum, schema enforcement, or safe parsing boundary. It also writes to the predictable shared path `/tmp/remote_config.sh`, creating an additional opportunity for local race-condition or symlink attacks. This remote execution mechanism is unnecessary for the Skill's declared purpose of generating, converting, and sending Telegram voice messages. ### Attack Path 1. An attacker persuades the user or Agent to invoke `load_config_from_remote` with an attacker-controlled URL, or compromises the configured remote service. 2. The remote server returns JSON containing a value that becomes executable shell syntax after the `jq` transformation. 3. The function writes the generated statements to `/tmp/remote_config.sh`. 4. The function executes the file using `source`. 5. The attacker's commands run with the privileges an ...[truncated 742 chars]
Remediation
View remediation
&2; return 1 ;; esac ``` ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/audio_converter.sh:170
Finding

Command Injection through eval in the Audio Converter

Content
View full analysis
&1); then ``` ### Technical Analysis The script constructs an ffmpeg command as a string and reparses it with `eval`. The string includes values originating from command-line arguments: - Input file path. - Output file path. - `--bitrate`. - `--sample-rate`. - `--channels`. Quoting values while constructing the string does not make them safe because `eval` performs another round of shell parsing. A value that terminates the intended quoting context or contains command substitution can introduce an additional shell command. No strict allowlist validation is applied to the audio option values before they reach `eval`. File existence and format checks do not prevent malicious shell syntax from appearing in a valid filename. ### Attack Path 1. An attacker controls a filename, output path, or audio option passed to `audio_converter.sh`. 2. The supplied value contains shell syntax designed to escape the command's intended argument context. 3. The script inserts the value into `ffmpeg_cmd`. 4. `eval` reparses the entire command string. 5. The injected command executes with the privileges of the user running the converter. A realistic exposure exists when an Agent processes uploaded files whose names are attacker-controlled or forwards user-provided conversion options. ### Impact Assessment Successful exploitation provides arbitrary local command execution as the invoking user. The attacker could: - Read or modify files available to the Skill process. - Access exported Telegram and TTS credentials. ...[truncated 329 chars]
Remediation
View remediation
&1); then ``` Apply strict validation before execution: ```bash [[ "$bitrate" =~ ^[0-9]+k$ ]] || { log_error "Invalid bitrate" return 1 } [[ "$sample_rate" =~ ^[0-9]+$ ]] || { log_error "Invalid sample rate" return 1 } [[ "$channels" =~ ^[12]$ ]] || { log_error "Invalid channel count" return 1 } ``` Additional hardening should include: - Prefixing file operands with `--` where supported. - Rejecting unsafe or unexpected output locations. - Running media processing in a sandbox with no access to API credentials. - Applying file-size, duration, and processing-time limits. - Adding regression tests using filenames containing spaces, quotes, semicolons, dollar signs, and command-substitution characters. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
docs/api-integration.md:887
Finding

Generic Arbitrary-Command Executors Using eval and Predictable Named Pipes

Content
View full analysis
"$pipe" break fi done } ``` ### Technical Analysis The batch API helper treats each input string as shell code and executes it using `eval`. Any untrusted data incorporated into an operation becomes an arbitrary-command execution vector. The connection-pool example creates predictable FIFOs under `/tmp`, reads text from them, and passes that text directly to `eval`. It does not create a private directory, enforce restrictive permissions, verify FIFO ownership, authenticate writers, or restrict commands to an allowlist. The worker processes run indefinitely in the background. This broad command-execution interface is not required to call TTS or Telegram APIs and breaks the principle of least privilege. ### Attack Path For the batch helper: 1. An attacker influences an operation string passed to `batch_api_calls`. 2. The string includes an unintended shell command. 3. `eval "$ ...[truncated 1117 chars]
Remediation
View remediation
&2; return 1 ;; esac } ``` - Do not use shell command strings as inter-process messages. - Replace the named-pipe design with a structured queue containing validated JSON or another non-executable format. - If FIFOs are necessary, create them inside a private directory produced by `mktemp -d`, set mode `0700`, and verify ownership and file type before every use. - Add termination handling and remove FIFOs when workers exit. - Apply concurrency, queue-size, execution-time, and resource limits. - Run workers under a dedicated account without access to unrelated files or credentials. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
docs/api-integration.md:657
Finding

Unauthenticated Webhook Listener Triggers TTS and Telegram Processing

Content
View full analysis
/tmp/webhook_server.py << 'EOF' from http.server import HTTPServer, BaseHTTPRequestHandler import json import subprocess import threading class WebhookHandler(BaseHTTPRequestHandler): def do_POST(self): content_length = int(self.headers['Content-Length']) post_data = self.read.rfile.read(content_length) try: data = json.loads(post_data.decode('utf-8')) text = data.get('text', '') # 在新线程中处理,避免阻塞 thread = threading.Thread(target=process_webhook, args=(text,)) thread.start() self.send_response(202) self.send_header('Content-Type', 'application/json') self.end_headers() self.wfile.write(json.dumps({'status': 'accepted'}).encode()) except Exception as e: self.send_response(400) self.send_header('Content-Type', 'application/json') self.end_headers() self.wfile.write(json.dumps({'error': str(e)}).encode()) def log_message(self, format, *args): # 禁用默认日志 pass def process_webhook(text): # 调用TTS生成和发送 subprocess.run([ './scripts/tts_generator.sh', text, '|', 'xargs', './scripts/telegram_sender.sh' ], shell=True) if __name__ == '__main__': server = HTTPServer(('0.0.0.0', 8080), WebhookHandler) print('Webhook服务器启动在端口 8080') server.serve_forever() EOF python3 /tmp/webhook_server.py & } ``` ### Technical Analysis The example binds the HTTP server to `0.0.0.0`, making it reachable through all available network interfaces. It accepts POST requests and initi ...[truncated 1977 chars]
Remediation
View remediation
Vulnerability Patterns
  • 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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (144)

YARA rule 'agent_skill_credential_exfiltration_webhook': AI agent skill credential harvesting followed by webhook or external exfiltration [agent_skills]

Critical
Category
YARA Match
Confidence
85% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · docs/api-integration.md (reported line 58)May include surrounding context.

ey_id": "$ALIYUN_ACCESS_KEY_ID", "access_key_secret": "$ALIYUN_ACCESS_KEY_SECRET", "tts_appkey": "$ALIYUN_TTS_APPKEY" } EOF

text

#### API调用示例
```bash
# 调用阿里云TTS
call_aliyun_tts() {
  local text="$1"
  local output_file="$2"
  
  # 构建请求
  local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
  local signature=$(generate_signature "$text" "$timestamp")
  
  # 发送请求
  curl -X POST "https://nls-gateway-cn-shanghai.aliyuncs.com/stream/v1/tts" \
    -H "Content-Type: application/json" \
    -H "Authorization: $signature" \
    -d "{
      \"appkey\": \"$ALIYUN_TTS_APPKEY\",
      \"text\": \"$text\",
      \"format\": \"wav\",
      \"sample_rate\": 16000,
      \"voice\": \"xiaoyun\",
      \"volume\": 50,
      \"speech_rate\": 0,
      \"pitch_rate\": 0
    }" \
    -o "$output_file"
  
  # 验证响应
  if [ -f "$output_file" ] && [ $(stat -c%s "$output_file") -gt 1000 ]; then
    echo "✅ TTS生成成功: $output_file"
    return 0
  else
    echo "❌

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · PUBLISH_GUIDE.md (reported line 154)May include surrounding context.

md
steps:
      - uses: actions/checkout@v2
      - name: 安装依赖
        run: |
          sudo apt-get update
          sudo apt-get install -y ffmpeg curl jq
      - name: 运行验证

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · docs/best-practices.md (reported line 331)May include surrounding context.

md
steps:
      - uses: actions/checkout@v2
      - name: 安装依赖
        run: |
          sudo apt-get update
          sudo apt-get install -y ffmpeg curl jq
      - name: 运行验证

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · examples/error-examples.md (reported line 561)May include surrounding context.

md
steps:
      - uses: actions/checkout@v2
      - name: 安装依赖
        run: |
          sudo apt-get update
          sudo apt-get install -y ffmpeg curl jq
      - name: 运行验证

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · examples/error-examples.md (reported line 566)May include surrounding context.

md
steps:
      - uses: actions/checkout@v2
      - name: 安装依赖
        run: |
          sudo apt-get update
          sudo apt-get install -y ffmpeg curl jq
      - name: 运行验证

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · PUBLISH_GUIDE.md (reported line 130)May include surrounding context.

export ALIYUN_TTS_API_KEY="your_aliyun_key_here"

或者使用配置文件

cp templates/.env.example .env

编辑.env文件,填写真实值

text

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · README.md (reported line 25)May include surrounding context.

export ALIYUN_TTS_API_KEY="your_aliyun_key_here"

或者使用配置文件

cp templates/.env.example .env

编辑.env文件,填写真实值

text

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · README.md (reported line 246)May include surrounding context.

md
local output_file="$2"
    
    # API调用(使用环境变量)
    curl -X POST "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
        -H "Authorization: Bearer $ALIYUN_TTS_API_KEY" \
        -H "Content-Type: application/json" \
        -d "{

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 514)May include surrounding context.

bash
# 自动清理临时文件
cleanup() {
    rm -f /tmp/audio_*.wav
    rm -f /tmp/audio_*.ogg
    echo "🧹 已清理临时文件"
}

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 515)May include surrounding context.

md
# 自动清理临时文件
cleanup() {
    rm -f /tmp/audio_*.wav
    rm -f /tmp/audio_*.ogg
    echo "🧹 已清理临时文件"
}

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · README.md (reported line 533)May include surrounding context.

generate_audio "$text" "/tmp/temp_audio.wav"

text
# 立即清理
shred -u "/tmp/temp_audio.wav" 2>/dev/null || rm -f "/tmp/temp_audio.wav"

}

text

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 67)May include surrounding context.

md
./scripts/telegram_sender.sh generated_audio.ogg

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 98)May include surrounding context.

md
./scripts/telegram_sender.sh generated_audio.ogg

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The webhook server example accepts arbitrary POST requests, parses attacker-controlled JSON, and immediately processes the supplied text without invoking the documented signature verification routine. In this context, that means any network client that can reach the server can trigger downstream processing and message-sending workflows, enabling unauthorized use and making later command-injection issues easier to exploit.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The webhook example launches a network-facing server on 0.0.0.0 and processes untrusted request content by passing it into local script execution. In an agent skill, this materially increases the attack surface by turning documentation into an unsolicited remote-trigger execution path, especially when paired with missing authentication and shell invocation.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
100% confidence
Finding

The webhook handler passes attacker-controlled text into subprocess execution while also setting shell=True, and the argument list itself includes shell metacharacter pipeline elements. This creates a likely command-injection path where a crafted webhook payload can execute arbitrary shell commands on the host, making it the most severe issue in the file.

Content

Scanner excerpt · docs/api-integration.md (reported line 697)May include surrounding context.

md
def process_webhook(text):
    # 调用TTS生成和发送
    subprocess.run([
        './scripts/tts_generator.sh', text,
        '|', 'xargs', './scripts/telegram_sender.sh'
    ], shell=True)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The remote configuration example downloads data from a URL, transforms it into shell export statements, writes it to a file, and then sources that file. If the remote service, transport path, or returned content is compromised, this becomes arbitrary shell code execution in the agent environment.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
89% confidence
Finding

The cleanup function deletes files using a wildcard under "$temp_dir" without validating that temp_dir is set to an expected safe location. If temp_dir is empty, malformed, or attacker-influenced, the command may delete unintended files in the current working directory or another sensitive path matching the pattern.

Content

Scanner excerpt · docs/best-practices.md (reported line 184)May include surrounding context.

bash
# ✅ 安全清理
cleanup() {
  rm -f "$temp_dir"/*.wav
  rm -f "$temp_dir"/*.ogg
  rm -f "$temp_dir"/*.tmp
}

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
89% confidence
Finding

This deletion pattern has the same weakness as the prior line: it trusts temp_dir blindly and expands a wildcard against that path. In shell scripts, unvalidated cleanup paths are a common source of accidental or attacker-triggered file deletion.

Content

Scanner excerpt · docs/best-practices.md (reported line 185)May include surrounding context.

md
# ✅ 安全清理
cleanup() {
  rm -f "$temp_dir"/*.wav
  rm -f "$temp_dir"/*.ogg
  rm -f "$temp_dir"/*.tmp
}

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
89% confidence
Finding

The .tmp cleanup command repeats the same unsafe pattern and can delete unintended temporary files if temp_dir is misconfigured or influenced by external input. Cleanup code often runs automatically via trap, increasing the chance of non-interactive destructive behavior.

Content

Scanner excerpt · docs/best-practices.md (reported line 186)May include surrounding context.

md
cleanup() {
  rm -f "$temp_dir"/*.wav
  rm -f "$temp_dir"/*.ogg
  rm -f "$temp_dir"/*.tmp
}

# 确保清理

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · examples/basic-usage.md (reported line 324)May include surrounding context.

md
print(f"发送语音消息: {text[:50]}...")
            
            # 设置环境变量
            env = os.environ.copy()
            env.update({
                'TELEGRAM_BOT_TOKEN': self.config['telegram_bot_token'],
                'TELEGRAM_CHAT_ID': self.config['telegram_chat_id']

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The CLI example loads configuration with source "$CONFIG_FILE" from a user-writable file in the home directory, which executes arbitrary shell code contained in that file. For a tool whose stated purpose is only sending Telegram voice messages, this introduces an unnecessary local code-execution path that could be abused if the file is modified by malware, another local user, or unsafe automation.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · examples/best-practices.md (reported line 54)May include surrounding context.

清理临时文件

echo "🧹 清理文件..." rm -f /tmp/test_audio.wav /tmp/test_audio.ogg

echo "✅ 消息发送完成!"

text

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · examples/best-practices.md (reported line 728)May include surrounding context.

md
./scripts/tts_generator.sh "告警:$message" /tmp/alert.wav
        ./scripts/audio_converter.sh /tmp/alert.wav /tmp/alert.ogg
        TELEGRAM_CHAT_ID="$TELEGRAM_ALERT_CHAT_ID" ./scripts/telegram_sender.sh /tmp/alert.ogg
        rm -f /tmp/alert.wav /tmp/alert.ogg
    fi
}

Chaining Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The cleanup routine pipes find results into xargs rm -rf for directories under /tmp matching a broad pattern. This is dangerous because /tmp is attacker-writable: crafted filenames with whitespace/newlines can be mishandled by xargs, and the script may delete directories it did not create, enabling unintended destructive cleanup against other users' or processes' data.

Content

Scanner excerpt · scripts/tts_generator.sh (reported line 311)May include surrounding context.

sh
rm -rf "$TEMP_DIR" 2>/dev/null || true
    
    # 可选:清理旧的临时文件
    find /tmp -name "telegram_voice_*" -type d -mtime +1 2>/dev/null | xargs rm -rf 2>/dev/null || true
    
    log_success "清理完成"
}