π‘οΈ Sentinel: [HIGH] Fix insecure temporary file usage in apt.sh#86
π‘οΈ Sentinel: [HIGH] Fix insecure temporary file usage in apt.sh#86
Conversation
π¨ Severity: HIGH π‘ Vulnerability: Predictable temporary file path `/tmp/yq` used during the download and installation of `yq`. π― Impact: Hardcoding `/tmp/yq` allows a malicious local user to pre-create `/tmp/yq` (e.g., as a symlink or with specific permissions), leading to potential privilege escalation or overriding of arbitrary files when `sudo mv /tmp/yq /usr/local/bin/yq` is executed. π§ Fix: Replaced the hardcoded `/tmp/yq` download and move logic with a subshell that creates a secure temporary directory using `mktemp -d` and implements an `EXIT` trap to guarantee cleanup. β Verification: Ran `./build.sh` (ShellCheck passed) and reviewed the patch. Co-authored-by: kidchenko <5432753+kidchenko@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π WalkthroughWalkthroughA security vulnerability in the apt installer script is fixed by replacing hardcoded temporary file path Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~12 minutes Poem
π₯ Pre-merge checks | β 3β Passed checks (3 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.jules/sentinel.md:
- Line 3: The journal entry header "## 2024-04-11 - [Insecure Temporary File
Usage for yq Download]" has the wrong year; update that header to "## 2026-04-11
- [Insecure Temporary File Usage for yq Download]" so the sentinel.md date
matches this PR event and preserves accurate audit history.
In `@tools/os_installers/apt.sh`:
- Around line 237-239: The download/install of yq (using YQ_VERSION and TMP_DIR
to write /usr/local/bin/yq) lacks integrity verification before running sudo
mv/chmod; add SHA256 verification by obtaining a trusted checksum (e.g. a
YQ_SHA256 variable or downloading the release checksum alongside the binary),
compute the downloaded file's sha256 (using sha256sum or shasum -a 256) and
compare it to the expected value, abort with a clear error if the check fails,
and only run sudo mv /usr/local/bin/yq and sudo chmod +x after the checksum
passes.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 00182116-8ffe-4753-a1c7-6b8b99280e07
π Files selected for processing (2)
.jules/sentinel.mdtools/os_installers/apt.sh
| @@ -0,0 +1,15 @@ | |||
| # Sentinel Journal | |||
|
|
|||
| ## 2024-04-11 - [Insecure Temporary File Usage for yq Download] | |||
There was a problem hiding this comment.
Fix the journal date to match this PR event.
The entry says 2024-04-11, but this PR is from 2026-04-11. Please correct the date to avoid audit/history confusion.
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.jules/sentinel.md at line 3, The journal entry header "## 2024-04-11 -
[Insecure Temporary File Usage for yq Download]" has the wrong year; update that
header to "## 2026-04-11 - [Insecure Temporary File Usage for yq Download]" so
the sentinel.md date matches this PR event and preserves accurate audit history.
| 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 |
There was a problem hiding this comment.
π§© Analysis chain
π Script executed:
#!/bin/bash
# Verify whether the yq install flow includes integrity verification primitives.
rg -n -C3 'yq/releases/download|sha256sum|shasum|gpg|cosign' tools/os_installers/apt.shRepository: kidchenko/dotfiles
Length of output: 2629
π Script executed:
# Check for any sha256 or sig file handling in the yq install block
rg -n -B10 -A5 'yq_linux_amd64' tools/os_installers/apt.shRepository: kidchenko/dotfiles
Length of output: 577
π Script executed:
# Also check if there's a separate verification step after the download
rg -n -B2 -A10 'YQ_VERSION' tools/os_installers/apt.shRepository: kidchenko/dotfiles
Length of output: 715
Add integrity verification before privileged install of yq.
The script downloads an executable and installs it with sudo without checksum or signature validation. A compromised release artifact would be installed as root. While other tools in this script (GitHub CLI, Docker, Yarn, Terraform) use GPG key verification, yq bypasses this security practice. Add SHA256 verification before the privileged install:
Suggested hardening patch
if ! command -v yq &> /dev/null; then
YQ_VERSION="v4.44.6"
+ YQ_SHA256="<pin-sha256-for-yq_linux_amd64>"
(
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
wget "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -O "$TMP_DIR/yq"
+ echo "${YQ_SHA256} $TMP_DIR/yq" | sha256sum -c -
sudo mv "$TMP_DIR/yq" /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq
)
fiπ Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 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 | |
| if ! command -v yq &> /dev/null; then | |
| YQ_VERSION="v4.44.6" | |
| YQ_SHA256="<pin-sha256-for-yq_linux_amd64>" | |
| ( | |
| TMP_DIR=$(mktemp -d) | |
| trap 'rm -rf "$TMP_DIR"' EXIT | |
| wget "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" -O "$TMP_DIR/yq" | |
| echo "${YQ_SHA256} $TMP_DIR/yq" | sha256sum -c - | |
| sudo mv "$TMP_DIR/yq" /usr/local/bin/yq | |
| sudo chmod +x /usr/local/bin/yq | |
| ) | |
| fi |
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tools/os_installers/apt.sh` around lines 237 - 239, The download/install of
yq (using YQ_VERSION and TMP_DIR to write /usr/local/bin/yq) lacks integrity
verification before running sudo mv/chmod; add SHA256 verification by obtaining
a trusted checksum (e.g. a YQ_SHA256 variable or downloading the release
checksum alongside the binary), compute the downloaded file's sha256 (using
sha256sum or shasum -a 256) and compare it to the expected value, abort with a
clear error if the check fails, and only run sudo mv /usr/local/bin/yq and sudo
chmod +x after the checksum passes.
π‘οΈ Sentinel: [HIGH] Fix insecure temporary file usage in apt.sh
π¨ Severity: HIGH
π‘ Vulnerability: Predictable temporary file path
/tmp/yqused during the download and installation ofyq.π― Impact: Hardcoding
/tmp/yqallows a malicious local user to pre-create/tmp/yq(e.g., as a symlink or with specific permissions), leading to potential privilege escalation or overriding of arbitrary files whensudo mv /tmp/yq /usr/local/bin/yqis executed.π§ Fix: Replaced the hardcoded
/tmp/yqdownload and move logic with a subshell that creates a secure temporary directory usingmktemp -dand implements anEXITtrap to guarantee cleanup.β Verification: Ran
./build.sh(ShellCheck passed) and reviewed the patch.PR created automatically by Jules for task 7306839158455040801 started by @kidchenko
Summary by CodeRabbit
Bug Fixes
Documentation