Exploit databaseDownload repository ZIP
GH-baa1948fa181370bee4d9c39b5f9a2de
jordanhardee/cve-2026-109518-apt-patch-proxmox-and-generic
Sources for CVE-2026-109518
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files4
jordanhardee/cve-2026-109518-apt-patch-proxmox-and-genericRevision 212993359fed
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
cve-2026-109518-local.sh
Shell · 12,159 bytes#!/bin/sh
# cve-2026-109518-local.sh - check / patch CVE-2026-109518 (APT) on THIS machine.
# Works on any Linux box (bare metal, VM, container, Proxmox or not). Debian, Ubuntu
# and every derivative are judged by apt's own version + changelog; anything without
# apt/dpkg is reported as SKIP and left untouched.
#
# sh cve-2026-109518-local.sh patch: check, mitigate, patch, verify
# sh cve-2026-109518-local.sh --audit audit: read-only, changes nothing
# ... --csv /root/cve.csv also append a CSV row to that file
# remote: ssh root@host 'sh -s -- --audit' < cve-2026-109518-local.sh
#
# Patch order: 1 tamper check of cached .debs (mismatch = stop, flag INFECTED?)
# 2 Acquire::Retries=0 (bug unexploitable) 3 upgrade apt only 4 re-check
# Status: PATCHED / OK-OLD / SKIP (exit 0); VULNERABLE / MITIGATED / UNKNOWN / FAIL
# (exit 1); INFECTED? (exit 2). Last line is a machine-readable REPORT|... line.
#
# EXPERIMENTAL - remove the temporary mitigation once a system is patched:
# --revert-check read-only: say per system whether it is safe to revert
# --revert remove /etc/apt/apt.conf.d/99-cve-2026-109518 (APT retries
# back to normal). NEVER downgrades or unpatches apt. Refuses
# unless the system is verified PATCHED, the cache is clean and
# the file is exactly the one this script wrote. Keeps a backup.
# --restore-mitigation put the mitigation back (from the backup, or freshly written)
# Revert status: REVERT-READY / REVERTED / NOTHING-TO-REVERT / RESTORED (exit 0),
# KEPT = refused for safety, see detail (exit 1).
set -u
MODE=patch; CSV=""
while [ $# -gt 0 ]; do
case "$1" in
--audit) MODE=audit ;;
--revert-check) MODE=revert-check ;;
--revert) MODE=revert ;;
--restore-mitigation) MODE=restore ;;
--csv) CSV=${2:-}; shift ;;
--csv=*) CSV=${1#*=} ;;
-h|--help) awk 'NR>1 && /^#/ {sub(/^# ?/, ""); print; next} NR>1 {exit}' "$0" 2>/dev/null; exit 0 ;;
*) echo "unknown option: $1 (use --audit, --revert-check, --revert, --restore-mitigation, --csv FILE)"; exit 64 ;;
esac
shift
done
MITF=/etc/apt/apt.conf.d/99-cve-2026-109518
MITC='Acquire::Retries "0";'
BAKD=/var/backups/cve-2026-109518
export DEBIAN_FRONTEND=noninteractive
osr=/etc/os-release; [ -r "$osr" ] || osr=/usr/lib/os-release
os=$( [ -r "$osr" ] && . "$osr"; echo "${PRETTY_NAME:-${NAME:-unknown OS}}")
v=""; fixed=""; ret=""; cache="not checked"; note=""
finish() { # finish STATUS detail...
st=$1; shift; det="$*${note:+; $note}"
echo "STATUS $st $det [$os]"
clean() { printf '%s' "$1" | tr '|\n' '/ '; }
echo "REPORT|$st|$(clean "$v")|$(clean "$fixed")|$(clean "$ret")|$(clean "$cache")|$(clean "$os")|$(clean "$det")"
if [ -n "$CSV" ]; then
q() { printf '"%s"' "$(printf '%s' "$1" | sed 's/"/""/g')"; }
[ -s "$CSV" ] || echo 'timestamp,host,mode,status,apt_version,fixed_version,acquire_retries,cache_check,os,detail' > "$CSV"
echo "$(q "$(date '+%F %T')"),$(q "$(hostname)"),$MODE,$(q "$st"),$(q "$v"),$(q "$fixed"),$(q "$ret"),$(q "$cache"),$(q "$os"),$(q "$det")" >> "$CSV"
echo "CSV row written to $CSV"
fi
case "$st" in
PATCHED|OK-OLD|SKIP|REVERT-READY|REVERTED|NOTHING-TO-REVERT|RESTORED) exit 0 ;;
INFECTED*) exit 2 ;;
*) exit 1 ;;
esac
}
if ! command -v apt-get >/dev/null 2>&1 || ! command -v dpkg >/dev/null 2>&1 \
|| ! command -v dpkg-deb >/dev/null 2>&1; then
finish SKIP "not Debian/Ubuntu-family, nothing to patch"
fi
v=$(dpkg-query -W -f='${Version}' apt 2>/dev/null)
[ -n "$v" ] || finish SKIP "apt-get present but the apt package is not installed (apt-rpm?)"
check_cache() { # sets ok/mis/unk/n
ok=0; mis=0; unk=0; n=0
for deb in /var/cache/apt/archives/*.deb; do
[ -e "$deb" ] || break
n=$((n+1))
pkg=$(dpkg-deb -f "$deb" Package); ver=$(dpkg-deb -f "$deb" Version); arch=$(dpkg-deb -f "$deb" Architecture)
want=$(apt-cache show "$pkg:$arch=$ver" 2>/dev/null | awk '/^SHA256:/{print $2}' | sort -u)
have=$(sha256sum "$deb" | cut -d' ' -f1)
if [ -z "$want" ]; then unk=$((unk+1))
elif echo "$want" | grep -qx "$have"; then ok=$((ok+1))
else mis=$((mis+1)); echo "MISMATCH $pkg $ver ($deb)"
fi
done
if [ "$n" -eq 0 ]; then cache="cache empty, tamper check inconclusive"
else cache="cache ok=$ok mismatch=$mis unknown=$unk"; fi
}
eff_retries() { # effective Acquire::Retries (default 3 from apt 2.3 on, 0 before)
ret=$(apt-config dump 2>/dev/null | awk -F'"' '/^Acquire::Retries /{print $2; exit}')
if [ -z "$ret" ]; then
if dpkg --compare-versions "$v" ge 2.3~; then ret="3 (default)"; else ret="0 (default)"; fi
fi
}
decide() { # sets vst / vdet: the patch verdict for this system
v=$(dpkg-query -W -f='${Version}' apt)
eff_retries
# Evidence 1: apt's own changelog names this CVE (derivative backports: Pop!_OS,
# Trisquel, Kali, Deepin ... under their own version numbers)
chg=/usr/share/doc/apt/changelog.Debian.gz
inchg=""; [ -r "$chg" ] && gzip -dc "$chg" 2>/dev/null | grep -q 'CVE-2026-109518' && inchg=1
# Evidence 2: version vs. the advisories. apt series don't overlap between Debian and
# Ubuntu except 1.0.x (Debian 8 vs Ubuntu 14.04) and 3.3.x, split by suffix.
fixed=""; ubu=""
case "$v" in
1.0.*) fixed=1.0.1ubuntu2.24+esm4; ubu=1 ;; # Ubuntu 14.04 ESM
1.2.*) fixed=1.2.36+esm1; ubu=1 ;; # Ubuntu 16.04 ESM
1.6.*) fixed=1.6.19+esm1; ubu=1 ;; # Ubuntu 18.04 ESM
2.0.*) fixed=2.0.12+esm1; ubu=1 ;; # Ubuntu 20.04 ESM
2.2.*) fixed=2.2.5 ;; # Debian 11
2.4.*) fixed=2.4.15ubuntu0.1; ubu=1 ;; # Ubuntu 22.04 family
2.6.*) fixed=2.6.2 ;; # Debian 12 family
2.7.*|2.8.*) fixed=2.8.4ubuntu0.1; ubu=1 ;; # Ubuntu 24.04 family (2.7 = pre-update)
3.0.*) fixed=3.0.4 ;; # Debian 13 family
3.2.*) fixed=3.2.1ubuntu0.1; ubu=1 ;; # Ubuntu 26.04 family
3.3.*ubuntu*) fixed=3.3.3ubuntu0.1; ubu=1 ;; # Ubuntu 26.10 family
3.3.*) fixed=3.3.6 ;; # Debian testing/unstable, Kali ...
esac
ge=""; [ -n "$fixed" ] && dpkg --compare-versions "$v" ge "$fixed" && ge=1
ubuver=""; case "$v" in *ubuntu*|*+esm*) ubuver=1 ;; esac
r0=""; case "$ret" in 0|"0 (default)") r0=1 ;; esac
old=""; dpkg --compare-versions "$v" lt 2.2~ && old=1
if [ -n "$inchg" ]; then
vst=PATCHED; vdet="apt $v, fix confirmed in its changelog ($cache)"
elif [ -n "$ge" ] && { [ -z "$ubu" ] || [ -n "$ubuver" ]; }; then
vst=PATCHED; vdet="apt $v ($cache)"
elif [ -n "$old" ] && [ -n "$r0" ]; then
vst=OK-OLD; vdet="apt $v: old release, not exploitable with Acquire::Retries=$ret ($cache)"
elif [ -n "$ge" ]; then
vst=UNKNOWN; vdet="apt $v: non-Ubuntu build of an Ubuntu series, fix can't be confirmed - ask your distro (retries=$ret) ($cache)"
elif [ -z "$fixed" ] && [ -z "$old" ]; then
vst=UNKNOWN; vdet="apt $v: version not in the advisories (EOL or custom build) - ask your distro (retries=$ret) ($cache)"
elif [ -n "$r0" ]; then
vst=MITIGATED; vdet="apt $v < ${fixed:-no fix for this release}: $why; Acquire::Retries=0 makes it unexploitable ($cache)"
else
vst=VULNERABLE; vdet="apt $v < ${fixed:-no fix for this release}, Acquire::Retries=$ret - EXPLOITABLE; run without --audit ($cache)"
fi
}
verdict() { decide; finish "$vst" "$vdet"; }
why="not patched yet"
echo "== CVE-2026-109518 $MODE on $(hostname) [$os] apt $v"
echo "-- tamper check"
check_cache
[ "$mis" -gt 0 ] && finish "INFECTED?" "$mis cached package(s) fail hash check - NOT patched, isolate this system ($cache)"
echo "$cache"
# ---------------- EXPERIMENTAL: revert / restore the mitigation ----------------
mit_state() { # ours / absent / foreign (edited by someone, a symlink, not a file)
if [ ! -e "$MITF" ] && [ ! -L "$MITF" ]; then echo absent
elif [ -L "$MITF" ] || [ ! -f "$MITF" ]; then echo foreign
elif [ "$(cat "$MITF")" = "$MITC" ]; then echo ours
else echo foreign; fi
}
need_rw_root() {
[ "$(id -u)" = 0 ] || finish FAIL "--$MODE must run as root (use --revert-check to just look)"
[ -w /etc/apt/apt.conf.d ] || finish FAIL "/etc/apt/apt.conf.d is not writable (read-only system?) - nothing changed"
}
if [ "$MODE" = restore ]; then
echo "-- EXPERIMENTAL: restore mitigation"
need_rw_root
case "$(mit_state)" in
ours) eff_retries; finish RESTORED "mitigation already in place (Acquire::Retries=$ret), nothing changed" ;;
foreign) finish KEPT "$MITF exists but was edited by someone - left as is, check it by hand" ;;
esac
latest=$(ls -t "$BAKD"/99-cve-2026-109518.* 2>/dev/null | head -1)
if [ -n "$latest" ] && [ "$(cat "$latest")" = "$MITC" ]; then cp -p "$latest" "$MITF"; src="backup $latest"
else echo "$MITC" > "$MITF"; src="written fresh"; fi
eff_retries
[ "$ret" = 0 ] || finish FAIL "mitigation restored ($src) but Acquire::Retries is '$ret': another apt config overrides it"
finish RESTORED "mitigation back in place ($src), Acquire::Retries=0"
fi
if [ "$MODE" = revert-check ] || [ "$MODE" = revert ]; then
echo "-- EXPERIMENTAL: $MODE"
why="not patched"
decide
state=$(mit_state)
[ "$state" = absent ] && { eff_retries; finish NOTHING-TO-REVERT "no mitigation file here; system is $vst (Acquire::Retries=$ret)"; }
[ "$state" = foreign ] && finish KEPT "$MITF was edited by someone or is not a plain file - not ours to remove, left as is"
[ "$vst" = PATCHED ] || finish KEPT "system is $vst, not verified patched - mitigation stays: $vdet"
if [ "$MODE" = revert-check ]; then
finish REVERT-READY "patched ($vdet) - --revert would remove $MITF (backup kept)"
fi
need_rw_root
mkdir -p "$BAKD" && chmod 700 "$BAKD" || finish FAIL "can't create backup dir $BAKD - nothing changed"
bak=$BAKD/99-cve-2026-109518.$(date +%Y%m%d-%H%M%S)
cp -p "$MITF" "$bak" && cmp -s "$MITF" "$bak" || finish FAIL "backup to $bak failed - nothing changed"
rm -f "$MITF"
if ! apt-config dump >/dev/null 2>&1; then
cp -p "$bak" "$MITF"; finish FAIL "apt config failed to load after removal - mitigation put back"
fi
decide
if [ "$vst" != PATCHED ]; then
cp -p "$bak" "$MITF"; finish FAIL "verdict changed to $vst after removal - mitigation put back"
fi
finish REVERTED "mitigation removed, Acquire::Retries now $ret, apt $v still patched; backup: $bak (undo: --restore-mitigation)"
fi
if [ "$MODE" = audit ]; then
why="not patched (audit mode, nothing changed)"
verdict
fi
[ "$(id -u)" = 0 ] || finish FAIL "patch mode must run as root (or use --audit)"
if [ -x /usr/bin/midclt ]; then
eff_retries; finish SKIP "TrueNAS SCALE appliance: apt is disabled by design, update through TrueNAS (apt $v)"
fi
if [ ! -w /usr/bin ] || [ ! -w /var/lib/dpkg ]; then
note="read-only/immutable system (Vanilla OS, Endless OS, ...) - not changed, update with its own tool"
why="can't patch a read-only system"
verdict
fi
echo "-- mitigate (Acquire::Retries=0)"
echo "$MITC" > "$MITF"
eff_retries
[ "$ret" = 0 ] || finish FAIL "Acquire::Retries is '$ret', another apt config overrides it - NOT patched"
echo "-- patch"
held=$(apt-mark showhold 2>/dev/null | grep -E '^(apt|libapt-pkg[0-9.a-z]*)(:.*)?$' | tr '\n' ' ')
apt-get update -q || finish FAIL "apt-get update failed, mitigated only ($cache)"
if [ -n "$held" ]; then
echo "note: on hold, not upgrading: $held"
why="not upgraded because apt is on hold (run: apt-mark unhold apt)"
else
why="fix not in this system's repos yet, rerun later"
# confold/confdef: keep locally edited apt config files instead of stopping at a prompt
apt-get install --only-upgrade -y -q -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold apt \
|| finish FAIL "apt upgrade failed, mitigated only ($cache)"
fi
echo "-- verify"
check_cache
[ "$mis" -gt 0 ] && finish "INFECTED?" "$mis package(s) fail hash check after patching - isolate this system ($cache)"
verdict