T09 · Insecure Skill Coding Practices
- Location
all-in-one.sh:7- Finding
Sensitive NAS telemetry can remain in a temporary file after abnormal termination
- Content
View full analysis
/dev/null > "$TMPFILE" # ── 2. 格式化 ── python3 "$SCRIPT_DIR/scripts/format.py" "$TMPFILE" rm -f "$TMPFILE" ``` ### Technical Analysis The script securely creates a uniquely named file through `mktemp`, but cleanup only occurs at the end of the normal execution path. Because `set -e` is enabled, any failure in the collection or formatting command terminates the script before `rm -f "$TMPFILE"` executes. The temporary file can contain sensitive reconnaissance data, including: - Hostname and operating-system information - Local IP addresses and listening ports - Login history and failed-login counts - SSH daemon configuration - Process and service names - System and kernel logs - Disk models, serial numbers, and health information - ZFS datasets and snapshots - Docker container and image metadata Although `mktemp` normally creates the file with restrictive permissions, leaving this information on disk unnecessarily increases exposure to privileged local users, forensic recovery, backup processes, or later permission and configuration mistakes. ### Attack Path 1. A local attacker or malformed runtime condition causes `scripts/collect.sh` or `scripts/format.py` to fail. 2. `set -e` immediately terminates `all-in-one.sh`. 3. The explicit `rm -f` cleanup operation is never reached. 4. The completed or partially completed report remains under `/tmp/nas-collect.*`. 5. A privileged local attacker, backup service, forensic process, or other sufficiently authorized process retrieves the residual telemetry. 6. The exposed information is used to map storage, services, containers, SSH configuration, and network attack surfaces. ### Impact Asse ...[truncated 530 chars]- Remediation
View remediation
