Exploit database

GH-9c880776c9a8305e3fb85450ce732147

hosted-power/nginx2root-patches

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-123007

23 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files22
hosted-power/nginx2root-patchesRevision de9901d65e8e

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

install-el9-rpm.sh

Shell · 3,762 bytes
#!/bin/bash
# Upgrade one exact Enterprise Linux NGINX package family from this bundle.
set -euo pipefail

[ "$(id -u)" -eq 0 ] || {
    echo 'ERROR: run as root (sudo ./install-el9-rpm.sh)' >&2
    exit 1
}

BUNDLE=$(realpath "${1:-$(dirname "$0")}")
[ -f "$BUNDLE/bundle.env" ] || {
    echo "ERROR: bundle metadata is missing from $BUNDLE" >&2
    exit 1
}
. "$BUNDLE/bundle.env"
. /etc/os-release
TARGET_MAJOR=${TARGET_MAJOR:-9}

[ "$ID" = "$TARGET_OS_ID" ] && [ "${VERSION_ID%%.*}" = "$TARGET_MAJOR" ] || {
    echo "ERROR: this bundle supports $TARGET_NAME $TARGET_MAJOR only" >&2
    exit 1
}

host_arch=$(rpm --eval '%{_arch}')
declare -A bundle_by_name=()
shopt -s nullglob
available_rpms=("$BUNDLE"/*.rpm)
[ "${#available_rpms[@]}" -gt 0 ] || {
    echo "ERROR: no RPM packages found in $BUNDLE" >&2
    exit 1
}

for package in "${available_rpms[@]}"; do
    package_name=$(rpm -qp --qf '%{NAME}' "$package")
    package_evr=$(rpm -qp --qf '%{EPOCHNUM}:%{VERSION}-%{RELEASE}' "$package")
    package_arch=$(rpm -qp --qf '%{ARCH}' "$package")
    [ "$package_evr" = "$HOTFIX_EVR" ] || {
        echo "ERROR: package $package_name has unexpected version $package_evr" >&2
        exit 1
    }
    case "$package_arch" in
        noarch|"$host_arch") ;;
        *) echo "ERROR: package $package_name architecture $package_arch does not match $host_arch" >&2; exit 1 ;;
    esac
    [ -z "${bundle_by_name[$package_name]:-}" ] || {
        echo "ERROR: duplicate package $package_name in bundle" >&2
        exit 1
    }
    bundle_by_name[$package_name]=$package
done

mapfile -t installed_names < <(rpm -qa --qf '%{NAME}\n' 'nginx*' | sort -u)
printf '%s\n' "${installed_names[@]}" | grep -qx nginx || {
    echo "ERROR: the $TARGET_NAME NGINX $TARGET_STREAM package family is not installed" >&2
    exit 1
}

selected_rpms=()
for package_name in "${installed_names[@]}"; do
    package_evr=$(rpm -q --qf '%{EPOCHNUM}:%{VERSION}-%{RELEASE}' "$package_name")
    case "$package_evr" in
        "$BASE_EVR"|"$HOTFIX_EVR") ;;
        *) echo "ERROR: installed $package_name version $package_evr does not match this bundle" >&2; exit 1 ;;
    esac
    [ -n "${bundle_by_name[$package_name]:-}" ] || {
        echo "ERROR: bundle has no matching package for installed $package_name" >&2
        exit 1
    }
    selected_rpms+=("${bundle_by_name[$package_name]}")
done

nginx -t
was_active=0
if [ -d /run/systemd/system ] && systemctl is-active --quiet nginx; then
    was_active=1
fi

dnf -y install "${selected_rpms[@]}"
nginx -t

if [ "$was_active" -eq 1 ]; then
    systemctl is-active --quiet nginx || {
        echo 'ERROR: nginx was active before the upgrade but is not active now' >&2
        exit 1
    }

    nginx_processes_use_installed_binary() {
        local found=0 process_exe process_name status_file
        for status_file in /proc/[0-9]*/status; do
            process_name=$(awk '$1 == "Name:" { print $2; exit }' \
                "$status_file" 2>/dev/null || true)
            [ "$process_name" = nginx ] || continue
            found=1
            process_exe=$(readlink "${status_file%/status}/exe" 2>/dev/null || true)
            [ "$process_exe" = /usr/sbin/nginx ] || return 1
        done
        [ "$found" -eq 1 ]
    }

    if ! nginx_processes_use_installed_binary; then
        systemctl restart nginx
        systemctl is-active --quiet nginx
        nginx_processes_use_installed_binary || {
            echo 'ERROR: nginx processes still use the replaced executable after restart' >&2
            exit 1
        }
    fi
fi

echo "PASS: upgraded installed $TARGET_NAME $TARGET_MAJOR NGINX $TARGET_STREAM packages to $HOTFIX_EVR"
rpm -q --qf '%{NAME} %{EPOCHNUM}:%{VERSION}-%{RELEASE}\n' "${installed_names[@]}" | sort