T09 · Insecure Skill Coding Practices
Error
- Location
- plugin/index.ts:226
- Finding
- Unauthenticated API Disclosure of Captured Agent Responses<![CDATA[ ## Vulnerability Details **File Location**: `plugin/index.ts`, lines 179-194 and 226-243 **Vulnerability Type**: Unauthenticated sensitive-data exposure with wildcard CORS **Risk Level**: High ### Vulnerable Code ```typescript const entry = { ts: new Date().toISOString(), emotion: result.global.emotion, confidence: result.global.confidence, label: result.global.label, color: result.global.color, secondary: result.global.secondary, sec_conf: result.global.sec_conf, desc: result.global.desc, why: result.global.why, arc: result.arc, peak: result.peak, metrics: result.global.metrics, dim_profile: result.global.dim_profile, scores: result.global.scores, sentences: result.sentences, n: result.n, analysisMs: result.analysis_ms, process: pm, textPreview: text.slice(0, 200), }; latestResult = entry; history.push(entry); analysisCount++; appendLog(logPath, entry); ``` ```typescript if (p === "/eft/api/latest") { res.setHeader("Content-Type", "application/json"); res.setHeader("Access-Control-Allow-Origin", "*"); res.end(JSON.stringify(latestResult ?? { status: "awaiting_first_analysis" })); return true; } if (p === "/eft/api/history") { res.setHeader("Content-Type", "application/json"); res.setHeader("Access-Control-Allow-Origin", "*"); res.end(JSON.stringify({ count: history.length, entries: history.slice(-50).reverse() })); return true; } ``` ### Technical Analysis The `agent_end` handler automatically captures assistant responses and stores complete sentence-level text in `result.sentences`, peak-segment text in `result.peak`, the first 200 characters in `textPreview`, and associated session and process metadata. The `/eft/api/latest` and `/eft/api/history` routes return these records without implementing authentication, authorization, or caller validation. Both endpoints also set `Access-Control-Allow-Origin: *`, permitting JavaScript from any web origin to read responses when the EFT gateway is r ...[truncated 1704 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require authenticated gateway sessions for every `/eft` and `/eft/api/*` route. 2. Add explicit authorization checks so only designated administrators or session owners can access captured records. 3. Remove `Access-Control-Allow-Origin: *`. Use an exact, configurable allowlist for trusted dashboard origins. 4. Reject requests with untrusted `Origin` headers and add CSRF protection where cookie-based authentication is used. 5. Bind the service to loopback by default and clearly warn operators before allowing remote exposure. 6. Store derived emotion metrics rather than raw response text by default. 7. Make raw-text capture an explicit opt-in setting and support field-level redaction. 8. Separate records by session or user and enforce ownership checks before returning them. 9. Add security tests verifying that unauthenticated and cross-origin requests cannot access response data. ]]>
