-
Notifications
You must be signed in to change notification settings - Fork 1
π‘οΈ Sentinel: [HIGH] Fix insecure temporary file usage in apt.sh #86
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
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,15 @@ | ||
| # Sentinel Journal | ||
|
|
||
| ## 2024-04-11 - [Insecure Temporary File Usage for yq Download] | ||
|
|
||
| **Vulnerability:** Predictable temporary file path `/tmp/yq` used during | ||
| download and installation in `tools/os_installers/apt.sh`. | ||
|
|
||
| **Learning:** 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 files when `sudo mv /tmp/yq ...` is | ||
| executed. | ||
|
|
||
| **Prevention:** Always use securely generated random directories like | ||
| `mktemp -d` and wrap in a subshell with a cleanup trap to prevent local | ||
| privilege escalation and symlink attacks. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -231,9 +231,13 @@ 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 | ||||||||||||||||||||||||||||||||
| sudo chmod +x /usr/local/bin/yq | ||||||||||||||||||||||||||||||||
| ( | ||||||||||||||||||||||||||||||||
| 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" | ||||||||||||||||||||||||||||||||
| sudo mv "$TMP_DIR/yq" /usr/local/bin/yq | ||||||||||||||||||||||||||||||||
| sudo chmod +x /usr/local/bin/yq | ||||||||||||||||||||||||||||||||
|
Comment on lines
+237
to
+239
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 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 The script downloads an executable and installs it with 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
Suggested change
π€ 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 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