Skip to content

Resolve SSRF Vulnerabilities, Module Resolution Errors, and Studio Transport Corruption in base-builder-mcp - #22

Open
magqqgq wants to merge 1 commit into
base:masterfrom
magqqgq:magqqgq-patch-1
Open

Resolve SSRF Vulnerabilities, Module Resolution Errors, and Studio Transport Corruption in base-builder-mcp#22
magqqgq wants to merge 1 commit into
base:masterfrom
magqqgq:magqqgq-patch-1

Conversation

@magqqgq

@magqqgq magqqgq commented Sep 2, 2026

Copy link
Copy Markdown

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 awaited, 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].

…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].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant