T09 · Insecure Skill Coding Practices
- Location
scripts/qr.sh:69- Finding
WiFi SSID Path Traversal Can Write QR Images Outside the Intended Directory
- Content
View full analysis
`, to already exist. This limits but does not eliminate the vulnerability. The destination also has a timestamp and `.png` suffix, restricting which filenames can be targeted. Nevertheless, the script does not enforce its intended output-directory boundary. ### Attack Path 1. An attacker identifies or creates a suitable directory under `$QR_DIR` whose name begins with `wifi_`. 2. The attacker supplies an SSID containing a normal first component followed by `/../` traversal sequences and an external destination path. 3. The script concatenates the SSID into: `"$QR_DIR/wifi_${ssid}_.png"`. 4. Filesystem path resolution processes the embedded traversal components. 5. `qrencode -o` creates or overwrites the resolved PNG destination outside `$QR_DIR`, provided the necessary parent directories exist and the process has write permission. ### Impact Assessment The att ...[truncated 441 chars]- Remediation
View remediation
&2 return 1 ;; esac ``` Using a fully opaque filename independent of the SSID is preferable. ]]>
