Skip to content

fix(matrix): make auto_accept_invites configurable, default to false#711

Open
Reaster0 wants to merge 1 commit intoRightNow-AI:mainfrom
Reaster0:fix/matrix-configurable-auto-accept-invites
Open

fix(matrix): make auto_accept_invites configurable, default to false#711
Reaster0 wants to merge 1 commit intoRightNow-AI:mainfrom
Reaster0:fix/matrix-configurable-auto-accept-invites

Conversation

@Reaster0
Copy link

Summary

  • MatrixAdapter hardcoded auto_accept_invites: true, meaning any Matrix-connected instance would blindly join every room it was invited to
  • This is a security concern for public-facing homeservers — a malicious user could invite the bot into an arbitrary room and interact with the agent without the operator's consent
  • The field was not exposed in MatrixConfig, so operators had no way to disable it

Changes

  • Add auto_accept_invites: bool to MatrixConfig (openfang-types), with #[serde(default)] defaulting to false
  • Thread the field through MatrixAdapter::new() instead of hardcoding true
  • Wire it in channel_bridge.rs from mx_config.auto_accept_invites
  • Update unit tests to pass the new parameter

Migration

Breaking change in default behavior: existing setups that relied on auto-accept will need to explicitly opt in:

[channels.matrix]
auto_accept_invites = true

Test plan

  • cargo build --workspace --lib compiles
  • cargo test --workspace passes (3 updated test call sites in matrix.rs)
  • Start daemon with auto_accept_invites = false (default) — invite the bot to a room, verify it does not join
  • Set auto_accept_invites = true — invite again, verify auto-join works
  • Verify allowed_rooms filtering still applies when auto-accept is enabled

🤖 Generated with Claude Code

MatrixAdapter hardcoded `auto_accept_invites: true`, meaning any
Matrix-connected instance would blindly join every room it was invited
to. This is a security concern for public-facing homeservers — a
malicious user could invite the bot into an arbitrary room and interact
with the agent without the operator's consent.

Changes:
- Add `auto_accept_invites: bool` to `MatrixConfig` in openfang-types,
  with `#[serde(default)]` defaulting to `false`.
- Thread the field through `MatrixAdapter::new()` instead of hardcoding.
- Wire it in `channel_bridge.rs` from `mx_config.auto_accept_invites`.
- Update tests to pass the new parameter.

Operators who want the old behaviour can set:
```toml
[channels.matrix]
auto_accept_invites = true
```

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Member

@jaberjaber23 jaberjaber23 left a comment

Choose a reason for hiding this comment

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

Clean, minimal, security-positive change. Threads auto_accept_invites from config through channel_bridge to MatrixAdapter correctly. Default false is the right secure-by-default posture. Call chain verified complete. Tests updated.

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.

2 participants