fix(mattermost): prevent DM replies from creating threads#72659
fix(mattermost): prevent DM replies from creating threads#72659vincentkoc merged 3 commits intomainfrom
Conversation
Greptile SummaryThis PR fixes a bug where Mattermost DM replies could create thread roots by passing a Confidence Score: 5/5This PR is safe to merge; the fix is narrow, well-tested, and all call sites are updated consistently. No P0 or P1 issues found. The logic change is correct: moving the kind === 'direct' early-return before the threadRootId check in resolveMattermostEffectiveReplyToId closes the regression, and kind is forwarded at every call site of the two affected public functions. New tests cover the DM suppression path in both resolveMattermostReplyRootId and resolveMattermostEffectiveReplyToId, and the canFinalizeMattermostPreviewInPlace DM case. No files require special attention. Reviews (2): Last reviewed commit: "fix(mattermost): prevent DM replies from..." | Re-trigger Greptile |
2db932d to
1a031ae
Compare
1a031ae to
80a11bc
Compare
|
ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical. Source PR: #72659 |
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟠 DM access control bypass via fallback-to-channel when Mattermost channel lookup fails
DescriptionInbound message If Security impact:
This is a trust-boundary regression because the prior code used the websocket event’s Vulnerable code: const channelInfo = await resolveChannelInfo(channelId);
const kind = resolveMattermostTrustedChatKind({
channelType: channelInfo?.type,
});
...
const accessDecision = resolveDmGroupAccessWithLists({
isGroup: kind !== "direct",
dmPolicy,
groupPolicy,
...
});RecommendationEnsure that inability to resolve the channel type cannot cause a direct message to be treated as a channel/group. Recommended options (choose one):
const channelInfo = await resolveChannelInfo(channelId);
const channelType = channelInfo?.type?.trim();
if (!channelType) {
logVerboseMessage(`mattermost: drop post (cannot resolve channel type for ${channelId})`);
return;
}
const kind = mapMattermostChannelTypeToChatType(channelType);
const channelType = channelInfo?.type ?? payload.data?.channel_type;
const kind = resolveMattermostTrustedChatKind({
channelType,
// optionally: fallback: "channel" (explicit)
});Also consider not caching null lookups for as long (or caching with a shorter TTL) to reduce the window where misclassification can occur during transient errors. Analyzed PR: #72659 at commit Last updated on: 2026-04-27T09:36:31Z |
|
ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical. Source PR: #72659 |
…2659) * fix(mattermost): prevent DM replies from creating threads * fix(mattermost): prevent DM replies from creating threads * fix(mattermost): prevent DM replies from creating threads
…2659) * fix(mattermost): prevent DM replies from creating threads * fix(mattermost): prevent DM replies from creating threads * fix(mattermost): prevent DM replies from creating threads
Summary
Credit
This carries forward the useful fix path from @jwchmodx in #60115 and preserves related context from #55186, #59758, #59981, #59791, and #57565.
Review/Validation
ProjectClownfish replacement details: