T09 · Insecure Skill Coding Practices
Error
- Location
- distiller.py:137
- Finding
- Raw conversation history is transmitted to an external API before local redaction<![CDATA[ ## Vulnerability Details **File Location**: `distiller.py:57-82`, `distiller.py:137-168` **Vulnerability Type**: External disclosure of sensitive conversation data **Risk Level**: High ### Complete Code Snippet ```python def distill_chunk(session_id, start_line, end_line, conversation_text, existing_topics): prompt = f""" {conversation_text} """ try: response = client.models.generate_content( model=DISTILL_MODEL, contents=prompt, config=types.GenerateContentConfig( response_mime_type="application/json", ) ) return json.loads(response.text) except Exception as e: return [] ``` ```python with open(session_file, 'r', encoding='utf-8') as f: lines = f.readlines() total_lines = len(lines) if last_read_line >= total_lines: continue current_line = last_read_line while current_line < total_lines: chunk_end = min(current_line + CHUNK_SIZE_MESSAGES, total_lines) chunk_lines = lines[current_line:chunk_end] conversation_text = "" for i, line in enumerate(chunk_lines): try: data = json.loads(line) role = data.get("message", {}).get("role", "unknown").upper() content_list = data.get("message", {}).get("content", []) text = "".join([ c.get("text", "") for c in content_list if c.get("type") == "text" ]) if text.strip(): conversation_text += ( f"[{current_line + i + 1}] {role}: {text}\n" ) except: continue if conversation_text.strip(): existing_topics = get_existing_topics() results = distill_chunk( session_id, current_line + 1, chunk_end, conversation_text, existing_topics ) ``` ### Technical Analysis The skill reads every nonempty JSONL session b ...[truncated 1596 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Perform deterministic local redaction before constructing any external API request. Cover API keys, authorization headers, passwords, private keys, tokens, cookies, and common credential formats. 2. Use an explicit allowlist of sessions or directories instead of processing all main-agent sessions automatically. 3. Require informed opt-in before transmitting conversations to a third-party service, especially before enabling recurring execution. 4. Exclude tool output and other high-risk content by default unless the user explicitly enables it. 5. Minimize requests by sending only locally selected facts or bounded extracts rather than complete message text. 6. Provide a local-model mode for users who cannot permit external data transfer. 7. Document the external recipient, data categories, retention implications, and applicable provider privacy settings. 8. Add automated tests proving that representative secrets never appear in outbound request bodies. ]]>
