Fix Slack shared workspace returning wrong user's token - #514
Conversation
When multiple Aurora orgs share a Slack workspace, _lookup_slack_token was short-circuiting on the first org with a match. This caused users in other orgs to get "not authenticated" because their token was never checked. Now collects all matching tokens across all orgs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesCross-org Slack token aggregation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Superseded by updated review
Aurora Risk Review
Verdict: RISKY
The fix correctly resolves the multi-org token lookup bug, but the implementation introduces an unbounded per-org DB fan-out and per-user Vault secret read on every Slack webhook event. In a multi-tenant SaaS deployment with many orgs, this will cause Slack's 3-second response deadline to be breached under load, triggering retries and duplicate event processing. The Vault read amplification also risks exhausting secret-backend rate limits.
Findings
| # | Severity | File | Finding |
|---|---|---|---|
| 1 | HIGH | server/routes/slack/slack_events_helpers.py:83 |
Unbounded per-org DB fan-out on every Slack webhook event risks 3-second timeout and retry storm |
| 2 | HIGH | server/routes/slack/slack_events_helpers.py:170 |
Per-user Vault secret read for every org's tokens amplifies secret-backend load on the authentication hot path |
| 3 | MEDIUM | server/routes/slack/slack_events_helpers.py:155 |
Non-deterministic workspace credential selection in `get_user_id_from_slack_team` after aggregation |
Aurora reviews PRs for incident prevention. This is advisory only and does not block merge.
|
🔍 Aurora is reviewing this PR for incident risk. This usually takes a minute or two — findings will appear as a review when it's done. |
|
There was a problem hiding this comment.
Aurora Risk Review
Verdict: RISKY
This PR correctly fixes the multi-org token aggregation bug, but all three prior HIGH/MEDIUM infrastructure findings remain unaddressed. The per-org DB fan-out on every Slack webhook event still risks Slack's 3-second timeout and a retry storm, and the Vault secret read loop in get_user_id_from_slack_user is now exercised over a larger result set (all orgs, not just the first matching one), amplifying secret-backend load on the authentication hot path.
Findings
| # | Severity | File | Finding |
|---|---|---|---|
| 1 | HIGH | server/routes/slack/slack_events_helpers.py:83 |
Unbounded per-org DB fan-out on every Slack webhook event risks 3-second timeout and retry storm |
| 2 | HIGH | server/routes/slack/slack_events_helpers.py:170 |
Per-user Vault secret read for every org's tokens amplifies secret-backend load — now worse after aggregation |
| 3 | MEDIUM | server/routes/slack/slack_events_helpers.py:155 |
Non-deterministic workspace credential selection in get_user_id_from_slack_team after aggregation |
Aurora reviews PRs for incident prevention. This is advisory only and does not block merge.
| org_ids = _get_all_org_ids() | ||
| if not org_ids: | ||
| return [] | ||
|
|
There was a problem hiding this comment.
[HIGH] Unbounded per-org DB fan-out on every Slack webhook event risks 3-second timeout and retry storm
_lookup_slack_token still opens one DB admin connection per org (via _get_all_org_ids() → SELECT DISTINCT org_id FROM users) on every @aurora mention and every button click. With N orgs, each Slack event triggers N+1 sequential DB round-trips before a response is returned. Slack requires a 200 OK within 3 seconds or it retries — repeated retries under load will compound the fan-out. This PR's fix does not change the loop structure; it only changes what is done with results inside the loop, leaving the fan-out fully intact.



Summary
_lookup_slack_tokenwas short-circuiting on the first org with a matchRoot Cause
_lookup_slack_tokenhadif results: return resultsinside the org loop, so it never checked subsequent orgs for the same team_id.Test plan
Summary by CodeRabbit
Release Notes
Bug Fixes