Harden lock authentication command lookup

Keep the target user's local bin on user-scoped upgrade paths while giving privileged lock and firewall helpers only root-owned search directories. Pin the lock helper's root PATH and fprintd-list executable, with regression coverage for each defense independently.

Reported-by: Rooke Poole <rookpool97@gmail.com>
This commit is contained in:
Mehmet Ince committed 2026-09-04 19:43:03 +01:00
1 parent 493067741e
commit 70047956fa
4 files changed
+262 -8

No files matched your search

+8 -1
View File
@@ -6,6 +6,12 @@
set -e
# Install and upgrade callers can start this helper as root. Ignore their PATH
# so optional commands never fall through to a user-writable directory.
if (( EUID == 0 )); then
export PATH=/usr/share/omarchy/bin:/usr/local/bin:/usr/bin:/bin
fi
target_user=${OMARCHY_INSTALL_USER:-${SUDO_USER:-}}
if [[ -z $target_user && -n ${PKEXEC_UID:-} ]]; then
target_user=$(getent passwd "$PKEXEC_UID" | cut -d: -f1)
@@ -34,7 +40,8 @@ auth required pam_faillock.so authsucc
account include system-local-login
EOF
if omarchy-cmd-present fprintd-list && fprintd-list "$target_user" 2>/dev/null | grep -qi finger; then
if [[ -x /usr/bin/fprintd-list ]] &&
/usr/bin/fprintd-list "$target_user" 2>/dev/null | grep -qi finger; then
echo "Configuring lock screen fingerprint authentication..."
as_root tee /etc/pam.d/omarchy-lock-fingerprint >/dev/null <<'EOF'
#%PAM-1.0
+6 -3
View File
@@ -175,7 +175,10 @@ target_home=$(getent passwd "$target_user" | cut -d: -f6)
[[ -n $target_home && -d $target_home ]] || fail "Home directory for '$target_user' was not found."
target_uid=$(id -u "$target_user")
target_runtime_dir="/run/user/$target_uid"
package_path="/usr/share/omarchy/bin:/usr/local/bin:/usr/bin:/bin:$target_home/.local/bin"
# User-local commands are needed only after dropping to the target user. Never
# expose their search path to commands run through as_root.
root_path=/usr/share/omarchy/bin:/usr/local/bin:/usr/bin:/bin
package_path="$root_path:$target_home/.local/bin"
as_root() {
if (( EUID == 0 )); then
@@ -661,7 +664,7 @@ configure_lock_authentication() {
as_root env \
OMARCHY_INSTALL_USER="$target_user" \
OMARCHY_PATH=/usr/share/omarchy \
PATH="$package_path" \
PATH="$root_path" \
"$apply_lock"
}
@@ -1287,7 +1290,7 @@ apply_firewall_defaults() {
fi
log "Applying Omarchy firewall defaults"
as_root env OMARCHY_PATH=/usr/share/omarchy PATH="$package_path" \
as_root env OMARCHY_PATH=/usr/share/omarchy PATH="$root_path" \
bash -euo pipefail "$firewall_script" ||
warn "Could not apply firewall defaults; run 'sudo bash $firewall_script' after reboot."
}