T09 · Insecure Skill Coding Practices
- Location
scripts/moudao.js:214- Finding
Configurable Plaintext API Endpoint Can Expose API Credentials and User Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/moudao.js:214-244,scripts/moudao.js:597-603
Vulnerability Type: Unrestricted external endpoint with plaintext HTTP support
Risk Level: MediumVulnerable Code
javascript function callLLM(systemPrompt, userMessage, apiKey, baseUrl) { return new Promise((resolve, reject) => { const url = new URL(baseUrl || 'https://api.deepseek.com/chat/completions'); const data = JSON.stringify({ model: process.env.LLM_MODEL || 'deepseek-chat', messages: [ { role: 'system', content: systemPrompt }, { role: 'user', content: userMessage } ], temperature: 0.3, max_tokens: 4096, response_format: { type: 'json_object' } }); const options = { hostname: url.hostname, port: url.port || 443, path: url.pathname, method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data), 'Authorization': `Bearer ${apiKey}` } }; const client = url.protocol === 'https:' ? https : http; const req = client.request(options, (res) => {javascript const apiKey = process.env.DEEPSEEK_API_KEY; const baseUrl = process.env.DEEPSEEK_BASE_URL;Technical Analysis
The
DEEPSEEK_BASE_URLenvironment variable controls the destination receiving LLM requests. The implementation does not restrict the destination hostname and explicitly permits both HTTPS and plaintext HTTP.Every request sends the value of
DEEPSEEK_API_KEYin theAuthorizationheader. The request body can contain the user's idea, profile, constraints, diagnostic context, and generated research context. Consequently, an attacker who can influence the environment configuration can redirect credentials and user information to an attacker-controlled server.When an HTTP ...[truncated 1690 chars]
- Remediation
View remediation
Remediation Suggestions
- Require HTTPS for every remote API endpoint and reject
http:or any unsupported protocol before constructing the request. - Allowlist trusted API hostnames, such as the official DeepSeek API host. If custom providers must be supported, require explicit user approval and clearly display the destination.
- Do not automatically send
DEEPSEEK_API_KEYto custom hosts. Use separate, endpoint-specific credential variables and validate that each credential is only sent to its intended hostname. - Normalize and validate the complete URL, including protocol, hostname, port, and path. Reject embedded credentials, unexpected ports, redirects, and malformed destinations.
- Document that ideas, profiles, constraints, and diagnostic context are transmitted to an external LLM provider. Advise users not to submit secrets or unnecessary sensitive information.
- Apply request timeouts, response-size limits, and strict TLS certificate verification.
- Consider disabling custom endpoints by default and enabling them only through an explicit secure configuration option.
- Add automated tests verifying that plaintext endpoints and unapproved hosts are rejected and that credentials are never forwarded across provider boundaries.
- Require HTTPS for every remote API endpoint and reject
