Repository navigation
Slack: filter thread context by allowlist - #58380
jacobtomlinson merged 5 commits into
Conversation
Greptile SummaryThis PR adds allowlist-aware filtering to Slack thread context resolution. Before building thread context (starter body + history body), it now checks both the thread-root message and each history entry against the effective allowlist — dropping non-allowlisted messages while always preserving bot messages (which represent prior agent turns). The Key changes:
The implementation is logically consistent: the same Confidence Score: 5/5This PR is safe to merge — the allowlist filtering is correct, bots are consistently allowed, and the change is well-covered by focused regression tests. No P0 or P1 issues were found. The logic in No files require special attention. Reviews (1): Last reviewed commit: "Slack: filter thread context by allowlis..." | Re-trigger Greptile |
🔒 Aisle Security AnalysisWe found 2 potential security issue(s) in this PR:
1. 🟠 Slack thread context allowlist can be bypassed via mutable/non-unique display name matching
Description
When Impact:
Vulnerable flow:
Vulnerable code: const starterSenderName =
params.allowNameMatching && starter?.userId
? (await params.ctx.resolveUserName(starter.userId))?.name
: undefined;
...
return resolveSlackAllowListMatch({
allowList: params.allowFromLower,
id: params.userId,
name: params.userName,
allowNameMatching: params.allowNameMatching,
}).allowed;Additionally, RecommendationDo not use mutable/non-unique display names to make enforcement decisions. Recommended fix options (pick one):
return resolveSlackAllowListMatch({
allowList: params.allowFromLower,
id: params.userId,
// name: undefined,
allowNameMatching: false,
}).allowed;
Also add tests asserting that a non-allowlisted user ID with a spoofed name does not pass when the allowlist is intended to restrict access. 2. 🟠 Slack thread context allowlist bypass for bot messages (bot_id => allowed)
DescriptionThe Slack thread context allowlist check is bypassed for any message that has a
Vulnerable code: if (params.allowFromLower.length === 0 || params.botId) {
return true;
}RecommendationDo not treat Options (choose one based on intended policy):
function isSlackThreadContextSenderAllowed(p: {
allowFromLower: string[];
allowNameMatching: boolean;
userId?: string;
userName?: string;
botId?: string;
}): boolean {
if (p.allowFromLower.length === 0) return true;
const senderId = p.userId ?? p.botId; // decide identifier scheme
if (!senderId) return false;
return resolveSlackAllowListMatch({
allowList: p.allowFromLower,
id: senderId,
name: p.userName,
allowNameMatching: p.allowNameMatching,
}).allowed;
}
if (p.botId && p.botId === ctx.botId /* or configured app/bot id */) return true;Also consider a separate configuration for allowing/disallowing third‑party bot messages in thread context. Analyzed PR: #58380 at commit Last updated on: 2026-04-02T10:23:22Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa9c3315a9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
aa9c331 to
c259cf5
Compare
🔒 Aisle Security AnalysisWe found 2 potential security issue(s) in this PR:
1. 🟠 Authorization allowlist can be bypassed via mutable/non-unique Slack display names when allowNameMatching is enabled
Description
This is risky for authorization because
Vulnerable code (new usage): const starterSenderName =
params.allowNameMatching && starter?.userId
? (await params.ctx.resolveUserName(starter.userId))?.name
: undefined;
...
return resolveSlackAllowListMatch({
allowList: params.allowFromLower,
id: params.userId,
name: params.userName,
allowNameMatching: params.allowNameMatching,
}).allowed;Additional context: RecommendationUse only stable, unique identifiers for authorization.
Example safer change (in // Prefer immutable/stable handle for authorization contexts
const handle = info.user?.name || undefined;
return { name: handle };Or better, avoid passing 2. 🟠 Slack thread context allowlist bypass for bot messages (botId treated as implicitly trusted)
DescriptionThe Slack thread context filtering logic treats any message with a
Vulnerable code: if (params.allowFromLower.length === 0 || params.botId) {
return true;
}This behavior is also validated by the new test case, which expects a bot reply to remain in context even when a user is blocked by allowlist. RecommendationDo not implicitly trust bot messages when an allowlist is configured. Options (pick one based on desired product behavior):
function isSlackThreadContextSenderAllowed(p: {
allowFromLower: string[];
allowNameMatching: boolean;
userId?: string;
userName?: string;
botId?: string;
}): boolean {
if (p.allowFromLower.length === 0) return true;
// If allowlist is active, do NOT auto-allow bots.
if (!p.userId) return false;
return resolveSlackAllowListMatch({
allowList: p.allowFromLower,
id: p.userId,
name: p.userName,
allowNameMatching: p.allowNameMatching,
}).allowed;
}
Also consider documenting the security implications if bot messages are intentionally included, and provide a config flag to disable including bot messages in context when Analyzed PR: #58380 at commit Last updated on: 2026-03-31T13:12:35Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c259cf5df7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c259cf5 to
192e333
Compare
|
Addressing the automated review notes:
|
53ed148 to
148c2c5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 148c2c55d7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edb2579d6e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
99090ed to
c4a750d
Compare
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
* Slack: filter thread context by allowlist * Slack: honor room thread allowlists * Slack: keep open-room thread context * Slack: keep non-room thread context * Changelog: add Slack thread context fix
Summary
Changes
allowNameMatchingbehavior in thread contextValidation
pnpm test -- extensions/slack/src/monitor/message-handler/prepare-thread-context.test.tspnpm buildNotes
resolveSlackThreadContextData, which exercises the vulnerable thread-context seam directly