Skip to content

add sender allowlist for per-chat access control#705

Merged
gavrielc merged 2 commits intoqwibitai:mainfrom
akshan-main:feat/sender-allowlist
Mar 4, 2026
Merged

add sender allowlist for per-chat access control#705
gavrielc merged 2 commits intoqwibitai:mainfrom
akshan-main:feat/sender-allowlist

Conversation

@akshan-main
Copy link
Copy Markdown
Contributor

@akshan-main akshan-main commented Mar 4, 2026

Per discussion on discord, this is the core version Gavriel requested.

Sender-based access control at the orchestrator level. Two modes:

  • Trigger: store all messages for context, only allowed senders can activate the agent
  • Drop: messages from denied senders are not stored at all

Everyone is allowed by default. No behavior change unless the user creates ~/.config/nanoclaw/sender-allowlist.json.

Addresses #678
Modified from #679

Type of Change

  • Skill - adds a new skill in .claude/skills/
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code

Description

Right now any participant in a registered group can trigger the agent by @-mentioning it. In larger groups this burns tokens on unwanted activations.

This adds pre-agent sender filtering. Denied senders never invoke the agent (zero compute cost for their triggers).

Changes:

  • src/sender-allowlist.ts — config loader, isSenderAllowed, shouldDropMessage, isTriggerAllowed
  • src/sender-allowlist.test.ts — 19 tests
  • src/config.tsSENDER_ALLOWLIST_PATH constant
  • src/db.ts — add is_from_me to two SELECT projections so trigger checks can bypass for self-sent messages
  • src/index.ts — import + two trigger checks + onMessage drop logic
  • groups/main/CLAUDE.md — registration flow guidance (recommend allow-only for closed groups)

Simplified per Gavriel's request (vs #679):

  • No deny list
  • No mtime caching (reads file each call, it's tiny JSON)
  • No failMode config (hardcoded fail-open)
  • is_from_me explicitly bypasses in trigger checks. is_bot_message filtered by DB query (AND is_bot_message = 0) before reaching trigger evaluation — same end result.

How to test

npm run build
npm test

Comment thread groups/main/CLAUDE.md

After registering a group, explain the sender allowlist feature to the user:

> This group can be configured with a sender allowlist to control who can interact with me. There are two modes:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
> This group can be configured with a sender allowlist to control who can interact with me. There are two modes:
> This group can be configured with a sender allowlist so only specific members can interact with me. There are two modes:

Comment thread groups/main/CLAUDE.md
> - **Trigger mode** (default): Everyone's messages are stored for context, but only allowed senders can trigger me with @{AssistantName}.
> - **Drop mode**: Messages from non-allowed senders are not stored at all.
>
> For closed groups with trusted members, I recommend setting up an allow-only list so only specific people can trigger me. Want me to configure that?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
> For closed groups with trusted members, I recommend setting up an allow-only list so only specific people can trigger me. Want me to configure that?
> Unless this is a closed groups with only trusted members, I recommend setting up an allow-only list so only specific people can trigger me. Want me to configure that?

Comment thread groups/main/CLAUDE.md
Comment on lines +218 to +220
- Your own messages (`is_from_me`) explicitly bypass the allowlist in trigger checks. Bot messages are filtered out by the database query before trigger evaluation, so they never reach the allowlist.
- If the config file doesn't exist or is invalid, all senders are allowed (fail-open)
- The config file is on the host at `~/.config/nanoclaw/sender-allowlist.json`, not inside the container
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Your own messages (`is_from_me`) explicitly bypass the allowlist in trigger checks. Bot messages are filtered out by the database query before trigger evaluation, so they never reach the allowlist.
- If the config file doesn't exist or is invalid, all senders are allowed (fail-open)
- The config file is on the host at `~/.config/nanoclaw/sender-allowlist.json`, not inside the container
- The config file is on the host at `~/.config/nanoclaw/sender-allowlist.json`

@gavrielc
Copy link
Copy Markdown
Collaborator

gavrielc commented Mar 4, 2026

@akshan-main Great PR, thank you for the quick turnaround. This is a great addition to NanoClaw's security model and helps make it more robust.

@gavrielc gavrielc merged commit 4de981b into qwibitai:main Mar 4, 2026
1 check passed
jenskock pushed a commit to jenskock/nanoclaw that referenced this pull request Mar 6, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
idgmatrix pushed a commit to Gurufin-AI/nanoclaw that referenced this pull request Mar 9, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
bebekim pushed a commit to bebekim/goodclaw that referenced this pull request Mar 14, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
bogdano2 pushed a commit to bogdano2/nanoclaw that referenced this pull request Mar 17, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
moey823 added a commit to moey823/nanoclaw that referenced this pull request Mar 26, 2026
Merged upstream changes including:
- DB query limits (qwibitai#692/qwibitai#735)
- Timezone-aware context injection (qwibitai#691)
- SDK bump to 0.2.68
- update_task tool and task ID passthrough
- Sender allowlist (qwibitai#705)
- Atomic task claiming (qwibitai#657)

Resolved conflicts in index.ts (sender allowlist + our steering/cancel),
ipc.ts (idempotency check + taskId passthrough), and task-scheduler.ts
(computeNextRun refactor + our cost tracking/alerting).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
onlyforart referenced this pull request in onlyforart/nanoclaw Mar 27, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
XiRoSe pushed a commit to XiRoSe/nova-agent that referenced this pull request Apr 9, 2026
dm-j pushed a commit to dm-j/nanoclaw that referenced this pull request Apr 13, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
talmosko-code pushed a commit to talmosko-code/nanoclaw that referenced this pull request Apr 28, 2026
* feat: add sender allowlist for per-chat access control

* style: fix prettier formatting
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