T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/analyzer.js:25
- Finding
- Sensitive conversation context is excluded from privacy analysis<![CDATA[ ## Vulnerability Details **File Location**: `scripts/analyzer.js:25-27` and `scripts/analyzer.js:57-82` **Vulnerability Type**: Sensitive-data routing bypass **Risk Level**: High ### Vulnerable Code ```js analyzeTask(prompt, context = "", requirements = {}) { const contextLength = this.estimateContextLength(prompt, context); const privacyLevel = this.detectPrivacyLevel(prompt); const taskType = this.classifyTaskType(prompt); let reason = ""; if (privacyLevel === 'high') { reason = "privacy sensitive content detected"; } else if (contextLength > 32768) { reason = "large context requirement"; } else { reason = "general purpose routing"; } return { contextLength, privacyLevel, taskType, costSensitivity: requirements.costSensitive || false, performanceCritical: requirements.performanceCritical || false, reason }; } ``` ```js detectPrivacyLevel(prompt) { // Enhanced privacy detection with multiple checks const lowerPrompt = prompt.toLowerCase(); // Check for sensitive patterns const hasSensitivePattern = this.sensitivePatterns.some(pattern => pattern.test(prompt) ); // Check for common sensitive contexts const sensitiveContexts = [ 'my password is', 'api key', 'secret key', 'access token', 'authentication', 'login credentials' ]; const hasSensitiveContext = sensitiveContexts.some(ctx => lowerPrompt.includes(ctx) ); return (hasSensitivePattern || hasSensitiveContext) ? 'high' : 'low'; } ``` ### Technical Analysis The analyzer includes both the prompt and conversation context when estimating the total token count, but it passes only `prompt` to `detectPrivacyLevel`. Consequently, passwords, API keys, access tokens, personally identifiable information, private conversation history, and other confidential information contained exclusively in `context` do not affect the privacy classification. A harmless prompt combined with ...[truncated 1440 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Analyze every data field that may be sent to the selected model: ```js const privacyLevel = this.detectPrivacyLevel(`${prompt}\n${context}`); ``` 2. Prefer an API that accepts separate fields and evaluates both, rather than relying on string concatenation. 3. Validate that `prompt` and `context` are strings before analysis. 4. Expand detection beyond keywords to cover structured credentials, private keys, financial identifiers, email addresses, telephone numbers, and configurable organization-specific patterns. 5. Treat uncertain or failed privacy analysis as sensitive and route locally by default. 6. Add tests where the prompt is harmless but the context contains credentials or PII. 7. Apply output-side enforcement before returning a cloud model: reject any cloud decision when the combined request has a high or unknown privacy classification. ]]>
