-
Notifications
You must be signed in to change notification settings - Fork 1
🛡️ Sentinel: [CRITICAL] Fix predictable /tmp path vulnerability in apt.sh #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ## 2024-05-24 - [Avoid predictable /tmp files in installation scripts] | ||
|
Check failure on line 1 in .jules/sentinel.md
|
||
| **Vulnerability:** In `tools/os_installers/apt.sh`, the `yq` binary was downloaded directly to a predictable path `/tmp/yq` before being moved with `sudo` to a global path. This can expose the system to symlink attacks or local privilege escalation since `/tmp` is a world-writable directory. | ||
|
Check failure on line 2 in .jules/sentinel.md
|
||
| **Learning:** Hardcoding paths in `/tmp` for temporary files, especially those executed or moved with `sudo` privileges, introduces a vulnerability where malicious users could preemptively create a symlink or a file at that location. | ||
|
Check failure on line 3 in .jules/sentinel.md
|
||
| **Prevention:** Always use `mktemp -d` to create securely generated, isolated temporary directories (e.g. `tmp_dir=$(mktemp -d)`) and use these directories to store downloaded artifacts, ensuring they are deleted via `rm -rf` afterwards. | ||
|
Check failure on line 4 in .jules/sentinel.md
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Comment on lines
+235
to
+236
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: The official checksum verification workflow for the yq_linux_amd64 binary in GitHub release v4.44.6 of mikefarah/yq is as follows: 1. Download the binary from: https://github.com/mikefarah/yq/releases/download/v4.44.6/yq_linux_amd64 2. Download the checksum files: - checksums: https://github.com/mikefarah/yq/releases/download/v4.44.6/checksums - checksums_hashes_order: https://github.com/mikefarah/yq/releases/download/v4.44.6/checksums_hashes_order - (optionally) extract-checksum.sh: https://github.com/mikefarah/yq/releases/download/v4.44.6/extract-checksum.sh 3. Extract the SHA-256 checksum using the provided script (recommended): ./extract-checksum.sh SHA-256 yq_linux_amd64 This outputs the expected SHA-256 hash for the binary (e.g., "acebc9d07aa2d0e482969b2c080ee306e8f58efbd6f2d857eefbce6469da1473" from example usage). 4. Verify the checksum: sha256sum yq_linux_amd64 Compare the output to the extracted hash. Alternatively, pipe the extracted line to a verifier like sha256sum --check or rhash -c -. This workflow uses multiple hash algorithms in a single 'checksums' file, with 'checksums_hashes_order' defining the column order. The extract script simplifies retrieval of the specific SHA-256 value without depending on tool versions. No GPG signatures are provided; verification relies on these checksums. v4.44.6 exists as confirmed by release references and actions (Dec 2024), following the standard pattern seen in later releases like v4.52.4. Citations:
🏁 Script executed: # Check the file size and examine the relevant lines and context
wc -l tools/os_installers/apt.shRepository: kidchenko/dotfiles Length of output: 92 🏁 Script executed: # Read the context around lines 235-236 to see YQ_VERSION and any verification
sed -n '220,250p' tools/os_installers/apt.shRepository: kidchenko/dotfiles Length of output: 948 🏁 Script executed: # Search for any checksum or signature verification in the entire file
grep -n "checksum\|signature\|sha256\|md5\|gpg\|verify" tools/os_installers/apt.shRepository: kidchenko/dotfiles Length of output: 1484 Add checksum verification for yq binary before installation. Line 235 downloads yq binary from GitHub and line 236 installs it to The yq project provides official checksums at: Verify the downloaded binary before privileged installation: 🤖 Prompt for AI Agents |
||
| sudo chmod +x /usr/local/bin/yq | ||
| rm -rf "$tmp_dir" | ||
|
Comment on lines
+234
to
+238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether yq installation block has trap-based cleanup around mktemp usage.
rg -n -C3 'Installing yq|mktemp -d|trap .*EXIT|rm -rf "\$tmp_dir"|wget .*yq_linux_amd64|sudo (mv|install) .*yq' tools/os_installers/apt.shRepository: kidchenko/dotfiles Length of output: 484 🏁 Script executed: # Check if set -e is enabled at line 7
head -10 tools/os_installers/apt.shRepository: kidchenko/dotfiles Length of output: 283 🏁 Script executed: # Get broader context around the yq installation block to check for error handling
sed -n '230,240p' tools/os_installers/apt.shRepository: kidchenko/dotfiles Length of output: 399 Ensure temporary directory cleanup runs on failure paths. Because 💡 Suggested fix- tmp_dir=$(mktemp -d)
+ tmp_dir="$(mktemp -d)"
+ cleanup_yq_tmp() { rm -rf "$tmp_dir"; }
+ trap cleanup_yq_tmp EXIT
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"
+ cleanup_yq_tmp
+ trap - EXIT🤖 Prompt for AI Agents |
||
| fi | ||
|
|
||
| # Install lsd (LSDeluxe) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix markdownlint blockers (MD041, MD022, MD013) in this new file.
CI currently fails because Line 1 is not a top-level heading, heading spacing is missing, and Lines 2–4 exceed max line length.
📝 Suggested lint-compliant rewrite
📝 Committable suggestion
🧰 Tools
🪛 GitHub Check: Lint Documentation
[failure] 4-4: Line length
.jules/sentinel.md:4:81 MD013/line-length Line length [Expected: 80; Actual: 237] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md013.md
[failure] 3-3: Line length
.jules/sentinel.md:3:81 MD013/line-length Line length [Expected: 80; Actual: 233] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md013.md
[failure] 2-2: Line length
.jules/sentinel.md:2:81 MD013/line-length Line length [Expected: 80; Actual: 292] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md013.md
[failure] 1-1: First line in a file should be a top-level heading
.jules/sentinel.md:1 MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "## 2024-05-24 - [Avoid predict..."] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md041.md
[failure] 1-1: Headings should be surrounded by blank lines
.jules/sentinel.md:1 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "## 2024-05-24 - [Avoid predictable /tmp files in installation scripts]"] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md022.md
🪛 LanguageTool
[locale-violation] ~4-~4: In American English, ‘afterward’ is the preferred variant. ‘Afterwards’ is more commonly used in British English and other dialects.
Context: ... ensuring they are deleted via
rm -rfafterwards.(AFTERWARDS_US)
🤖 Prompt for AI Agents