security: replace hardcoded BOT_TOKEN with Wrangler secrets + .env.example#2
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes hardcoded secrets from
src/index.js. Replaces withenv.BOT_TOKEN/env.CHAT_ID/env.ALLOWED_ORIGIN(Wrangler bindings) plus a.env.exampledocumenting how to set them.Background
The previous
src/index.jsshipped:8157141771:AAH...)338930874)https://itpovar.ru)GitHub secret-scanning detected the leak on 2026-02-10 as alert #1 —
secret_type: telegram_bot_token,publicly_leaked: true, state stillopenafter 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 withenv.*lookups; return 500 with a clear "set Wrangler secrets" message when any required binding is missing.env.example(new) — documentsBOT_TOKEN,CHAT_ID,ALLOWED_ORIGINwith placeholder values and thewrangler secret putcommand for each. Strictly documentation; secrets are NOT loaded from this file at runtime.What this PR does NOT do
6c25580and earlier. History rewrite is a separate operation; revoking the token is the only fix that matters.@BotFather. After revoke + rotation, the GitHub secret-scanning alert can be closed as "revoked".Test plan
node -c src/index.jsclean (syntax-OK)BOT_TOKEN.*=.*['"]literal assignments remain insrc/wrangler secret put BOT_TOKEN(with the new rotated value),wrangler secret put CHAT_ID,wrangler secret put ALLOWED_ORIGINafter merge🤖 Generated with Claude Code