Repository navigation
Closed
Description
CVSS Assessment
| Metric | Value |
|---|---|
| Score | 7.5 / 10.0 |
| Severity | High |
| Vector | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Summary
The Telegram file download functions in download.ts make HTTP fetch calls without any timeout or AbortController. If Telegram's API becomes slow or unresponsive, these calls block indefinitely, potentially hanging the entire message processing pipeline.
Affected Code
File: src/telegram/download.ts:12-13,34
export async function getTelegramFile(token: string, fileId: string): Promise<TelegramFileInfo> {
const res = await fetch( // NO TIMEOUT - can hang forever
`https://api.telegram.org/bot${token}/getFile?file_id=${encodeURIComponent(fileId)}`,
);
// ...
}
export async function downloadTelegramFile(
token: string,
fileInfo: TelegramFileInfo,
): Promise<SavedMedia> {
// ...
const res = await fetch(url); // Line 34 - NO TIMEOUT
// ...
}Attack Surface
How is this reached?
- Network (HTTP/WebSocket endpoint, API call)
- Adjacent Network (same LAN, requires network proximity)
- Local (local file, CLI argument, environment variable)
- Physical (requires physical access to machine)
Authentication required?
- None (unauthenticated/public access)
- Low (any authenticated user)
- High (admin/privileged user only)
Entry point: Any Telegram message with an attachment (photo, document, video, etc.) triggers file download via these functions.
Exploit Conditions
Complexity:
- Low (no special conditions, works reliably)
- High (requires race condition, specific config, or timing)
User interaction:
- None (automatic, no victim action needed)
- Required (victim must click, visit, or perform action)
Prerequisites: Telegram API must experience slowdown or become unresponsive. This can occur due to:
- Telegram infrastructure issues
- Network connectivity problems
- Rate limiting or API degradation
- Malicious network interception (MITM causing TCP slowloris)
Impact Assessment
Scope:
- Unchanged (impact limited to vulnerable component)
- Changed (can affect other components, escape sandbox)
What can an attacker do?
| Impact Type | Level | Description |
|---|---|---|
| Confidentiality | None | No data exposure |
| Integrity | None | No data modification |
| Availability | High | Message processing hangs, connection pools exhaust, cascade failures in async workflows |
Steps to Reproduce
- Configure OpenClaw with Telegram integration
- Simulate slow Telegram API responses (e.g., using a proxy that delays responses)
- Send a message with an attachment to the bot
- Observe that the gateway hangs waiting for the fetch to complete
- Additional messages queue up, eventually exhausting resources
Recommended Fix
Add AbortController with timeout, consistent with patterns used elsewhere in the codebase (e.g., chrome.ts):
import { withTimeout } from "../web/web-shared.js";
const TELEGRAM_FETCH_TIMEOUT_MS = 30_000; // 30 seconds
export async function getTelegramFile(token: string, fileId: string): Promise<TelegramFileInfo> {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), TELEGRAM_FETCH_TIMEOUT_MS);
try {
const res = await fetch(
`https://api.telegram.org/bot${token}/getFile?file_id=${encodeURIComponent(fileId)}`,
{ signal: controller.signal }
);
// ...
} finally {
clearTimeout(timeoutId);
}
}References
- CWE: CWE-400 - Uncontrolled Resource Consumption
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Priority
None yet
Activity
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)
fix(telegram): add timeout to file download to prevent DoS (CWE-400)