T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/activator.py:34
- Finding
- Automatic External Transmission of Insufficiently Redacted Conversation History<![CDATA[ ## Vulnerability Details **File Location**: `scripts/activator.py:34-45, 88-95`; `scripts/trunkate.py:9-22` **Vulnerability Type**: Sensitive data exposure through incomplete redaction and external transmission **Risk Level**: High ### Vulnerable Code ```python # scripts/activator.py:34-45 # 4. Protect common secrets (API keys, passwords, bearer tokens) secret_patterns = [ r'(?i)(?:password|secret|api[_-]?key|token|access[_-]?key|auth[_-]?token|credentials?)\s*[:=]\s*["\']?[a-zA-Z0-9_\-.~]+["\']?', r'Bearer\s+[a-zA-Z0-9\-_.]+' ] for pattern in secret_patterns: for match in re.finditer(pattern, text): placeholder = f"__TRUNKATE_PROTECTED_{uuid.uuid4().hex}__" protected[placeholder] = match.group(0) filtered_text = text for placeholder, original in protected.items(): if original in filtered_text: filtered_text = filtered_text.replace(original, placeholder) ``` ```python # scripts/activator.py:88-95 with open(history_path, "r") as f: history = f.read() # 4. Filter Sensitive Content LOCALLY before external transmission filtered_history, protected_blocks = _filter_sensitive_content(history) # 5. Invoke Semantic Pruner with safe, filtered text optimized_filtered = optimize_prompt(filtered_history, budget=target_budget) ``` ```python # scripts/trunkate.py:9-22 def optimize_prompt(prompt: str, budget: Union[int, str] = 1000, model: str = "gpt-4o") -> str: """Optimizes a prompt using the private Trunkate AI API.""" api_url = os.environ.get("TRUNKATE_API_URL", API_URL).rstrip("/") api_key = os.environ.get("TRUNKATE_API_KEY") if not api_key: print("Error: TRUNKATE_API_KEY required.", file=sys.stderr) return prompt payload = {"text": prompt, "budget": budget, "model": model} headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"} try: response = requests.post(f"{api_url}/optimize", json=payload, headers=head ...[truncated 2332 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make remote history processing explicitly opt-in and clearly disclose when data is transmitted. 2. Use structured OpenClaw message parsing instead of treating the complete history as an opaque string. 3. Allowlist the message types and fields that may be transmitted; exclude system messages, credentials, and raw tool output by default. 4. Implement and enforce the rules file rather than presenting it as documentation only. 5. Add robust detection for private keys, certificates, cookies, database URLs, cloud credentials, and common secret formats. 6. Provide project-level and message-level exclusion controls. 7. Offer a local-only compression mode for sensitive environments. 8. Provide a transmission preview or audit log that identifies the destination and categories of data sent. 9. Add automated tests showing that representative secrets and protected blocks never leave the process. ]]>
