Back to skill

Security audit

Telegram Direct Send

Security checks for vulnerabilities and agentic risk

Overview

The skill sends images to Telegram as advertised, but it recommends loading a local .env file in ways that can persistently execute shell code.

Review carefully before installing. Use temporary exports or a proper secret manager instead of sourcing a skill-local .env file, do not add the provided block to shell startup files, and keep the Telegram bot token narrowly scoped to the send command.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:64
Finding
Persistent Shell Code Execution Through Unsafe Environment File Sourcing## Vulnerability Details **File Location**: `SKILL.md`, lines 64–78 and 84–88 **Vulnerability Type**: Unsafe shell evaluation of a writable configuration file **Risk Level**: Medium ### Vulnerable Code ```bash ### 4. Auto-Load .env (Optional but Recommended) **For OpenClaw sessions:** Add to your `~/.bashrc` or `~/.zshrc`: ```bash # Auto-load telegram-direct-send env vars if [ -f "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" ]; then source "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" fi ``` ``` The alternative wrapper repeats the unsafe behavior: ```bash #!/bin/bash # Load env vars from skill directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ -f "$SCRIPT_DIR/.env" ]; then source "$SCRIPT_DIR/.env" fi ``` ### Technical Analysis The Bash `source` command evaluates the complete contents of the specified file as shell code. It does not restrict the file to passive `KEY=VALUE` configuration entries. Consequently, any command, function definition, command substitution, redirection, or other shell construct inserted into `.env` will execute with the privileges of the user running the shell. Recommending that users add this operation to `~/.bashrc` or `~/.zshrc` expands the risk beyond an individual Skill invocation. The Skill only needs two values, `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID`, during a send operation. Executing arbitrary contents from the Skill directory whenever a shell starts is unnecessary for that functionality and violates least-privilege principles. The project also claims that `.env` is excluded by `.gitignore`, but no `.gitignore` is present in the audited package. This does not directly cause command execution, but it weakens the documented protection against accidental credential disclosure. ### Attack Path 1. A local attacker, compromised process, malicious update, or another component with write access modifies `$HOME/.openclaw/workspace/skills/telegram-direct ...[truncated 1215 chars]
Remediation
## Remediation Suggestions 1. Remove the recommendation to source the Skill’s `.env` from `~/.bashrc` or `~/.zshrc`. 2. Load credentials only for the duration of an explicit send operation. 3. Parse the configuration as data rather than evaluating it as shell code. Accept only exact keys such as `TELEGRAM_BOT_TOKEN` and `TELEGRAM_CHAT_ID`, reject malformed lines, and never use `eval`. 4. Prefer a credential manager or OpenClaw-supported secret facility over a plaintext `.env` file. 5. If a local secret file remains supported: - Require restrictive permissions such as `chmod 600 .env`. - Verify that the file is owned by the current user. - Ensure the containing directory is not writable by untrusted users. - Add an actual `.gitignore` entry for `.env`. 6. Avoid exporting the Telegram token globally. Pass it only to the process that performs the Telegram request. 7. Document that shell tracing and command logging must remain disabled because Telegram requires the bot token in the API URL.

T09 · Insecure Skill Coding Practices

Warning
Location
skill.md:64
Finding
Persistent Shell Code Execution Through Unsafe Environment File Sourcing in Duplicate Skill Definition## Vulnerability Details **File Location**: `skill.md`, lines 64–78 and 84–88 **Vulnerability Type**: Unsafe shell evaluation of a writable configuration file **Risk Level**: Medium ### Vulnerable Code ```bash ### 4. Auto-Load .env (Optional but Recommended) **For OpenClaw sessions:** Add to your `~/.bashrc` or `~/.zshrc`: ```bash # Auto-load telegram-direct-send env vars if [ -f "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" ]; then source "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" fi ``` ``` The alternative wrapper repeats the unsafe behavior: ```bash #!/bin/bash # Load env vars from skill directory SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ -f "$SCRIPT_DIR/.env" ]; then source "$SCRIPT_DIR/.env" fi ``` ### Technical Analysis This file duplicates the unsafe instructions in `SKILL.md`. Bash treats a sourced file as executable shell input, so `.env` is not confined to declaring the two Telegram variables. Any shell syntax placed in the file executes in the current shell context. Adding the source operation to shell startup files gives a Skill-controlled file a persistent execution path. This exceeds the minimum access needed to send an image through Telegram, which only requires reading two configuration values at the time of the request. Maintaining duplicate Skill definitions also creates remediation risk: correcting only one file may leave the other vulnerable version available to users or tooling. ### Attack Path 1. The user follows the instructions in `skill.md` and adds the provided block to a shell startup file or creates the wrapper. 2. An attacker or compromised local process with write access changes the Skill’s `.env` file. 3. The modified file contains arbitrary shell commands in addition to the expected Telegram variables. 4. The next shell startup or wrapper invocation sources the file. 5. The injected commands execute as the affected user and can execute repeatedly w ...[truncated 724 chars]
Remediation
## Remediation Suggestions 1. Apply the same correction to both `SKILL.md` and `skill.md`, or remove the duplicate file and retain one canonical definition. 2. Do not instruct users to source Skill-owned configuration from shell startup files. 3. Replace shell evaluation with a strict configuration parser that recognizes only the two required variable names. 4. Scope credentials to the individual Telegram request instead of exporting them into every descendant process. 5. Store the bot token in a supported secret manager where possible. 6. If `.env` must be used, require user-only permissions and verify file ownership before reading it. 7. Add the missing `.gitignore` with an explicit `.env` rule and avoid asserting that secrets are ignored unless the protection is actually included. 8. Add validation and fail closed when required values are missing or malformed.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (42)

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
source .env
Confidence
80% confidence
Finding
Instructing users to source a local .env file causes code in that file to execute in the current shell, not just load key-value pairs. If the .env file is modified maliciously or accidentally contains shell commands, this becomes a code-execution and credential exposure risk.

