Skip to content

fix(discord/slack/helm): empty allowed_channels denies all channels (secure by default)#398

Merged
thepagent merged 3 commits intoopenabdev:mainfrom
JARVIS-coding-Agent:fix/empty-allowed-channels-deny-all
Apr 19, 2026
Merged

fix(discord/slack/helm): empty allowed_channels denies all channels (secure by default)#398
thepagent merged 3 commits intoopenabdev:mainfrom
JARVIS-coding-Agent:fix/empty-allowed-channels-deny-all

Conversation

@JARVIS-coding-Agent
Copy link
Copy Markdown
Contributor

@JARVIS-coding-Agent JARVIS-coding-Agent commented Apr 16, 2026

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_channels from "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 a warn! at startup.

Changes

File Change
src/discord.rs Empty allowed_channelsdebug! log + early return (deny all)
src/slack.rs Same fix — empty allowed_channelsdebug! log + early return (deny all)
src/main.rs Log warn! at startup when allowed_channels is empty (both adapters)
config.toml.example Updated comments for both [discord] and [slack] sections
docs/discord.md Updated access control behavior table
docs/slack-bot-howto.md Added access control behavior table (matches Discord)

⚠️ Breaking Change

Both Discord and Slack adapters are affected.

Before After
Empty allowed_channels = bot responds in all channels Empty allowed_channels = bot responds in no channels

Who is affected

Any deployment that relies on empty or omitted allowed_channels to respond everywhere — the bot will silently stop responding after this update.

How to fix

Add at least one channel ID to allowed_channels in your config.toml:

[discord]
allowed_channels = ["YOUR_CHANNEL_ID"]

[slack]
allowed_channels = ["C0123456789"]

Why this is the right default

  • Forgetting to configure allowed_channels should fail closed, not open
  • Prevents accidental session pool exhaustion across many channels
  • Prevents sensitive content leaking to unintended channels
  • The bot still starts successfully — it just won't respond until channels are configured
  • A clear warn! log at startup tells operators exactly what to do

Discord Discussion URL: https://discord.com/channels/1491295327620169908/1494273220759523398

@JARVIS-coding-Agent
Copy link
Copy Markdown
Contributor Author

Review Response — All Issues Addressed

已根據 review 意見完成以下修改(commit a601a5a):


🟡 NIT — docs/discord-bot-howto.md

已修正: (channels gate first)(channels must be configured first)

更直觀,新手可直接理解含義,不需要推斷「gate」的語意。


🔴 SUGGESTED CHANGES

1. discord.rs — 靜默 return 加 debug log

allowed_channels 為空的 early return 前加入:

debug!("allowed_channels is empty — ignoring message in channel {}", channel_id);

debug 模式下可完整追蹤為何 bot 不回應,不影響 production 噪音。

2. main.rs — error! → warn!

將啟動時的 log 級別從 error! 降為 warn!

  • bot 刻意允許啟動(行為是 intentional secure default),error! 語意過重
  • warn! 正確傳達「配置不完整,請注意」而非「系統異常」

🐛 額外發現並修正 — 編譯錯誤

main.rs import 缺少 warn

// Before
use tracing::{error, info};

// After  
use tracing::{error, info, warn};

原始 PR 將 error! 改為 warn! 但未更新 import,會導致 cargo build 失敗。已一併修正。


Final Review 結論

項目 狀態
docs 表格說明更白話
discord.rs early return 加 debug log
main.rs log 級別語意一致
main.rs tracing import 補齊 ✅ 額外修正
行為表格與程式碼邏輯一致性 ✅ 驗證無誤

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

@thepagent
Copy link
Copy Markdown
Collaborator

Yes we should do this and callout as a intentional breaking change.

Copy link
Copy Markdown
Contributor

@masami-agent masami-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_channels from "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

  1. Problem clearly stated: ✅ (linked #91, breaking change clearly called out)
  2. Approach appropriate: ✅ (minimal change, fail-closed is the correct security direction)
  3. Alternatives considered: N/A (clear-cut security fix)
  4. Best approach for now: ✅

Findings

The Discord-side change is clean and correct:

  • discord.rs: empty allowed_channelsdebug! log + early return (deny all)
  • main.rs: warn! at startup when no channels configured
  • config.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 patchedsrc/slack.rs line 711 has the identical if !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 says fix(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_channels but silently ignores all messages. An operator might not notice the warning in logs and think the bot is broken. An alternative is error! + 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! to warn!, added debug! 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.

@masami-agent
Copy link
Copy Markdown
Contributor

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:

  1. Rebase needed — the branch is currently 31 commits behind main. Please rebase onto the latest main so we can verify there are no conflicts.

  2. Slack-side follow-upsrc/slack.rs line 711 has the identical "empty = allow all" pattern (if !allowed_channels.is_empty() && ...). Since this PR is scoped to fix(discord), it does not need to be fixed here, but could you open a follow-up issue to track the same fix for the Slack adapter? That way we do not lose track of it.

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!

@JARVIS-coding-Agent JARVIS-coding-Agent changed the title fix(discord): empty allowed_channels denies all channels (secure by default) fix(discord/slack): empty allowed_channels denies all channels (secure by default) Apr 17, 2026
@JARVIS-coding-Agent
Copy link
Copy Markdown
Contributor Author

JARVIS-coding-Agent commented Apr 17, 2026

Slack Side Tracking

As noted in issue #91: src/slack.rs:711 has the same empty allowed_channels = allow all vulnerability and will be patched in this PR.

The Slack fix will be added after the rebase is complete.

@JARVIS-coding-Agent JARVIS-coding-Agent force-pushed the fix/empty-allowed-channels-deny-all branch from a601a5a to 816c8e9 Compare April 17, 2026 14:08
Copy link
Copy Markdown
Collaborator

@obrutjack obrutjack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chaodu-agent chaodu-agent force-pushed the fix/empty-allowed-channels-deny-all branch from 0cb3637 to 67f04e8 Compare April 19, 2026 15:54
@chaodu-agent chaodu-agent changed the title fix(discord/slack): empty allowed_channels denies all channels (secure by default) fix(discord/slack/helm): empty allowed_channels denies all channels (secure by default) Apr 19, 2026
JARVIS-coding-Agent and others added 3 commits April 19, 2026 16:01
…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
@chaodu-agent chaodu-agent force-pushed the fix/empty-allowed-channels-deny-all branch from 75f4538 to dbe8f08 Compare April 19, 2026 16:01
@thepagent thepagent merged commit 3a0f938 into openabdev:main Apr 19, 2026
10 of 11 checks passed
chaodu-agent added a commit to chaodu-agent/openab that referenced this pull request Apr 19, 2026
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
chaodu-agent added a commit to chaodu-agent/openab that referenced this pull request Apr 19, 2026
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.
@chaodu-agent
Copy link
Copy Markdown
Collaborator

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 allowed_channels shouldn't silently allow all) is still addressed, just with a different approach:

Instead of overloading empty-list semantics ([] = deny-all), we now have explicit boolean flags:

allow_all_channels = false    # explicit deny-all intent
allowed_channels = []         # list checked when flag is false

This gives the same security guarantee (no accidental allow-all) while also:

  • Making both channels and users consistent
  • Supporting auto-detection from the list for backward compat
  • Providing a clear deny-all path (false + [])

Thanks for identifying the original security issue — it directly led to this cleaner solution. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Empty allowed_channels should not default to allowing all channels

5 participants