Create Slack integration with link unfurls - #2058
Merged
Merged
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Member
Author
|
hey @greptileai, please re-review the PR |
Member
Author
|
hey @greptileai, please re-review the PR |
| state.organizationId, | ||
| ); | ||
| await requireOrganizationSettingsManager(user.id, organizationId); | ||
| const result = await exchangeSlackOAuthCode({ |
There was a problem hiding this comment.
P2: Slack OAuth callback exchanges token before validating cross-tenant ownership
OAuth token exchange happens before cross-tenant ownership check, leaving stale credentials on rejection.
Revoke the newly issued Slack token when cross-org ownership is rejected, or check ownership after exchange and before persistence.
AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.
<file name="apps/web/app/api/integrations/slack/callback/route.ts">
<violation number="1" location="apps/web/app/api/integrations/slack/callback/route.ts:70">
<priority>P2</priority>
<title>Slack OAuth callback exchanges token before validating cross-tenant ownership</title>
<evidence>The callback exchanges the Slack OAuth code before saveSlackInstallation checks whether the workspace is already owned by another organization. Slack invalidates the previous token when issuing a new one, so a rejected cross-org installation leaves the original organization with a stale token.</evidence>
<recommendation>After exchanging the OAuth code, if saveIntegrationInstallation rejects the installation because the workspace is already owned by another organization, revoke the newly issued Slack token via auth.revoke before returning an error. Alternatively, refactor the flow to validate ownership after fetching the team identity but before persisting credentials.</recommendation>
</violation>
</file>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connect Slack workspaces from org settings so Cap share links unfurl in Slack. Adds OAuth install/callback, events webhook, oEmbed + Player.js embed support, and a provider-agnostic integration_installations store.
Greptile Summary
Adds Slack workspace integration and link unfurl support.
Confidence Score: 4/5
The OAuth ownership-rejection path must be fixed before merging because it can leave an existing workspace installation with unusable credentials.
The callback exchanges the Slack OAuth code before installation persistence checks tenant ownership; when that check rejects a cross-organization installation, the replacement token is discarded and later unfurls continue using the stale stored token.
Files Needing Attention: apps/web/app/api/integrations/slack/callback/route.ts and apps/web/lib/integrations/installations.ts
Important Files Changed
Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "fix: recover exhausted Slack event retri..." | Re-trigger Greptile