T09 · Insecure Skill Coding Practices
- Location
mcp-server/server.js:14- Finding
Configurable API Endpoint Can Receive Credentials and Sensitive Research Data
- Content
View full analysis
Vulnerability Details
File Location:
mcp-server/server.js, lines 14–20
Vulnerability Type: Unrestricted credential-bearing outbound requests
Risk Level: MediumVulnerable Code
js const BASE = process.env.SHULAN_BASE_URL || "http://127.0.0.1:8790"; const KEY = process.env.SHULAN_API_KEY || ""; async function call(path, options = {}) { const headers = { "Content-Type": "application/json" }; if (KEY) headers.Authorization = `Bearer ${KEY}`; const res = await fetch(`${BASE}${path}`, { ...options, headers });Technical Analysis
The server accepts
SHULAN_BASE_URLwithout validating its scheme, hostname, port, or origin. It then attachesSHULAN_API_KEYas a Bearer token to every API request sent to that endpoint.This configurability supports local or self-hosted deployments, but it does not enforce a trust boundary. A malicious or mistakenly configured base URL can point to an attacker-controlled server. The implementation also permits plaintext HTTP for non-loopback destinations, allowing credentials and request contents to be exposed through network interception.
Task-creation calls can include the user's research question, requested data sources, task type, cost estimate, and subscription frequency. Consequently, this weakness can expose both authentication credentials and potentially sensitive business-research information.
Attack Path
- An attacker persuades the user, modifies deployment configuration, or supplies setup instructions that set
SHULAN_BASE_URLto an attacker-controlled HTTP or HTTPS endpoint. - The MCP server reads this endpoint without validation.
- The user or agent invokes any ShuLan tool.
- The server sends
Authorization: Bearer <SHULAN_API_KEY>to the configured endpoint. - If
shulan_create_taskis invoked, the request body additionally discloses the research question and task parameters. - The attacker can capture the API key ...[truncated 817 chars]
- An attacker persuades the user, modifies deployment configuration, or supplies setup instructions that set
- Remediation
View remediation
Remediation Suggestions
- Parse
SHULAN_BASE_URLwith the standardURLclass and reject malformed URLs. - Permit only
https:for remote hosts. Allowhttp:solely for explicit loopback addresses such as127.0.0.1,::1, andlocalhost. - Default to an allowlisted production origin such as
https://shulan.io. - Require an explicit security override for self-hosted origins and display a warning that the configured server will receive the API key and research content.
- Reject URLs containing embedded usernames or passwords, unexpected schemes, or fragments.
- Bind credentials to approved origins so the
Authorizationheader is not automatically sent to arbitrary destinations. - Fail closed when
SHULAN_API_KEYis absent for authenticated operations rather than silently issuing unauthenticated requests. - Use restricted, revocable API keys with minimum required permissions and spending limits.
- Document secure secret injection and recommend restrictive permissions for configuration files such as
~/.claude/mcp.json. - Add automated tests covering attacker-controlled hosts, remote plaintext HTTP, malformed URLs, embedded credentials, and approved local development endpoints.
- Parse
