Skip to content

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

@chaodu-agent

Description

@chaodu-agent

Summary

Currently, when allowed_channels is empty ([]) or omitted in config.toml, the bot responds to all channels in the Discord server. This is an "open by default" design that poses security and resource risks in production.

Current Behavior

// discord.rs
let in_allowed_channel =
    self.allowed_channels.is_empty() || self.allowed_channels.contains(&channel_id);

Empty = allow all.

Problem

  • Users who forget to configure allowed_channels unknowingly expose the bot to the entire server
  • Session pool (max_sessions = 10) can be exhausted quickly if the bot responds across many channels
  • Bot may respond with sensitive content in unintended channels

Proposed Options

Option A: Empty = deny all (secure by default)

  • Safest approach
  • Downside: new users may be confused when bot does not respond after setup
  • Mitigation: clear error log at startup: ERROR: No allowed_channels configured. Bot will not respond to any messages.

Option B: Empty = allow all + startup warning

  • Keep current behavior but log a prominent warning:
    ⚠️ No allowed_channels configured — bot will respond in ALL channels
    
  • Lower friction for development/testing

Option C: Require at least one channel (fail fast)

  • Refuse to start if allowed_channels is empty
  • Clearest signal, zero ambiguity

Recommendation

Option A or C for production safety. The cost of setting one channel ID is trivial compared to the risk of accidental full-server exposure.

References

  • src/config.rs: allowed_channels: Vec<String> with #[serde(default)]
  • src/discord.rs: is_empty() check in message handler

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp1High — address this sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions