Skip to content

fix(slack-bot): scope error/rejection replies to the requesting user only - #1245

Merged
kantord merged 2 commits into
mainfrom
issue-1242
Sep 9, 2026
Merged

kantord merged 2 commits into
mainfrom
issue-1242

Conversation

@kantord

@kantord kantord commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #1242. agentSessions.ts sent every reply — including auth-rejection, rate-limit, and
operational-failure messages — via bolt's say() (chat.postMessage). In a channel or group
thread that's visible to everyone, not just the person who triggered it: a rejected user's
attempt was being outed to the whole channel.

  • NOT_AUTHORIZED_MESSAGE, RATE_LIMITED_MESSAGE, and FAILURE_MESSAGE now go out via
    chat.postEphemeral (visible only to the requesting user) for the channel/group code paths
    (app_mention and the channel message handler).
  • DM behavior is unchanged — a DM is already private to the bot and that one person, so say()
    there has no visibility problem.
  • Successful prompt replies (the actual agent output) are untouched, still say().

Out of scope: #1241 (pluggable AccessResolver) is a separate, independent issue from the same
review pass — not touched here.

Test plan

  • pnpm run lint (biome) — clean
  • pnpm run typecheck — no new errors (pre-existing @stacklok/mecatl-sdk module-resolution
    errors in bridge.ts/env.ts are unrelated, from the unbuilt SDK dependency)
  • New test/agentSessions.test.ts (6 cases): unauthorized/rate-limited/failed app_mention →
    chat.postEphemeral; successful app_mention → still say(); DM rejection → still say();
    unauthorized channel-thread follow-up → chat.postEphemeral
  • pnpm vitest run for the package's non-daemon-dependent suites (env/rateLimit/agentSessions)

Fully or partially written by an AI agent.

…only (#1242)

NOT_AUTHORIZED_MESSAGE, RATE_LIMITED_MESSAGE, and FAILURE_MESSAGE broadcast
to the whole channel/group thread via say()/chat.postMessage, publicly
outing a rejected user's attempt to everyone else in the thread. Route
those three through chat.postEphemeral in channel/group contexts instead,
visible only to the triggering user; DM behavior is unchanged since a DM
is already private to that one person.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@samuv samuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The overall approach makes sense: chat.postEphemeral is the right primitive for channel/group rejection and failure responses, while successful output and DM behavior should remain unchanged.

One change is needed before approval:

[P2] Fail closed when the requesting user is unavailable

privateNotifier() falls back to the channel-visible say() when user is undefined. Slack's AppMentionEvent.user is optional, and isAllowed() can reject that exact case when an allowlist is configured. The fallback would then publicly send NOT_AUTHORIZED_MESSAGE, preserving the privacy leak this PR is intended to eliminate. The same fallback can expose rate-limit or operational-failure messages.

Please ignore/log userless channel events (or reject them before constructing the notifier) rather than falling back to a public reply, and add a regression test covering an app mention without user.

…ting user id is unknown

Review feedback on #1245: privateNotifier() fell back to the channel-visible
say() when the Slack event carried no user id — but that's exactly the case
isAllowed() can reject on with an allowlist configured, so the fallback
would still publicly broadcast NOT_AUTHORIZED_MESSAGE (and could do the
same for a rate-limit or failure reply), recreating the leak this PR exists
to close.

Ignore/log a userless app_mention or channel message up front instead of
constructing a notifier for it at all; ephemeralNotifier() now requires a
real user id and has no say() fallback. Adds regression tests for both
userless paths.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord

kantord commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

Fixed in f750eb2 — thanks for catching this.

ephemeralNotifier() now requires a real user id (no more string | undefined) and has no
say() fallback. Both app_mention and the channel message handler now check for a missing
user id up front and ignore/log the event before ever constructing a notifier, so there's no
path left where a rejection/rate-limit/failure reply can leak to the channel. Added regression
tests covering both userless paths.

Fully or partially written by an AI agent.

@kantord
kantord enabled auto-merge (squash) September 9, 2026 08:32

@samuv samuv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-reviewed at f750eb212cd9c2a575050f49e0c4369b707b5f49. The follow-up fixes the privacy fallback cleanly: userless channel events now fail closed before a notifier is constructed, ephemeralNotifier requires a concrete user ID, and regression tests cover both userless event paths. No further findings.

@kantord
kantord merged commit fc155c6 into main Sep 9, 2026
29 checks passed
@kantord
kantord deleted the issue-1242 branch September 9, 2026 08:34
JAORMX pushed a commit that referenced this pull request Sep 9, 2026
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.

Slack bot: scope error/rejection replies to the requesting user only (ephemeral, not channel-visible)

2 participants