Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix insecure temporary download paths in apt.sh#91

Open
kidchenko wants to merge 1 commit intomainfrom
sentinel/fix-insecure-tmp-paths-10068104001288958326
Open

πŸ›‘οΈ Sentinel: [HIGH] Fix insecure temporary download paths in apt.sh#91
kidchenko wants to merge 1 commit intomainfrom
sentinel/fix-insecure-tmp-paths-10068104001288958326

Conversation

@kidchenko
Copy link
Copy Markdown
Owner

@kidchenko kidchenko commented Apr 16, 2026

🚨 Severity: HIGH
πŸ’‘ Vulnerability: The tools/os_installers/apt.sh script was downloading executable artifacts to predictable temporary paths like /tmp/yq or directly to the current working directory. This pattern is vulnerable to Time-of-Check to Time-of-Use (TOCTOU) and symlink attacks. If an attacker pre-creates a symlink at /tmp/yq pointing to a sensitive file, the script (running with sudo) could inadvertently overwrite it or allow local privilege escalation.
🎯 Impact: Local attackers could potentially escalate privileges or overwrite critical system files by exploiting the predictable download paths when the installation script is executed.
πŸ”§ Fix: Wrapped the go, yq, and lsd installation blocks in subshells (...). Within each subshell, a secure temporary directory is created using TMP_DIR=$(mktemp -d), and a local trap (trap 'rm -rf "$TMP_DIR"' EXIT) ensures cleanup. The wget commands were updated to download specifically into this isolated directory.
βœ… Verification: Ensure the scripts pass shellcheck (via ./build.sh lint) and that running the modified installation blocks does not leave artifacts in /tmp or the current directory.


PR created automatically by Jules for task 10068104001288958326 started by @kidchenko

Summary by CodeRabbit

  • Documentation

    • Added security journal entry documenting temporary file handling patterns for shell scripts
  • Chores

    • Updated package installer to use dynamically-created temporary directories for artifact downloads and processing

Replaced hardcoded `/tmp/...` paths and current directory downloads with securely generated temporary directories (`mktemp -d`) in `tools/os_installers/apt.sh`.

Co-authored-by: kidchenko <5432753+kidchenko@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

πŸ“ Walkthrough

Walkthrough

These changes implement secure temporary directory handling in shell scripts to mitigate TOCTOU and symlink attacks. A new security documentation file explains the vulnerability pattern and prevention approach, while the apt.sh installer is updated to use mktemp -d with automatic trap-based cleanup instead of predictable paths.

Changes

Cohort / File(s) Summary
Security Documentation
.jules/sentinel.md
Added security journal entry documenting shell script artifact download vulnerabilities (TOCTOU, symlink attacks) and prevention pattern using mktemp -d with trap cleanup.
Installer Security Hardening
tools/os_installers/apt.sh
Updated Go, yq, and lsd installers to use per-installation temporary directories created via mktemp -d with automatic EXIT trap cleanup, replacing hardcoded output paths in the current directory and /tmp.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through tempfiles true,
No /tmp shortcuts, nothing newβ€”
With mktemp -d and traps so neat,
Our burrows stay secure and sweet! ✨

