other
- Location
src/client.js:181- Finding
Remote HTTP Backend Connections Expose API Credentials and Conversation Content ## Remediation Suggestions 1. **Validate the effective URL before use.** Parse it with the platform URL parser after configuration resolution, reject unsupported schemes, and require HTTPS for non-loopback destinations. 2. **Preserve local functionality narrowly.** If local HTTP remains supported, restrict the exception to explicitly recognized loopback addresses rather than arbitrary hostnames or private-network destinations. 3. **Apply validation consistently.** Enforce the same policy before direct API requests and before supplying the backend URL to CLI subprocesses. 4. **Keep secure transport defaults.** Preserve certificate verification and redirect rejection. Do not introduce certificate-verification bypasses as a workaround for remote connectivity problems. 5. **Make insecure exceptions explicit.** If remote HTTP must be supported for exceptional deployments, require a separate opt-in setting, display a prominent warning, and document that credentials and conversations will be exposed unless an independently secured tunnel protects the connection. 6. **Add regression tests.** Cover remote HTTP rejection, remote HTTPS acceptance, supported loopback exceptions, malformed URLs, and each supported configuration source. 7. **Respond to prior exposure.** Rotate API keys previously transmitted over untrusted HTTP networks and review backend access logs for unexpected use.
- Content
View full analysis
Vulnerability Details
File Location:
src/config.js:358–371;src/client.js:133–140,164–189
Vulnerability Type: CWE-319 — Cleartext Transmission of Sensitive Information
Risk Level: Medium — conditional on configuring a non-loopback HTTP backendVulnerable Code
The backend URL is accepted without enforcing HTTPS:
javascript // --- apiUrl: file (legacy) > pluginConfig > sharedConfig > env > "" --- const fileUrl = typeof resolvedFile.apiUrl === "string" && resolvedFile.apiUrl.trim(); const pluginUrl = typeof resolvedPlugin.apiUrl === "string" && resolvedPlugin.apiUrl.trim(); const au = firstDefined( { value: fileUrl || undefined, source: "file" }, { value: pluginUrl || undefined, source: "pluginConfig" }, { value: sharedCfg.apiUrl || undefined, source: "sharedConfig" }, { value: envStr("NMEM_API_URL"), source: "env" }, { value: "", source: "default" }, ); const apiUrl = au.value; _sources.apiUrl = au.source;The API credential is attached to requests:
javascript getApiHeaders() { const headers = { "content-type": "application/json", "x-nmem-space-protocol": "exact-v1" }; if (this._apiKey) { headers.authorization = `Bearer ${this._apiKey}`; headers["x-nmem-api-key"] = this._apiKey; } return headers; }The direct API request path sends these headers and the serialized body to the configured backend:
javascript async apiJson(method, path, body, timeout = 30_000) { const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), timeout); try { const headers = this.getApiHeaders(); const load = async () => { const response = await fetch(`${this.getApiBaseUrl()}/spaces`, {headers, signal: controller.signal, redirect: "error"}); if (!response.ok) throw new Error(`Space roster HTTP ${response.status}`); return response.json(); }; const scopedBody = await exactSpaceBody(body, this._spaceRef, load); let scopedPath = path; if (this._spaceRef) { const url = new ...[truncated 3516 chars]