Credential Access

High
Category
Privilege Escalation
Content
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
source .env

# 3. Send an image
curl -s -X POST \
Confidence
80% confidence
Finding
This continues the workflow of sourcing .env before making network requests, combining two risks: arbitrary shell execution from the env file and subsequent use of exposed bot credentials. The skill context makes this more dangerous because the loaded secrets are immediately used to transmit data externally.

Credential Access

High
Category
Privilege Escalation
Content
# Option B: Create .env file (recommended)
cp .env.example .env
# Edit .env with your values
source .env
```
Confidence
81% confidence
Finding
The explicit source .env instruction is a genuine risk because shell sourcing executes file contents. If an attacker can alter the .env file, they can run arbitrary commands in the user's shell and potentially capture or misuse credentials.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# Auto-load telegram-direct-send env vars
if [ -f "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" ]; then
    source "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env"
fi
```
Confidence
84% confidence
Finding
Automatically sourcing a fixed .env path from shell startup creates a persistent code-execution point and exposes credentials into every new shell session. If that file is tampered with, arbitrary commands run automatically, and the Telegram bot token becomes widely available across sessions.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# Auto-load telegram-direct-send env vars
if [ -f "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" ]; then
    source "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env"
fi
```
Confidence
84% confidence
Finding
This line is the actual source command executed from shell startup, creating persistent trust in a mutable file under the workspace. In shared or less controlled environments, that can enable startup-time command execution and credential leakage.

Credential Access

High
Category
Privilege Escalation
Content
#!/bin/bash
# Load env vars from skill directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/.env" ]; then
    source "$SCRIPT_DIR/.env"
fi
Confidence
82% confidence
Finding
The wrapper script sources .env from its own directory, which again executes arbitrary shell content from that file. Because the script may be shared or copied between systems, this pattern can turn a configuration file into an execution vector.

Credential Access

High
Category
Privilege Escalation
Content
# Load env vars from skill directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/.env" ]; then
    source "$SCRIPT_DIR/.env"
fi

# Now use the vars
Confidence
82% confidence
Finding
This source command is the concrete execution sink for the local .env file. If the env file is compromised, the script executes attacker-controlled shell before making network requests with valid bot credentials.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# 1. Copy example env file and edit
cp .env.example .env
# Edit .env with your tokens

# 2. Source the env file (or add to ~/.bashrc for auto-load)
source .env
Confidence
90% confidence
Finding
Instructing users to source a local .env file executes shell syntax from that file in the current shell, not merely loading key-value pairs. If the .env file is modified maliciously or unexpectedly, this can lead to arbitrary command execution and credential exposure in the user's session.

Credential Access

High
Category
Privilege Escalation
Content
# Option B: Create .env file (recommended)
cp .env.example .env
# Edit .env with your values
source .env
```
Confidence
90% confidence
Finding
Again, the issue is the recommendation to source `.env`, which executes shell content from a file that may be writable by other processes or accidentally contain unsafe commands. That can compromise the user's shell session and any credentials available there.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# Auto-load telegram-direct-send env vars
if [ -f "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" ]; then
    source "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env"
fi
```
Confidence
94% confidence
Finding
Adding a persistent shell startup hook that sources a skill-local `.env` file causes shell code in that file to execute automatically in future sessions. If the skill directory or .env file is modified, this becomes a persistence and arbitrary code execution vector tied to credentials present in the shell environment.

Credential Access

High
Category
Privilege Escalation
Content
```bash
# Auto-load telegram-direct-send env vars
if [ -f "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env" ]; then
    source "$HOME/.openclaw/workspace/skills/telegram-direct-send/.env"
fi
```
Confidence
94% confidence
Finding
This line is the actual persistent `source` operation, which executes whatever shell code is present in the skill's .env file on every new shell session. Because the file resides under a workspace/skills path, it may be more exposed to accidental edits or tampering than a dedicated user secret store.

Credential Access

High
Category
Privilege Escalation
Content
#!/bin/bash
# Load env vars from skill directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/.env" ]; then
    source "$SCRIPT_DIR/.env"
fi
Confidence
91% confidence
Finding
The wrapper script checks for a local .env and then sources it, which executes arbitrary shell commands if the file contents are malicious. This is especially risky in a reusable helper script because users may run it casually and assume it only loads variables.

Static analysis

No suspicious patterns detected.