Resolve SSRF Vulnerabilities, Module Resolution Errors, and Studio Transport Corruption in base-builder-mcp - #22
Open
magqqgq wants to merge 1 commit into
Open
Resolve SSRF Vulnerabilities, Module Resolution Errors, and Studio Transport Corruption in base-builder-mcp#22magqqgq wants to merge 1 commit into
base-builder-mcp#22magqqgq wants to merge 1 commit into
Conversation
…nsport Corruption in `base-builder-mcp` ### Description This pull request addresses findings F-07 and F-16 from the workspace security audit, as well as fixing a severe RPC transport corruption issue[cite: 30]. The `guideLink` parameter resolution has been rewritten to use the WHATWG URL parser to prevent Server-Side Request Forgery (SSRF) and Path Traversal attacks. Additionally, the project's TypeScript configuration has been updated to enforce correct ECMAScript Module (ESM) resolution, and stdout logging has been eliminated to prevent protocol framing corruption. ### Key Changes & Remediations #### 1. SSRF and Path Traversal Mitigation (`params.ts`) (F-07) * **WHATWG URL Validation:** `guideLink` inputs are no longer sanitized using an insecure `replace()` string manipulation, which previously allowed dot-segment relative path traversal (`..`)[cite: 30, 32]. Instead, inputs are passed through the WHATWG `URL` constructor[cite: 30]. * **Strict Origin Matching:** The parser now enforces strict scheme, host, and port matching against `https://docs.base.org` rather than simple string matching, preventing sub-domain routing attacks[cite: 30, 32]. * **Depth Bounds & Character Filtering:** Path traversals are explicitly capped to a depth of 12 segments, and illegal path characters (`#`, `?`, `\`, `.`) are thoroughly rejected[cite: 30, 32]. #### 2. Module Resolution Compilation (`tsconfig.json`) (F-16) * **`NodeNext` Enforcement:** Under `"type": "module"`, the legacy `"moduleResolution": "Node"` setting allowed extensionless relative imports to pass TypeScript compilation but immediately crash with `ERR_MODULE_NOT_FOUND` at runtime[cite: 30, 35]. The compiler options have been updated to `NodeNext` to ensure strict ESM resolution standards are applied[cite: 35]. #### 3. MCP Stdio Transport Framing * **Stdout JSON-RPC Protection (`logger.ts`, `sidebar.ts`, `index.ts`):** The MCP server communicates via `StdioServerTransport` where `stdout` acts as the JSON-RPC channel[cite: 30, 34]. Previous standard `console.log` executions (including a 1,800-line sidebar payload dump) severely corrupted the protocol framing[cite: 36]. All diagnostics and metrics logging are now safely offloaded to `stderr` via the new `logger.ts` module[cite: 34]. * **Lifecycle Connections:** The `server.connect(transport)` call inside `index.ts` is now `await`ed, preventing initialization failures from being swallowed as unhandled promise rejections[cite: 30]. ### Validation * Successfully passed the `base-builder-mcp` security harness locally with all 27 SSRF constraint assertions passing (`failures=0`)[cite: 30]. * Passed compilation tests using `npx tsc -p tsconfig.json` with correct ESM target validations[cite: 30].
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.
Description
This pull request addresses findings F-07 and F-16 from the workspace security audit, as well as fixing a severe RPC transport corruption issue[cite: 30]. The
guideLinkparameter resolution has been rewritten to use the WHATWG URL parser to prevent Server-Side Request Forgery (SSRF) and Path Traversal attacks. Additionally, the project's TypeScript configuration has been updated to enforce correct ECMAScript Module (ESM) resolution, and stdout logging has been eliminated to prevent protocol framing corruption.Key Changes & Remediations
1. SSRF and Path Traversal Mitigation (
params.ts) (F-07)guideLinkinputs are no longer sanitized using an insecurereplace()string manipulation, which previously allowed dot-segment relative path traversal (..)[cite: 30, 32]. Instead, inputs are passed through the WHATWGURLconstructor[cite: 30].https://docs.base.orgrather than simple string matching, preventing sub-domain routing attacks[cite: 30, 32].#,?,\,.) are thoroughly rejected[cite: 30, 32].2. Module Resolution Compilation (
tsconfig.json) (F-16)NodeNextEnforcement: Under"type": "module", the legacy"moduleResolution": "Node"setting allowed extensionless relative imports to pass TypeScript compilation but immediately crash withERR_MODULE_NOT_FOUNDat runtime[cite: 30, 35]. The compiler options have been updated toNodeNextto ensure strict ESM resolution standards are applied[cite: 35].3. MCP Stdio Transport Framing
logger.ts,sidebar.ts,index.ts): The MCP server communicates viaStdioServerTransportwherestdoutacts as the JSON-RPC channel[cite: 30, 34]. Previous standardconsole.logexecutions (including a 1,800-line sidebar payload dump) severely corrupted the protocol framing[cite: 36]. All diagnostics and metrics logging are now safely offloaded tostderrvia the newlogger.tsmodule[cite: 34].server.connect(transport)call insideindex.tsis nowawaited, preventing initialization failures from being swallowed as unhandled promise rejections[cite: 30].Validation
base-builder-mcpsecurity harness locally with all 27 SSRF constraint assertions passing (failures=0)[cite: 30].npx tsc -p tsconfig.jsonwith correct ESM target validations[cite: 30].