other
Note
- Location
- devops.py:832
- Finding
- Automatic Broad Environment Reconnaissance and Sensitive Diagnostic Disclosure<![CDATA[ ## Vulnerability Details **File Location**: `devops.py`, lines 832–1004 and 1099–1103 **Vulnerability Type**: Automatic environment reconnaissance and information disclosure **Risk Level**: Low ### Complete Code Snippet ```python def cmd_diag(_args): """Full system diagnostics — one command to see everything.""" w = min(term_width(), 80) now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") hostname = platform.node() or "unknown" os_info = platform.platform() if docker_available(): rc, out, _ = run( "docker ps -a --format '{{.Names}}\t{{.Status}}'" ) common_ports = [ 22, 80, 443, 3000, 3306, 5432, 6379, 8080, 8443, 9090 ] port_results = [] for port in common_ports: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(0.5) result = sock.connect_ex(("127.0.0.1", port)) sock.close() if result == 0: port_results.append((port, True)) except Exception: pass log_locations = [ "/var/log/syslog", "/var/log/messages", "/var/log/kern.log", "/var/log/auth.log", ] found_errors = False for log_path in log_locations: if not os.path.isfile(log_path): continue try: with open(log_path, "r", errors="replace") as f: lines = f.readlines() recent = lines[-500:] errors = [ line.rstrip() for line in recent if re.search( r"\b(error|critical|fatal|panic)\b", line, re.IGNORECASE, ) ] except PermissionError: continue rc, out, _ = run( "ps aux --sort=-%cpu 2>/dev/null | head -n 8" ) ``` ```python args = parser.parse_args() if args.command is None: # Default to diag ...[truncated 2449 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the implicit diagnostic behavior and require an explicit `diag` subcommand. 2. Display a clear summary of the information to be collected and require confirmation before broad diagnostics. 3. Divide diagnostics into opt-in flags such as `--system`, `--docker`, `--ports`, `--logs`, and `--processes`. 4. Redact potentially sensitive process arguments, usernames, container identifiers, IP addresses, tokens, and authentication-log fields. 5. Avoid printing raw log records by default; report only aggregate counts unless detailed output is explicitly requested. 6. Add a safe-output mode suitable for AI agents, CI systems, support tickets, and shared terminals. 7. Apply strict output-size limits and document that diagnostic output may contain sensitive operational data. 8. Ensure captured reports are stored with restrictive permissions and are not automatically transmitted or retained. ]]>
