Skip to content

security: replace hardcoded BOT_TOKEN with Wrangler secrets + .env.example#2

Merged
CreatmanCEO merged 1 commit into
mainfrom
token-cleanup
May 6, 2026
Merged

security: replace hardcoded BOT_TOKEN with Wrangler secrets + .env.example#2
CreatmanCEO merged 1 commit into
mainfrom
token-cleanup

Conversation

@CreatmanCEO
Copy link
Copy Markdown
Owner

Summary

Removes hardcoded secrets from src/index.js. Replaces with env.BOT_TOKEN / env.CHAT_ID / env.ALLOWED_ORIGIN (Wrangler bindings) plus a .env.example documenting how to set them.

Background

The previous src/index.js shipped:

  • Real Telegram bot token (8157141771:AAH...)
  • Production chat id (338930874)
  • Production origin (https://itpovar.ru)

GitHub secret-scanning detected the leak on 2026-02-10 as alert #1secret_type: telegram_bot_token, publicly_leaked: true, state still open after 3 months. The token has almost certainly been harvested by automated scrapers in that window.

What this PR does

  • src/index.js — replace inline constants with env.* lookups; return 500 with a clear "set Wrangler secrets" message when any required binding is missing
  • .env.example (new) — documents BOT_TOKEN, CHAT_ID, ALLOWED_ORIGIN with placeholder values and the wrangler secret put command for each. Strictly documentation; secrets are NOT loaded from this file at runtime.

What this PR does NOT do

  • Does not rewrite git history. The leaked token remains in commit 6c25580 and earlier. History rewrite is a separate operation; revoking the token is the only fix that matters.
  • Does not revoke the token. That must be done by the owner via @BotFather. After revoke + rotation, the GitHub secret-scanning alert can be closed as "revoked".

Test plan

  • node -c src/index.js clean (syntax-OK)
  • No BOT_TOKEN.*=.*['"] literal assignments remain in src/
  • Owner runs wrangler secret put BOT_TOKEN (with the new rotated value), wrangler secret put CHAT_ID, wrangler secret put ALLOWED_ORIGIN after merge
  • Owner closes GitHub secret-scanning alert docs: add LICENSE, README, CHANGELOG/CONTRIBUTING and validate CI #1 as "revoked"

🤖 Generated with Claude Code

…crets

⚠️ The previous src/index.js shipped a real Telegram bot token, chat id,
and production origin in the source. The token was publicly leaked in
this repo from 2026-02-10 (GitHub secret-scanning alert #1, never
resolved).

Changes:
- src/index.js — read BOT_TOKEN, CHAT_ID, ALLOWED_ORIGIN from env (Wrangler
  bindings), return 500 with a clear setup message if any is missing.
  No hardcoded values remain.
- .env.example — document the required secrets and how to set them via
  `wrangler secret put`. The file contains placeholder values only.

Note: this commit does NOT remove the leaked token from git history.
The token must be revoked via @Botfather as a separate operational step
(rotation, then `wrangler secret put BOT_TOKEN <new-token>`). After
revoke, the GitHub secret-scanning alert can be closed as "revoked":
https://github.com/CreatmanCEO/telegram-form-worker/security/secret-scanning/1

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CreatmanCEO CreatmanCEO merged commit 06c92f4 into main May 6, 2026
1 check passed
@CreatmanCEO CreatmanCEO deleted the token-cleanup branch May 6, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant