diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 0000000..b60ff8f --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2024-05-15 - Insecure Temporary File Creation in Installer Script +**Vulnerability:** Hardcoded temporary file path `/tmp/yq` used before a `sudo mv` operation, which can lead to symlink attacks or arbitrary code execution by local attackers. +**Learning:** Hardcoding paths in world-writable directories like `/tmp` is dangerous, especially in scripts that escalate privileges (`sudo`). An attacker can exploit this predictable path before the script has a chance to secure it. +**Prevention:** Always use securely generated random directories (e.g., `mktemp -d`) for temporary files, especially in privileged operations. diff --git a/tools/os_installers/apt.sh b/tools/os_installers/apt.sh index 156016b..f75f542 100644 --- a/tools/os_installers/apt.sh +++ b/tools/os_installers/apt.sh @@ -231,9 +231,11 @@ fi echo "Installing yq..." if ! command -v yq &> /dev/null; then YQ_VERSION="v4.44.6" - wget "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -O /tmp/yq - sudo mv /tmp/yq /usr/local/bin/yq + tmp_dir=$(mktemp -d) + wget "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -O "$tmp_dir/yq" + sudo mv "$tmp_dir/yq" /usr/local/bin/yq sudo chmod +x /usr/local/bin/yq + rm -rf "$tmp_dir" fi # Install lsd (LSDeluxe)