πŸš₯ Pre-merge checks | βœ… 3
βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly identifies the main change: fixing insecure temporary download paths in apt.sh, which is the core focus of the PR addressing a HIGH-severity vulnerability.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel/fix-insecure-tmp-paths-10068104001288958326

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tools/os_installers/apt.sh`:
- Around line 211-213: The install steps download Go and yq into TMP_DIR using
wget and then run privileged installs (tar into /usr/local and dpkg -i for
yq/lsd); modify the sequence in the functions or script block that uses
GO_VERSION, TMP_DIR and the yq download lines to first fetch the corresponding
checksum/signature artifact (Go .sha256 or go<version>.linux-amd64.tar.gz.sha256
and yq's checksums/signature), verify the downloaded file with sha256sum -c (or
cosign verify-blob if a signature is available) and only proceed to sudo tar -C
/usr/local -xzf "$TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz" or sudo dpkg -i
for yq/lsd when verification succeeds; for lsd note that no official checksum
may exist so either skip privileged install until integrity method is available
or validate via GitHub release provenance before invoking sudo dpkg -i.
πŸͺ„ 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: b7585a8c-76ba-4c26-a66d-5affa9217164

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between eb5ca40 and c3703cf.

πŸ“’ Files selected for processing (2)
  • .jules/sentinel.md
  • tools/os_installers/apt.sh

Comment on lines +211 to +213
wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -O "$TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "$TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

What are the official checksum/signature verification instructions for: Go 1.23.4 linux-amd64 tarball, mikefarah/yq v4.44.6 yq_linux_amd64, and lsd-rs/lsd v1.1.5 amd64.deb?

πŸ’‘ Result:

Go 1.23.4 linux-amd64 tarball: No evidence found of Go 1.23.4 release as of 2026-04-16; current stable versions are around 1.26.x per https://go.dev/dl/. Check https://go.dev/dl/ for SHA256 checksum listed in table for go1.23.4.linux-amd64.tar.gz if released, or download go1.23.4.linux-amd64.tar.gz.sha256 from storage.googleapis.com/golang/. mikefarah/yq v4.44.6 yq_linux_amd64: Download from https://github.com/mikefarah/yq/releases/tag/v4.44.6. Download 'checksums' and 'checksums_hashes_order' files. Use extract-checksum.sh script: ./extract-checksum.sh SHA-256 yq_linux_amd64 | sha256sum -c. For signature (recent releases): cosign verify-blob --bundle checksums.bundle checksums (install cosign first). lsd-rs/lsd v1.1.5 amd64.deb: Download lsd_1.1.5_amd64.deb from https://github.com/lsd-rs/lsd/releases/tag/v1.1.5. No official checksums or signatures provided in release assets or docs; verify via GitHub release integrity or compute your own SHA256.

Citations:


🏁 Script executed:

sed -n '205,260p' tools/os_installers/apt.sh

Repository: kidchenko/dotfiles

Length of output: 2070


Add artifact integrity verification before privileged install steps for Go and yq.

Downloads are installed via sudo without checksum/signature verification. A compromised release artifact would be executed as root.

Go 1.23.4 and yq v4.44.6 have official checksums available and should be verified before installation:

  • Go: SHA256 checksum available at https://go.dev/dl/ or download go1.23.4.linux-amd64.tar.gz.sha256
  • yq: Checksums available in GitHub release assets; use the provided checksums file with sha256sum -c or cosign verify-blob for signature verification
πŸ” Suggested hardening pattern (Go example)
 (
     TMP_DIR=$(mktemp -d)
     trap 'rm -rf "$TMP_DIR"' EXIT
     GO_VERSION="1.23.4"
+    GO_SHA256="<official_sha256_from_go.dev>"
     wget "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -O "$TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz"
+    echo "${GO_SHA256}  $TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz" | sha256sum -c -
     sudo rm -rf /usr/local/go
     sudo tar -C /usr/local -xzf "$TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz"
 )

Apply similar verification to yq release assets.

Note: lsd v1.1.5 does not provide official checksums or signatures in release assets. Consider verifying via GitHub release integrity or evaluating if signature verification is available elsewhere before sudo dpkg -i.

Also applies to lines 240-242 (yq), 253-254 (lsd).

πŸ€– 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 211 - 213, The install steps
download Go and yq into TMP_DIR using wget and then run privileged installs (tar
into /usr/local and dpkg -i for yq/lsd); modify the sequence in the functions or
script block that uses GO_VERSION, TMP_DIR and the yq download lines to first
fetch the corresponding checksum/signature artifact (Go .sha256 or
go<version>.linux-amd64.tar.gz.sha256 and yq's checksums/signature), verify the
downloaded file with sha256sum -c (or cosign verify-blob if a signature is
available) and only proceed to sudo tar -C /usr/local -xzf
"$TMP_DIR/go${GO_VERSION}.linux-amd64.tar.gz" or sudo dpkg -i for yq/lsd when
verification succeeds; for lsd note that no official checksum may exist so
either skip privileged install until integrity method is available or validate
via GitHub release provenance before invoking sudo dpkg -i.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant