T05 · Unauthorized Access and Privilege Escalation
- Location
src/server.ts:94- Finding
Unauthenticated Loopback RPC Service Uses Ambient Prospairrow Credentials
- Content
View full analysis
{ if (req.method !== "POST") { res.writeHead(405, { "content-type": "application/json" }); res.end(JSON.stringify({ error: "Method not allowed" })); return; } const body = await new Promise((resolve, reject) => { let data = ""; req.on("data", (chunk) => { data += chunk; }); req.on("end", () => resolve(data)); req.on("error", reject); }); try { const payload = JSON.parse(body) as JsonRpcRequest; const authHeader = Array.isArray(req.headers.authorization) ? req.headers.authorization[0] : req.headers.authorization; const apiKeyHeader = Array.isArray(req.headers["x-api-key"]) ? req.headers["x-api-key"][0] : req.headers["x-api-key"]; const bearer = typeof authHeader === "string" ? authHeader.match(/^Bearer\s+(.+)$/i)?.[1]?.trim() : ""; const apiKey = (typeof apiKeyHeader === "string" && apiKeyHeader.trim()) || bearer || undefined; const result = await handleRpc(payload, { apiKey }); ``` ```ts // src/framework/service.ts:56-64 async function resolveProspairrowApiKey(inputData: RunTaskInput): Promise { const fromRequest = cleanSecret(inputData.apiKey); if (fromRequest) return fromRequest; const fromEnv = cleanSecret(process.env.PROSPAIRROW_API_KEY); if (fromEnv) return fromEnv; return readConfigApiKey(); } ``` ```ts // src/framework/service.ts:182-225 const resolvedProspairrowApiKey = inputData.siteId === "prospairrow" ? await resolveProspairrowApiKey(inputData) : undefined; let storageStatePath: string | undefined; try { storageStatePath = await loadStorageStatePath(rootDir, site.siteId); } catch ...[truncated 3630 chars]- Remediation
View remediation
