T09 · Insecure Skill Coding Practices
- Location
scripts/navioffice.py:231- Finding
API Token Forwarding to Arbitrary Destinations Through Raw Requests
- Content
View full analysis
str: """Execute a raw API call.""" if path.startswith("http"): url = path else: url = f"{NAVI_OFFICE_API_URL}{path}" return api(method, url) ``` JavaScript implementation: ```javascript let fullUrl = rawUrl; if (!rawUrl.startsWith('http://') && !rawUrl.startsWith('https://')) { fullUrl = config.domain + rawUrl; } const parsedUrl = new URL(fullUrl); const options = { hostname: parsedUrl.hostname, port: parsedUrl.port || (parsedUrl.protocol === 'https:' ? 443 : 80), path: parsedUrl.pathname + parsedUrl.search, method: method.toUpperCase(), headers: { 'X-Api-Token': config.apiToken, 'Content-Type': contentType } }; ``` ```javascript async function rawAPI(method, path, extraArgs = []) { const params = {}; for (let i = 0; i < extraArgs.length; i++) { const arg = extraArgs[i]; if (arg.startsWith('-')) { if (i + 1 < extraArgs.length && !extraArgs[i + 1].startsWith('-')) { const key = arg.replace(/^-+/, ''); params[key === 'X' ? 'X-Custom' : key] = extraArgs[i + 1]; i++; } } else if (arg.includes('=')) { const [key, value] = arg.split('='); params[key] = value; } } return api(method.toUpperCase(), path, params, null); } ``` Shell implementation: ```bash curl -s -X "$method" "$url" \ -H "X-Api-Token: ${NAVI_OFFICE_API_TOKEN}" \ -H "Content-Ty ...[truncated 2391 chars]- Remediation
View remediation
