T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/state_awareness.py:81
- Finding
- Overbroad Host Reconnaissance and Log Collection<![CDATA[ ## Vulnerability Details **File Location**: `scripts/state_awareness.py:81-153` **Vulnerability Type**: Excessive host-level data access and sensitive log collection **Risk Level**: Medium ### Complete Code Snippet ```python def _get_resource_metrics(self) -> Dict[str, float]: """Get current system resource usage metrics.""" try: cpu_percent = psutil.cpu_percent(interval=1) memory = psutil.virtual_memory() disk = psutil.disk_usage('/') return { 'cpu_percent': cpu_percent, 'memory_percent': memory.percent, 'memory_available_gb': memory.available / (1024**3), 'disk_percent': disk.percent, 'disk_free_gb': disk.free / (1024**3), 'process_count': len(psutil.pids()) } except Exception as e: print(f"Error getting resource metrics: {e}") return { 'cpu_percent': 0, 'memory_percent': 0, 'memory_available_gb': 0, 'disk_percent': 0, 'disk_free_gb': 0, 'process_count': 0 } def _get_recent_errors(self, hours: int = 24) -> List[Dict]: """Get recent system errors from logs.""" errors = [] cutoff_time = datetime.now() - timedelta(hours=hours) # Look for error logs in common locations log_locations = [ "os.path.expanduser('~/.claude/logs')", "/var/log", "./logs" ] for log_dir in log_locations: if os.path.exists(log_dir): try: for log_file in os.listdir(log_dir): if log_file.endswith('.log'): file_path = os.path.join(log_dir, log_file) file_errors = self._parse_error_log(file_path, cutoff_time) errors.extend(file_errors) except Exception as e: print(f"Error reading log directory {log_dir}: {e}") return errors def _parse_error_log(self, f ...[truncated 2989 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Default to reading only logs owned by this Skill. 2. Require explicit user approval before scanning `/var/log` or other host-wide locations. 3. Accept an administrator-configured allowlist of canonical log paths. 4. Resolve paths with `realpath()` and reject symlinks or paths outside approved roots. 5. Apply secret and personal-data redaction before storing log content. 6. Store structured error metadata instead of complete raw log lines. 7. Enforce per-file and total byte, line, and time limits. 8. Minimize retention and provide a method to clear captured state. 9. Run the Skill under a dedicated least-privileged account. 10. Document every host metric and log source collected by default. ]]>
