Back to skill

Security audit

Telegram History

Security checks for vulnerabilities and agentic risk

Overview

This skill appears purpose-built for Telegram history retrieval, but it needs Review because it can access private Telegram messages through a user account and stores or handles login material with limited safeguards.

Install only if you intend to let the agent use a Telegram user account to read and print account-accessible message history. Prefer a dedicated Telegram account with access only to needed chats, protect or relocate api_credentials.json and session files, avoid putting 2FA passwords on the command line, and delete or revoke the Telegram session when finished.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/login.py:43
Finding

Telegram Authentication Secrets Exposed Through Command-Line Arguments

Content
View full analysis
= 5 and sys.argv[1] == "verify": phone = sys.argv[2] code = sys.argv[3] phone_code_hash = sys.argv[4] password = sys.argv[5] if len(sys.argv) > 5 else None ``` The corresponding documented commands are: ```bash python3 scripts/login.py verify +1234567890 # If 2FA is enabled, append your password: python3 scripts/login.py verify +1234567890 <2FA_PASSWORD> ``` ### Technical Analysis The verification code, phone-code hash, telephone number, and optional Telegram 2FA password are accepted as command-line arguments. Command-line secrets may be exposed through: - Shell history files. - Process inspection utilities while the command is running. - Endpoint monitoring and process-accounting systems. - Terminal session capture and command logging. - Diagnostic reports or automation logs that record executed commands. The script also prints a partially constructed verification command containing the user's telephone number and phone-code hash: ```python print(f"Run: python3 login.py verify {phone} {result.phone_code_hash}") ``` Although sending authentication data to Telegram is necessary for login, transporting these secrets through command-line arguments is not necessary and exceeds minimum-risk credential handling. ### Attack Path 1. A user follows the documented login procedure and supplies the Telegram verification code and optional 2FA password on the command line. 2. The shell records the command in its history, or a local monitoring system captures the process arguments. 3. An attacker with access to the user's shell history, process telemetry, terminal logs, or local process information obtains the te ...[truncated 946 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
SKILL.md:14
Finding

Unpinned Telethon Dependency Installed Without Integrity Verification

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/login.py:10
Finding

Reusable Telegram Session and API Credentials Lack Enforced Filesystem Protections

Content
View full analysis
/api_credentials.json << 'EOF' {"api_id": YOUR_API_ID, "api_hash": "YOUR_API_HASH"} EOF ``` ```text Session persists in `session/` — no need to re-login after initial setup. ``` ### Technical Analysis The Skill stores the Telegram API identifier, API hash, and a reusable Telethon session under the project directory. It creates the session directory without explicitly requesting mode `0700` and does not validate or enforce mode `0600` on credential and session files. Actual exposure depends on the operating system, parent-directory permissions, and the user's `umask`. On a correctly configured single-user system, generated files may already be sufficiently restricted. However, the code does not guarantee that protection. Persist ...[truncated 1620 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The provided code is solely a login utility for Telethon. It reads API credentials, creates a TelegramClient session, sends verification codes, checks whether a user is already authorized, and completes sign-in with optional 2FA. While login is mentioned in the description as a prerequisite, the declared primary purpose is message-history retrieval. None of the advertised retrieval features are present in this code chunk, so the actual behavior is materially narrower and different from the declared purpose.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

The documentation instructs users to store Telegram API credentials in a local JSON file inside the skill directory, which increases the chance of accidental disclosure through backups, repository commits, shared directories, or weak filesystem permissions. While api_id/api_hash are application credentials rather than a full account token, exposure can still enable unauthorized reuse of the Telegram app identity and facilitate further abuse when combined with session artifacts.

Content

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

2. Get API credentials

Go to https://my.telegram.org/apps and create an app. Save credentials in the skill directory:

bash
cat > <skill-dir>/api_credentials.json << 'EOF'
{"api_id": YOUR_API_ID, "api_hash": "YOUR_API_HASH"}
EOF

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

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

Content

Scanner excerpt · scripts/login.py (reported line 12)May include surrounding context.

python
SKILL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SESSION_PATH = os.path.join(SKILL_DIR, "session", "user")
CREDS_PATH = os.path.join(SKILL_DIR, "api_credentials.json")

async def main():
    with open(CREDS_PATH) as f:

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

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

Content

Scanner excerpt · scripts/tg_history.py (reported line 15)May include surrounding context.

python
SKILL_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SESSION_PATH = os.path.join(SKILL_DIR, "session", "user")
CREDS_PATH = os.path.join(SKILL_DIR, "api_credentials.json")

async def main():
    with open(CREDS_PATH) as f:

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The invocation description is overly broad and encourages use for reading history from 'any Telegram chat,' which can cause the skill to be selected for privacy-sensitive requests without strong consent or ownership checks. Because this uses a logged-in user account rather than the bot API, misuse could expose private or restricted message history available to that account.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill lacks a prominent privacy and security warning despite using MTProto user login with phone number and optional 2FA to access account-readable chat history. This is dangerous because operators may underestimate that it grants access to private messages, groups, and forum threads reachable by the authenticated user, increasing the risk of unauthorized surveillance or data over-collection.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script creates a persistent Telethon session on disk at a predictable path, which stores authentication material sufficient to access the user's Telegram account. Because the script provides no warning, consent flow, or file-permission hardening, users may unknowingly leave long-lived local credentials behind that can be reused by other local users, malware, or later automation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script is explicitly designed to fetch and export Telegram message history, including message text, sender identifiers, and topic replies, but provides no privacy notice, consent check, or usage guardrail before disclosing potentially sensitive communications. In the context of a skill whose purpose is to access messages unavailable through the bot API via a user account, this creates meaningful privacy and misuse risk because an operator can silently extract historical messages from chats they can access.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.