fix: harden Mattermost slash callback auth#2404
Open
BingqingLyu wants to merge 1 commit intomainfrom
Open
Conversation
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.
Fix Summary
Mattermost native slash commands were insecure in two ways: when
commands.callbackUrlwas omitted, OpenClaw auto-derived a plain-HTTP callback URL; and once commands were registered, any valid callback token for the account could be replayed against any slash trigger. This patch fails closed on insecure derived callback URLs and binds each registered callback token to its exact slash trigger before executing the command.Issue Linkage
Fixes openclaw#65624
Security Snapshot
Implementation Details
Files Changed
docs/channels/mattermost.md(+4/-1)docs/gateway/configuration-reference.md(+2/-0)extensions/mattermost/src/mattermost/monitor-slash.test.ts(+25/-11)extensions/mattermost/src/mattermost/monitor-slash.ts(+13/-0)extensions/mattermost/src/mattermost/slash-http.send-config.test.ts(+2/-0)extensions/mattermost/src/mattermost/slash-http.test.ts(+17/-2)extensions/mattermost/src/mattermost/slash-http.ts(+24/-1)extensions/mattermost/src/mattermost/slash-state.ts(+12/-0)Technical Analysis
The slash registration path previously accepted a derived
http://...callback when operators omittedcommands.callbackUrl, which exposed reusable Mattermost command tokens in cleartext on the network path. Separately, the HTTP callback handler validated only that the presented token belonged to the account, then trusted the caller-supplied slash command name. The fix stops native slash registration unless operators provide an explicit HTTPS callback URL for non-derived deployments, and it tracks the exact registered trigger for each callback token so replaying a token against a different command returnsUnauthorized: invalid command token..Validation Evidence
pnpm test extensions/mattermost/src/mattermost/slash-http.test.tspnpm test extensions/mattermost/src/mattermost/slash-http.send-config.test.tspnpm test extensions/mattermost/src/mattermost/monitor-slash.test.tsRisk and Compatibility
commands.callbackUrl; valid callbacks keep working once configuredAI-Assisted Disclosure