T09 · Insecure Skill Coding Practices
Error
- Location
- src/analyzers/__init__.py:54
- Finding
- Potentially Sensitive Log Data Is Transmitted to External AI Providers Without Accurate Disclosure<![CDATA[ ## Vulnerability Details **File Location**: `src/analyzers/__init__.py:54-57, 91-162` **Vulnerability Type**: Sensitive information exposure to third-party services **Risk Level**: High ### Vulnerable Code ```python # Use AI for unknown errors if self.api_key: analysis = self._analyze_with_ai(error_message, stack_trace) self.cache[cache_key] = analysis return analysis ``` ```python def _build_prompt(self, error_message: str, stack_trace: Optional[str]) -> str: """Build the AI prompt.""" prompt = f"""You are a senior software engineer helping debug an application error. Analyze this error and provide a clear, actionable response: ERROR MESSAGE: {error_message} """ if stack_trace: prompt += f""" STACK TRACE: {stack_trace[:2000]} # Limit stack trace length """ prompt += """ Please provide your analysis in this exact JSON format: { "error_type": "Brief error type (e.g., Database Connection Error)", "severity": "CRITICAL|HIGH|MEDIUM|LOW", "explanation": "Plain English explanation of what happened (2-3 sentences)", "root_cause": "The underlying cause (1-2 sentences)", "suggestions": [ "Step 1 to fix", "Step 2 to fix", "Step 3 to fix" ], "code_examples": [ "// Optional code example" ] } Guidelines: - Be specific and actionable - Use simple language (avoid jargon when possible) - Provide numbered steps - Include commands/code when relevant - Be helpful and encouraging """ return prompt ``` ```python def _call_claude(self, prompt: str) -> str: """Call Claude API.""" try: import anthropic client = anthropic.Anthropic(api_key=self.api_key) message = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1024, messages=[{"role": "user", "content": prompt}] ) return message.content[0].text except ImportError: raise ImportError("Please insta ...[truncated 2582 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Correct the documentation to state clearly that unknown errors may be transmitted to Anthropic or OpenAI. 2. Require explicit opt-in before enabling external AI analysis; do not activate it merely because an environment variable exists. 3. Add a guaranteed local-only mode that cannot invoke external providers. 4. Redact secrets and personal data before prompt construction. At minimum, detect API keys, authorization headers, cookies, private keys, connection strings, email addresses, and common token formats. 5. Show users the exact redacted payload and destination provider before the first external request. 6. Allow administrators to configure data-classification and provider restrictions. 7. Document applicable provider retention, training, privacy, and regional-processing policies. 8. Avoid logging prompts, API responses, or exceptions that may reproduce sensitive content. 9. Add tests confirming that representative credentials and personal data never appear in outbound request payloads. ]]>
