T09 · Insecure Skill Coding Practices
- Location
index.js:26- Finding
Configurable API Base URL Can Expose the Bearer Token to an Arbitrary Server
- Content
View full analysis
Vulnerability Details
File Location:
index.js, lines 26–50
Vulnerability Type: Unvalidated destination for authenticated API requests
Risk Level: MediumVulnerable Code
js async function apiRequest(method, endpoint, body = null) { const config = loadConfig(); const apiKey = config.apiKey; const baseUrl = config.baseUrl || 'https://socialrails.com/api/v1'; if (!apiKey) { return { error: 'SocialRails API key not configured. Run: openclaw config socialrails apiKey <your-key>' }; } const options = { method, headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json', }, }; if (body) { options.body = JSON.stringify(body); } const url = `${baseUrl}${endpoint}`; try { const response = await fetch(url, options);Technical Analysis
The skill reads
baseUrlfrom user-controlled configuration and uses it without validating its scheme, hostname, port, or origin. It then attaches the SocialRails API key to every request through theAuthorizationheader.Consequently, anyone able to influence
skills.socialrails.baseUrlin~/.openclaw/openclaw.jsoncan redirect authenticated requests to a server they control. The implementation also permits anhttp://URL, allowing the credential and request contents to be transmitted without transport encryption.This is a credential-disclosure flaw rather than remote code execution. Exploitation requires the ability to alter or socially engineer a change to the skill configuration.
Attack Path
- An attacker persuades the user to configure a purported proxy or alternative SocialRails endpoint, or otherwise gains the ability to modify
skills.socialrails.baseUrl. - The attacker sets
baseUrlto a server they control, such ashttps://attacker.example/api/v1. - The user invokes any skill command that calls
apiRequest. - The ...[truncated 857 chars]
- An attacker persuades the user to configure a purported proxy or alternative SocialRails endpoint, or otherwise gains the ability to modify
- Remediation
View remediation
Remediation Suggestions
- Parse the configured value with
new URL()rather than concatenating unvalidated strings. - Require the
https:scheme and reject plaintext HTTP. - Allowlist the official
socialrails.comhostname and expected API path. - Reject embedded credentials, unexpected ports, malformed URLs, and unapproved subdomains.
- If custom endpoints are necessary, require an explicit high-risk opt-in and use separate credentials that are not valid against the production SocialRails service.
- Before attaching the
Authorizationheader, verify that the final request URL remains on an approved origin. - Prevent credential forwarding across redirects, or disable redirects and validate each redirect destination.
- Document that changing
baseUrlcan disclose API credentials and should only be performed for trusted endpoints.
- Parse the configured value with
