From 585d1bb7c4c922a7e0fd57e748e40d4b374e534f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 04:42:26 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITICAL]?= =?UTF-8?q?=20Fix=20insecure=20temporary=20file=20usage=20in=20apt=20insta?= =?UTF-8?q?ller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `tools/os_installers/apt.sh` script previously downloaded the `yq` binary to a hardcoded, predictable path (`/tmp/yq`) before using `sudo` to move it. This exposes the system to symlink attacks or arbitrary file overwrite vulnerabilities by local attackers. This commit updates the script to securely generate a random temporary directory using `mktemp -d`. The `yq` binary is downloaded into this directory, moved securely, and the temporary directory is cleaned up afterward. A corresponding journal entry detailing this vulnerability and its prevention was also added to `.jules/sentinel.md`. Co-authored-by: kidchenko <5432753+kidchenko@users.noreply.github.com> --- .jules/sentinel.md | 4 ++++ tools/os_installers/apt.sh | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .jules/sentinel.md 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)