cuhibot

🛡️ Cuhi Bot Security Policy

Security is a paramount concern for the Cuhi Bot team. Since this bot is designed to handle user authentication cookies for social media platforms (Instagram, TikTok, Facebook, Twitter/X) and process private media files, it is engineered with strict privacy and security guardrails.

This document outlines our security practices, how to report vulnerabilities, and best practices for securely running your own instance of Cuhi Bot.


🚨 Reporting a Vulnerability

DO NOT report security vulnerabilities via public GitHub issues.

If you discover a security vulnerability in Cuhi Bot, please report it immediately via private email so that we can patch it before it is exploited in the wild.

Please include the following information in your report:


🔒 Security Principles

Cuhi Bot is built on the following core security principles:

  1. Self-Hosted Privacy: We do not collect telemetry, user data, or analytics. Your data, cookies, and downloaded media remain entirely on your own server.
  2. Least Privilege: The application runs with the minimum permissions required. We strongly recommend running Cuhi Bot in a Docker container or a dedicated, restricted user account.
  3. Strict Isolation: User data and history files are segregated. A user cannot access or trigger downloads using another user’s cookie profile.
  4. Data Integrity: We utilize OS-level file locking (fcntl on Unix, msvcrt on Windows) to prevent race conditions and file corruption when multiple users access the JSON data stores simultaneously.
  5. Input Sanitization: All URLs passed to the bot via Telegram messages or the Mini App are strictly validated against allow-listed regex patterns before being passed to underlying download engines (gallery-dl, yt-dlp).

🛡️ Access Control & Hardening

When deploying Cuhi Bot, administrators are highly encouraged to utilize the built-in security features to harden their instance:

1. User Allowlists

Cuhi Bot is NOT a public bot by default. You should configure the ALLOWED_USERS environment variable with a comma-separated list of Telegram User IDs. If a user is not on this list, the bot will silently ignore all their messages and block their access to the Mini App dashboard.

2. Admin System

The /admin panel is restricted via the ADMIN_IDS environment variable. Only these users can globally restart the bot, view system metrics, or manage global configurations.

3. Telegram WebApp Validation

The Mini App backend (server.py) does not trust client-side data. All API requests from the Mini App must include the initData payload from Telegram. The server cryptographically verifies this payload against your BOT_TOKEN using HMAC-SHA256 to ensure the request genuinely originated from the authenticated Telegram user.

4. Safe Payload Limits

To protect the server from Out-Of-Memory (OOM) crashes and the Telegram API from rate limits, Cuhi Bot automatically skips individual files larger than 50MB and groups uploads into maximum batches of 10 items.


⚠️ Administrator Responsibilities

While we secure the codebase, the security of the host environment is your responsibility:


Stay safe and keep your archives secure.