Skip to content

fix(slack): Require workspace membership for messages - #1936

Merged
dcramer merged 4 commits into
mainfrom
fix/slack-membership-fail-closed
Sep 25, 2026
Merged

dcramer merged 4 commits into
mainfrom
fix/slack-membership-fail-closed

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Reject messages unless the author's team matches the installation workspace. Use source_team only when user_team is absent. No membership lookup fallback.
  • Check webhook and Chat SDK input before storage, queueing, or reactions.
  • Use @slack/types for event fields, fixtures, and Block Kit output. Validate untyped input instead of casting it.

Validation

  • 375 tests pass across 41 files, including Slack ingress, output, and durable queue coverage.
  • Typecheck, lint, test architecture, formatting, and diff checks pass.

via David Cramer.

--

View Junior Session [Sentry]

@vercel

vercel Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 25, 2026 5:40pm UTC

Request Review

Remove redundant checks and repeated test cases. Keep unknown authors blocked.

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior sentry-junior Bot changed the title fix(slack): Reject messages with unknown workspace membership fix(slack): Require workspace membership for messages Sep 25, 2026
Validate ingress fields against Slack contracts and remove unchecked membership casts. Use upstream Block Kit types and raw event fixtures.

Co-Authored-By: David Cramer <[email protected]>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Sep 25, 2026
Share assistant callback parsing, keep membership validation local, and remove unused type plumbing and repeated prose.

Co-Authored-By: David Cramer <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

1 screenshot change — 1 changed · 0 added · 0 removed

Review screenshots in Frameshift

Conversation Detail · Desktop
Conversation Detail · Desktop
Changed

@sentry-evals

sentry-evals Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

In progress

junior-behavioral

Run Status
Base Pending
Head (CI run) Complete

@sentry-evals

sentry-evals Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

In progress

junior-integration

Run Status
Base Pending
Head (CI run) Complete

@dcramer
dcramer merged commit 2d61c76 into main Sep 25, 2026
49 of 51 checks passed
@dcramer
dcramer deleted the fix/slack-membership-fail-closed branch September 25, 2026 18:08
dcramer added a commit that referenced this pull request Sep 25, 2026
Follow up on #1936. Replace copied Slack types and payload casts with
SDK types. Keep local validation only where the SDK types are
incomplete.

Reject malformed files, blocks, previews, and timestamps before Chat SDK
parses them. Preserve nested message content.

Validate slash-command IDs once and carry their types into the handler.
Remove the synthetic SDK event, duplicate checks, and redundant
component tests.

<!-- junior-request-attribution:start -->
via **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1790359713.639289 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1790359713.639289)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1790359713.639289/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>
dcramer added a commit that referenced this pull request Nov 12, 2026
…e no user (#3213)

Some app integrations, such as HackerOne, post `bot_message` events that
have a `bot_id` and no `user`. Since #1936, `isSlackWorkspaceMember`
returns false for these events, so the webhook drops them before
channel-message automations can match. Because of this, #2197's
`match.user_id` cannot name these bots. A channel-message automation
filtered on HackerOne's bot ID has had zero runs.

This change adds a narrow path for these posts. Per review, it uses a
workspace + bot check, not an allowlist.

- **Channel scope:** `slackChannelScope` reads the signed envelope once.
A `workspace` channel needs `is_ext_shared_channel: false`,
`context_team_id` equal to `team_id`, and no `context_enterprise_id`
([callback
fields](https://docs.slack.dev/apis/events-api#callback-field)). Any
other envelope is `unknown` and drops the post. An Enterprise Grid
install drops these posts too.
- **Bot check:** `slackWorkspaceBotId` sits next to
`isSlackWorkspaceMember` and uses the same cache TTLs:
- If the event has `bot_profile`, its `id` must match `bot_id`, its
`team_id` must be this workspace, and it must not be deleted. No lookup.
- Otherwise, `bots.info` must return the bot, not deleted. If the bot
has a `user_id`, `users.info` must return a bot user in this workspace
that is not deleted.
- A classic integration has no bot user, so it is accepted on the
channel scope alone. Production spans suggest HackerOne (`B09LC7U21UG`)
is this case.
- **Automations only:** these posts never start a Turn. A post that
mentions Junior runs nothing, the same as a mention from a person.
- **Exact opt-in:** only automations that name the bot ID in
`match.user_id` run. The Event gets a typed author (`{ kind: "bot",
botId }`), so the summary no longer guesses the kind from the ID's
format. Member posts and bot posts share one ingest helper.

Link previews read the same channel scope and skip only `external`.
Their behavior does not change.

`slack.message.ingress` now records `app.slack.context_team_id` and
`app.slack.context_enterprise_id`, so a dropped bot post can be traced
to its envelope.

#2034 is still open. This PR answers it only for channel-message
automations and leaves Workflow mentions as they are.

<!-- junior-request-attribution:start -->
via @markatsentry, @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A3daf59e82cad7da4d1222db396136948 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A3daf59e82cad7da4d1222db396136948)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A3daf59e82cad7da4d1222db396136948/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Mark Collao <[email protected]>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — ce1feadd Deployed Sep 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant