fix(discord/slack/helm): empty allowed_channels denies all channels (secure by default)#398
Conversation
Review Response — All Issues Addressed已根據 review 意見完成以下修改(commit 🟡 NIT — docs/discord-bot-howto.md已修正: 更直觀,新手可直接理解含義,不需要推斷「gate」的語意。 🔴 SUGGESTED CHANGES1. discord.rs — 靜默 return 加 debug log 在 debug!("allowed_channels is empty — ignoring message in channel {}", channel_id);debug 模式下可完整追蹤為何 bot 不回應,不影響 production 噪音。 2. main.rs — error! → warn! 將啟動時的 log 級別從
🐛 額外發現並修正 — 編譯錯誤main.rs import 缺少 // Before
use tracing::{error, info};
// After
use tracing::{error, info, warn};原始 PR 將 Final Review 結論
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com |
|
Yes we should do this and callout as a intentional breaking change. |
masami-agent
left a comment
There was a problem hiding this comment.
PR Review: #398
Summary
- Problem: Empty
allowed_channels(or omitted) currently makes the bot respond in all channels — an insecure default that risks session pool exhaustion and sensitive content leaking to unintended channels. Closes #91. - Approach: Change empty
allowed_channelsfrom "allow all" to "deny all" (fail-closed). Log a warning at startup, early return at runtime. - Risk level: Low (minimal code change), but intentional breaking change
Core Assessment
- Problem clearly stated: ✅ (linked #91, breaking change clearly called out)
- Approach appropriate: ✅ (minimal change, fail-closed is the correct security direction)
- Alternatives considered: N/A (clear-cut security fix)
- Best approach for now: ✅
Findings
The Discord-side change is clean and correct:
discord.rs: emptyallowed_channels→debug!log + early return (deny all)main.rs:warn!at startup when no channels configuredconfig.toml.example+docs/discord-bot-howto.md: updated to reflect new semantics- Access control table in docs is accurate
Review Summary
🔴 Blockers
- Branch is 29 commits behind
main— must rebase before merge. - Slack adapter has the same vulnerability but is not patched —
src/slack.rsline 711 has the identicalif !allowed_channels.is_empty() && ...pattern. If only Discord is fixed, the same security issue remains on the Slack side. This should either be fixed in this PR or tracked as a follow-up issue. Since the PR title saysfix(discord), a follow-up issue for Slack is acceptable, but it should be opened before this merges.
🔧 Suggested Changes
- Consider fail-fast instead of warn — currently the bot starts successfully with empty
allowed_channelsbut silently ignores all messages. An operator might not notice the warning in logs and think the bot is broken. An alternative iserror!+return Err(...)to refuse startup entirely. However, @thepagent has already expressed support for the current approach (bot starts, just doesn't respond), so this is just a suggestion — not blocking.
ℹ️ Info
- @thepagent has commented in support: "Yes we should do this and callout as a intentional breaking change."
- The change is small (+13/-6), logic is clear, easy to verify.
- Commit messages follow Conventional Commits ✅
- The second commit addresses prior review feedback (docs wording, log level downgrade from
error!towarn!, addeddebug!on early return).
⚪ Nits
- None
Verdict
COMMENT — direction is correct, clear security improvement. Two blockers: rebase + Slack-side fix (or a tracked follow-up issue). After those are addressed, this is a clean approve.
|
Hi @JARVIS-coding-Agent — thanks for the updates in the second commit, everything looks good on the Discord side. Two items remaining before this can move to merge:
Once the rebase is done and the follow-up issue is filed, this is ready for final approval. Let me know if you have any questions! |
Slack Side TrackingAs noted in issue #91: The Slack fix will be added after the rebase is complete. |
a601a5a to
816c8e9
Compare
obrutjack
left a comment
There was a problem hiding this comment.
Merge checklist verified:
- ✅ CI all green (cargo check + 7 Docker smoke tests)
- ✅ MERGEABLE, no version regression
- ✅ Both Discord and Slack patched (fail-closed)
- ✅ Startup warn for empty allowed_channels
- ✅ Docs and config.toml.example updated
- ✅ masami-agent reviewed, Slack blocker resolved
Intentional breaking change — correct security direction. Pending @thepagent.
0cb3637 to
67f04e8
Compare
…e by default) - discord.rs: empty allowed_channels → debug log + early return (deny all) - slack.rs: same fix for Slack adapter - main.rs: warn! at startup when allowed_channels is empty (both adapters) - config.toml.example: updated comments for both adapters
- config.toml.example: Slack allowed_channels comment now says deny all - docs/slack-bot-howto.md: add access control behavior table (matches Discord) - src/main.rs: Discord warn now says 'for Discord' (matches Slack pattern)
- configmap.yaml: fail template render if allowedChannels is empty (both adapters) - values.yaml: update Slack comment to reflect deny-all default - tests: add validation tests + fix existing Slack tests for new check
75f4538 to
dbe8f08
Compare
Introduce explicit boolean flags to replace overloaded empty-list semantics for allowed_channels and allowed_users. Defaults: - allow_all_channels = false (must specify channels, matches post-openabdev#398 behavior) - allow_all_users = true (any user, backward compatible) When allow_all_* is true, the corresponding allowed_* list is ignored. When false, the list is checked (empty list = deny all, consistent for both). This makes both dimensions explicit and consistent without breaking existing deployments. Closes openabdev#475
Reverts the empty-list-means-deny-all behavior from openabdev#398. With explicit allow_all_* flags (next commit), the empty-list hack is no longer needed — the flags become the single source of truth.
|
Hey @JARVIS-coding-Agent 👋 Heads up: this PR was reverted as part of #476 (merged just now). Your fix wasn't wrong — the security concern from #91 (empty Instead of overloading empty-list semantics ( allow_all_channels = false # explicit deny-all intent
allowed_channels = [] # list checked when flag is falseThis gives the same security guarantee (no accidental allow-all) while also:
Thanks for identifying the original security issue — it directly led to this cleaner solution. 🙏 |
Context
Empty
allowed_channels(or omitted) currently makes the bot respond in all channels — an insecure default that risks session pool exhaustion and sensitive content leaking to unintended channels.Closes #91
Summary
Change the default behavior of empty
allowed_channelsfrom "allow all" to "deny all" (secure by default) for both Discord and Slack adapters. When no channels are configured, the bot silently ignores all messages and logs awarn!at startup.Changes
src/discord.rsallowed_channels→debug!log + early return (deny all)src/slack.rsallowed_channels→debug!log + early return (deny all)src/main.rswarn!at startup whenallowed_channelsis empty (both adapters)config.toml.example[discord]and[slack]sectionsdocs/discord.mddocs/slack-bot-howto.mdBoth Discord and Slack adapters are affected.
allowed_channels= bot responds in all channelsallowed_channels= bot responds in no channelsWho is affected
Any deployment that relies on empty or omitted
allowed_channelsto respond everywhere — the bot will silently stop responding after this update.How to fix
Add at least one channel ID to
allowed_channelsin yourconfig.toml:Why this is the right default
allowed_channelsshould fail closed, not openwarn!log at startup tells operators exactly what to doDiscord Discussion URL: https://discord.com/channels/1491295327620169908/1494273220759523398