Repository navigation
fix(slack-bot): scope error/rejection replies to the requesting user only - #1245
Conversation
…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
left a comment
There was a problem hiding this comment.
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]>
|
Fixed in f750eb2 — thanks for catching this.
Fully or partially written by an AI agent. |
samuv
left a comment
There was a problem hiding this comment.
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.
…only (#1245) Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
Fixes #1242.
agentSessions.tssent every reply — including auth-rejection, rate-limit, andoperational-failure messages — via bolt's
say()(chat.postMessage). In a channel or groupthread 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, andFAILURE_MESSAGEnow go out viachat.postEphemeral(visible only to the requesting user) for the channel/group code paths(
app_mentionand the channelmessagehandler).say()there has no visibility problem.
say().Out of scope: #1241 (pluggable
AccessResolver) is a separate, independent issue from the samereview pass — not touched here.
Test plan
pnpm run lint(biome) — cleanpnpm run typecheck— no new errors (pre-existing@stacklok/mecatl-sdkmodule-resolutionerrors in
bridge.ts/env.tsare unrelated, from the unbuilt SDK dependency)test/agentSessions.test.ts(6 cases): unauthorized/rate-limited/failed app_mention →chat.postEphemeral; successful app_mention → stillsay(); DM rejection → stillsay();unauthorized channel-thread follow-up →
chat.postEphemeralpnpm vitest runfor the package's non-daemon-dependent suites (env/rateLimit/agentSessions)Fully or partially written by an AI agent.