fix(slack): guard relay WebSocket frame JSON.parse against malformed input#98587
Merged
vincentkoc merged 2 commits intoJul 1, 2026
Merged
Conversation
vincentkoc
force-pushed
the
fix/slack-relay-json-parse-guard
branch
from
July 1, 2026 11:36
75c64eb to
821040d
Compare
…input Slack Socket Mode relay receives WebSocket frames from external infrastructure. parseRelayFrame() used bare JSON.parse() which would throw raw SyntaxError on malformed frames, potentially crashing the relay connection. Wrap JSON.parse in try/catch and throw SlackRelayMalformedFrameError with the original SyntaxError as cause, so callers can distinguish transport errors from parse errors. D4 dimension — all competitors have zero coverage. Signed-off-by: lsr911 <[email protected]>
vincentkoc
force-pushed
the
fix/slack-relay-json-parse-guard
branch
from
July 1, 2026 11:44
821040d to
4877ae6
Compare
This was referenced Jul 2, 2026
Closed
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.
What Problem This Solves
extensions/slack/src/monitor/relay-source.ts:298uses bareJSON.parse(text)inparseRelayFrame()to parse incoming Slack Socket Mode relay WebSocket frames. Malformed JSON from the relay infrastructure would throw rawSyntaxError, which propagates up throughhandleRelayFrameand is caught byrunRelayWebSocket's generic error handler. This loses the distinction between transport errors and parse errors, and makes debugging harder.Solution: Wrap
JSON.parsein try/catch and throwSlackRelayMalformedFrameErrorwith the originalSyntaxErrorascause, so callers can distinguish malformed-frame errors from transport errors.D4 dimension — JSON.parse without try/catch on external input. All major competitors (Alix-007, wangmiao, Pandah97, hugenshen, sunlit-deng) have zero coverage of this dimension.
Changes
relay-source.ts: addSlackRelayMalformedFrameErrorclass; wrap bareJSON.parsein try/catch; exportparseRelayFramefor testabilityrelay-source.test.ts: add 5 test cases covering valid JSON, malformed JSON, cause wrapping, empty object, and array framestest/_proof_slack_relay_json_guard.mts: real behavior proof script calling actualparseRelayFrameEvidence
Unit tests
Real behavior proof
Call chain
runRelayWebSocket→handleRelayFrame→parseRelayFrame→ now throwsSlackRelayMalformedFrameErrorinstead of rawSyntaxErrorfor malformed frames. The existing error handler inrunRelayWebSocketcatches all errors via.catch()and logs them, so no behavioral change for the relay loop — the improvement is semantic: the error type now distinguishes parse failures from transport failures.Label: bugfix | merge-risk: 🟢 minimal | AI-assisted