Skip to content

fix: support special chars in password and exit on auth failure#34

Merged
sunba91-su merged 1 commit into
mainfrom
fix/bot-login-hardening
Jun 8, 2026
Merged

fix: support special chars in password and exit on auth failure#34
sunba91-su merged 1 commit into
mainfrom
fix/bot-login-hardening

Conversation

@sunba91-su

Copy link
Copy Markdown
Owner

Problem

1. Password special characters cause silent truncation

When the bot password contains #, &, (, ), etc. in the .env file, Docker Compose treats # as a comment (truncating the password) and shell interpretation can mangle other characters.

2. Auth failure triggers rapid retry loop → account locked

When login fails (wrong password/user not found), the bot retries with backoff, triggering Rocket.Chat's IP-based rate limiting and locking the account.

Fix

Fix 1 — ROCKETCHAT_BOT_PASSWORD_FILE env var

Added support for the Docker-native _FILE secret pattern: if ROCKETCHAT_BOT_PASSWORD is empty, the bot reads from ROCKETCHAT_BOT_PASSWORD_FILE instead (file content is trimmed). This avoids all shell/env escaping issues.

Fix 2 — Exit on auth error (no retry)

Added isAuthError() helper checking for 401, User not found, IP blocked. Both the initial Connect() and the reconnect loop now exit immediately with a clear message instead of retrying.

Files Changed

File Change
internal/config/config.go Added _FILE env var pattern
internal/rocket/client.go Added isAuthError(), exit on auth failure
.env.example Added ROCKETCHAT_BOT_PASSWORD_FILE documentation
README.md Added _FILE to env vars table

Closes #33

Two fixes:

1. Add ROCKETCHAT_BOT_PASSWORD_FILE env var support (Docker _FILE
   pattern). Reads password from a file, avoiding shell/env escaping
   issues with characters like #, $, &, (, ), etc.

2. Exit immediately on authentication errors (401, User not found,
   IP blocked) instead of retrying with backoff. Prevents the bot
   account from being temporarily locked due to rapid retries.

Also: document the _FILE option in .env.example and README.md.

Closes #33
@sunba91-su sunba91-su merged commit 95d8571 into main Jun 8, 2026
4 checks passed
@sunba91-su sunba91-su deleted the fix/bot-login-hardening branch June 8, 2026 16:27
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.

Bot login hardening — support special chars in password and exit on auth failure

1 participant