T09 · Insecure Skill Coding Practices
- Location
verify-email.mjs:36- Finding
Unrestricted API Base URL Can Expose Credentials and Email Data
- Content
View full analysis
Vulnerability Details
File Location:
verify-email.mjs, lines 36–53
Vulnerability Type: Unvalidated credential-bearing network destination
Risk Level: MediumVulnerable Code
js const apiKey = process.env.OPENMERCH_API_KEY; if (!apiKey) fail("OPENMERCH_API_KEY is not set. Get a key from the Developer page in the OpenMerch app."); const baseUrl = (process.env.OPENMERCH_BASE_URL || "https://api.openmerch.dev").replace(/\/+$/, ""); async function call(method, path, body) { const headers = { "X-OpenMerch-Key": apiKey }; if (body !== undefined) headers["Content-Type"] = "application/json"; const res = await fetch(`${baseUrl}${path}`, { method, headers, body: body !== undefined ? JSON.stringify(body) : undefined, }); const text = await res.text(); let json; try { json = text ? JSON.parse(text) : {}; } catch { json = { raw_body: text }; } if (!res.ok) { fail(`${method} ${path} -> HTTP ${res.status}: ${text || res.statusText}`); } return json; }Technical Analysis
OPENMERCH_BASE_URLcontrols the destination of every API request but is not parsed or validated. The implementation neither requires HTTPS nor restricts the hostname to an approved OpenMerch endpoint.Every request made through
call()includes the sensitiveX-OpenMerch-Keyheader. Planning and execution requests also include the email address supplied by the user. Consequently, an attacker who can influence the process environment can redirect both the API credential and personal data to an arbitrary server. Anhttp://URL is also accepted, permitting plaintext transmission and network interception.Sending the target email and API key to the legitimate OpenMerch service is necessary for the declared external verification functionality and is documented. The security issue is that the same sensitive values may be sent to an unrestricted, user-configurab ...[truncated 1244 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse the configured endpoint with
new URL()and reject malformed values. - Require the
https:protocol in production to prevent plaintext credential and email transmission. - Restrict the hostname to
api.openmerch.devor a narrowly defined allowlist of trusted OpenMerch hosts. - If staging or testing overrides are necessary, require an explicit development-mode opt-in and use separate, least-privileged non-production credentials.
- Reject URLs containing unexpected credentials, ports, query strings, fragments, or path prefixes unless specifically required.
- Consider preventing automatic forwarding of authentication headers across redirects, or disable redirects and validate every redirect destination.
- Rotate the OpenMerch API key if the Skill has previously run with an untrusted or plaintext base URL.
- Parse the configured endpoint with
