Repository navigation
fix: reject unsafe Mattermost API path segments - #98390
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 6:33 AM ET / 10:33 UTC. Summary PR surface: Source +13, Tests +72. Total +85 across 4 files. Reproducibility: yes. at source level: current main concatenates the unvalidated suffix, and WHATWG URL normalization provides a concrete path-changing example. I did not establish a live failing Mattermost request during this read-only review. Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Keep the shared plugin-owned validator and both guarded transport paths, then demonstrate one rejected unsafe request and one successful normal request through a controlled HTTP endpoint before merge. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main concatenates the unvalidated suffix, and WHATWG URL normalization provides a concrete path-changing example. I did not establish a live failing Mattermost request during this read-only review. Is this the best way to solve the issue? Yes. Validating once in the plugin-owned URL builder before authorization and reusing it for the direct media path is narrower and less drift-prone than adding checks at individual callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c3bc3a72366c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +13, Tests +72. Total +85 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (9 earlier review cycles; latest 8 shown)
|
56bf468 to
64ee736
Compare
ace7ebc to
f23a132
Compare
f23a132 to
702f0c6
Compare
|
Merged via squash.
|
* Harden Mattermost API paths * fix(mattermost): guard direct media file paths * refactor(mattermost): streamline API path validation --------- Co-authored-by: Peter Steinberger <[email protected]>
* Harden Mattermost API paths * fix(mattermost): guard direct media file paths * refactor(mattermost): streamline API path validation --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #98389
What Problem This Solves
Fixes an issue where Mattermost plugin REST calls could reach a different bearer-token endpoint when a dynamic path component contained relative, URL-normalized, or malformed percent-encoded segments.
The affected workflow is Mattermost channel operation through the plugin REST client. Operators expect post, user, and channel ids to select the intended Mattermost endpoint; unsafe path-shaped values should fail before the client attaches the bot token and calls fetch.
Why This Change Was Made
The Mattermost client now rejects unsafe API path segments at one shared URL-builder boundary before preparing authorization headers. The direct authenticated media-file download path reuses the same builder. The guard handles raw
./.., encoded dot segments, backslash separator normalization, URL parser TAB/CR/LF normalization, and malformed percent encoding.Normal Mattermost paths and request bodies are unchanged. This PR does not alter token storage, account resolution, or Mattermost response handling.
User Impact
Mattermost users and operators get safer fail-closed behavior for malformed or unexpected REST path inputs. Legitimate Mattermost plugin requests continue to use the same
/api/v4endpoints.Evidence
Before/source proof:
main,buildMattermostApiUrlappended the requested suffix to/api/v4without rejecting dot segments first.http://localhost:8065/api/v4/posts/../users/meto/api/v4/users/me, so a path-shaped id can change the endpoint selected under the Mattermost bot token.After-fix proof on this branch:
node scripts/run-vitest.mjs extensions/mattermost/src/mattermost/client.test.ts extensions/mattermost/src/mattermost/monitor-resources.test.ts— 44 tests passed.saveRemoteMediareceives no request.git diff --checkpassed.No live Mattermost credentials were used. The requested mocked transport proof exercises the production shared URL builder before either authenticated transport boundary.