T09 · Insecure Skill Coding Practices
- Location
scripts/cloudbypass_request.js:25- Finding
Caller-Controlled API Endpoint Enables Credential and Request-Data Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
scripts/cloudbypass_request.js:25,scripts/cloudbypass_request.js:81-141, andscripts/cloudbypass_request.js:279-345
Vulnerability Type: Arbitrary outbound destination and sensitive-data disclosure
Risk Level: HighThe Cloudbypass API endpoint can be replaced through
config.apiBaseUrl. The replacement endpoint is not restricted to the legitimate Cloudbypass origin and is not required to use HTTPS. Both the normal request and download paths send sensitive headers to the resulting destination.Vulnerable Code
js // API base address this.apiBaseUrl = config.apiBaseUrl || 'https://api.cloudbypass.com';Normal request path:
js // Build Cloudbypass API URL const apiUrl = new URL(this.apiBaseUrl); apiUrl.pathname = targetUrl.pathname; apiUrl.search = targetUrl.search; // Build request headers const requestHeaders = { 'x-cb-apikey': this.apiKey, 'x-cb-host': targetUrl.hostname, ...headers }; // Protocol type if (protocol || targetUrl.protocol === 'http:') { requestHeaders['x-cb-protocol'] = protocol || 'http'; } // V2 mode configuration if (mode === 'v2' || mode === 'v2s') { requestHeaders['x-cb-version'] = mode === 'v2s' ? '2s' : '2'; if (!proxy) { throw new Error('Proxy is required for V2 mode. Please set proxy in config or CLOUDBYPASS_PROXY environment variable.'); } requestHeaders['x-cb-proxy'] = proxy; if (part) { requestHeaders['x-cb-part'] = part; } if (sitekey) { requestHeaders['x-cb-sitekey'] = sitekey; } } // Extra options if (extraOptions) { requestHeaders['x-cb-options'] = extraOptions; } // Process request body and set Content-Type let requestBody = null; if (body) { if (typeof body === 'object') { requestBody = JSON.stringify(body); if (!requestHeaders['Content-Type']) { ...[truncated 4084 chars]- Remediation
View remediation
Remediation Suggestions
-
Remove production endpoint configurability and always use the fixed endpoint:
js this.apiBaseUrl = 'https://api.cloudbypass.com'; -
If endpoint configurability is required for testing, validate the complete origin rather than only parsing the URL:
js const apiUrl = new URL(config.apiBaseUrl || 'https://api.cloudbypass.com'); if ( apiUrl.protocol !== 'https:' || apiUrl.hostname !== 'api.cloudbypass.com' || (apiUrl.port && apiUrl.port !== '443') || apiUrl.username || apiUrl.password ) { throw new Error('Untrusted Cloudbypass API endpoint'); } this.apiBaseUrl = apiUrl.origin; -
Keep test endpoints behind an explicit development-only flag and never attach real credentials when using them.
-
Reject plaintext HTTP and unexpected URL schemes, ports, user information, and hosts. If redirect handling is added later, revalidate every redirect destination before forwarding sensitive headers.
-
Prevent caller headers from overriding service-control headers. Filter reserved
x-cb-*names or construct protected headers after merging caller headers:js const requestHeaders = { ...sanitizedCallerHeaders, 'x-cb-apikey': this.apiKey, 'x-cb-host': targetUrl.hostname }; -
Explicitly allowlist caller headers that may be forwarded. Treat
Authorization,Cookie, proxy authorization, and other credential-bearing headers as sensitive. -
Document that target paths, query strings, headers, bodies, and proxy configuration are transmitted to the Cloudbypass provider. Require callers to avoid sending data that is unnecessary for retrieval.
-
Add tests confirming that HTTP endpoints, non-Cloudbypass hosts, unexpected ports, userinfo-bearing URLs, and reserved-header overrides are rejected.
-
