Exploit databaseDownload repository ZIP
GH-86245d80c6bb506583baf0be88985d52
dehasoft-tr/cve-2026-112816
Sources for CVE-2026-112816
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files2
dehasoft-tr/cve-2026-112816Revision f207301cf3c6
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
fix-cve-2026-112816.sh
Suggested starting fileShell · 8,100 bytes#!/usr/bin/env bash
# CVE-2026-112816 - Canonical LXD / MicroCloud snap security updater
# Ubuntu: read-only audit by default; --apply enables targeted snap updates.
# Vendor: https://discourse.ubuntu.com/t/security-advisory-critical-vulnerability-found-in-canonical-lxd-and-microcloud/90557
set -Eeuo pipefail
export LC_ALL=C
MODE=check
CLUSTER_OK=0
UNPATCHED=0
UNKNOWN=0
FOUND=0
usage() {
cat <<'HELP'
Usage: bash fix-cve-2026-112816.sh [--check | --apply] [--cluster-ok]
--check Show installed LXD/MicroCloud snap versions (default; no changes)
--apply Refresh only vulnerable LXD/MicroCloud snaps on their current channel
--cluster-ok Explicit confirmation that coordinated cluster maintenance is planned
-h, --help Show this help
The script NEVER installs LXD, changes snap channels, edits the firewall,
restarts guests directly, or changes SSH. Take a backup before --apply.
HELP
}
while (($#)); do
case "$1" in
--check) MODE=check ;;
--apply) MODE=apply ;;
--cluster-ok) CLUSTER_OK=1 ;;
-h|--help) usage; exit 0 ;;
*) printf '[ERROR] Unknown option: %s\n' "$1" >&2; usage >&2; exit 2 ;;
esac
shift
done
log() { printf '[INFO] %s\n' "$*"; }
warn() { printf '[WARN] %s\n' "$*" >&2; }
error(){ printf '[ERROR] %s\n' "$*" >&2; }
if [[ "$MODE" == apply && "$EUID" -ne 0 ]]; then
error 'Run the update with sudo: sudo bash fix-cve-2026-112816.sh --apply'
exit 2
fi
if ! command -v dpkg >/dev/null 2>&1; then
error 'This updater requires Ubuntu / dpkg for version comparison.'
exit 2
fi
# snap list columns: Name Version Rev Tracking Publisher Notes
snap_details() {
local pkg="$1" output
command -v snap >/dev/null 2>&1 || return 1
output="$(snap list "$pkg" 2>/dev/null)" || return 1
printf '%s\n' "$output" | awk -v pkg="$pkg" '
NR > 1 && $1 == pkg { printf "%s|%s|%s\n", $2, $4, $6; found=1; exit }
END { if (!found) exit 1 }
'
}
# Snap often appends a build hash: e.g. 5.21.8-abc123. Compare numeric release only.
release_version() {
local raw="$1" patch=0
if [[ "$raw" =~ (alpha|beta|rc[0-9]|dev|pre[0-9]) ]]; then
return 1 # pre-release versions cannot be declared fixed from the version label
fi
if [[ "$raw" =~ ^([0-9]+)\.([0-9]+)(\.([0-9]+))?([+~\-].*)?$ ]]; then
[[ -z "${BASH_REMATCH[4]:-}" ]] || patch="${BASH_REMATCH[4]}"
printf '%s.%s.%s\n' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "$patch"
else
return 1
fi
}
# Minimum patched releases in the vendor's October 2026 bulletin.
required_version() {
local pkg="$1" track="${2%%/*}" ver="$3"
case "$pkg:$track" in
lxd:4.0) echo 4.0.15 ;;
lxd:5.0) echo 5.0.11 ;;
lxd:5.21) echo 5.21.9 ;;
lxd:6) echo 6.10.1 ;;
microcloud:2) echo 2.1.5 ;;
microcloud:3) echo 3.4.1 ;;
lxd:latest)
case "$ver" in
4.0.*) echo 4.0.15 ;; 5.0.*) echo 5.0.11 ;;
5.21.*) echo 5.21.9 ;; 6.*) echo 6.10.1 ;;
*) return 1 ;;
esac ;;
microcloud:latest)
case "$ver" in 2.*) echo 2.1.5 ;; 3.*) echo 3.4.1 ;; *) return 1 ;; esac ;;
*) return 1 ;;
esac
}
# CSV format has no header. Any returned member indicates clustering is enabled.
cluster_detected() {
local result lxc_bin=""
lxc_bin="$(command -v lxc || true)"
if [[ -z "$lxc_bin" && -x /snap/bin/lxc ]]; then lxc_bin=/snap/bin/lxc; fi
[[ -n "$lxc_bin" ]] || return 1
if command -v timeout >/dev/null 2>&1; then
result="$(timeout 15 "$lxc_bin" cluster list --force-local --format csv 2>/dev/null)" || return 1
else
result="$("$lxc_bin" cluster list --force-local --format csv 2>/dev/null)" || return 1
fi
[[ -n "${result//[[:space:]]/}" ]]
}
check_or_patch() {
local pkg="$1" details raw channel notes current minimum updated_details updated_raw updated_channel updated_core
details="$(snap_details "$pkg")" || return 1
FOUND=$((FOUND + 1))
IFS='|' read -r raw channel notes <<< "$details"
log "$pkg installed: version=$raw channel=$channel notes=${notes:--}"
if ! current="$(release_version "$raw")"; then
warn "$pkg: cannot verify version format '$raw'; no update attempted."
UNKNOWN=1
return 0
fi
if ! minimum="$(required_version "$pkg" "$channel" "$current")"; then
warn "$pkg: unsupported/unrecognized track '$channel'; manual vendor check required."
UNKNOWN=1
return 0
fi
log "$pkg minimum patched version for this track: $minimum"
if dpkg --compare-versions "$current" ge "$minimum"; then
log "$pkg: version requirement PASSED; no changes needed."
return 0
fi
warn "$pkg: below the minimum patched version ($current < $minimum)."
if [[ "$MODE" != apply ]]; then
UNPATCHED=1
return 0
fi
log "Refreshing $pkg only, preserving tracked channel $channel ..."
if ! snap refresh "$pkg"; then
error "$pkg refresh failed. No claim of remediation."
UNPATCHED=1
return 0
fi
if ! updated_details="$(snap_details "$pkg")"; then
error "$pkg: unable to read version after refresh."
UNKNOWN=1
return 0
fi
IFS='|' read -r updated_raw updated_channel notes <<< "$updated_details"
if ! updated_core="$(release_version "$updated_raw")"; then
error "$pkg: post-update version '$updated_raw' could not be verified."
UNKNOWN=1
return 0
fi
if [[ "$updated_channel" != "$channel" ]]; then
error "$pkg: tracked channel changed unexpectedly ($channel -> $updated_channel)."
UNKNOWN=1
return 0
fi
if dpkg --compare-versions "$updated_core" ge "$minimum"; then
log "$pkg: PATCH VERIFIED ($current -> $updated_core, channel=$updated_channel)."
else
error "$pkg remains below patched release ($updated_core < $minimum)."
warn 'The stable release may still be rolling out. Do NOT treat this host as patched.'
UNPATCHED=1
fi
}
printf '\nCVE-2026-112816 | LXD + MicroCloud | mode=%s\n\n' "$MODE"
LXD_PRESENT=0
MICROCLOUD_PRESENT=0
if snap_details lxd >/dev/null 2>&1; then LXD_PRESENT=1; fi
if snap_details microcloud >/dev/null 2>&1; then MICROCLOUD_PRESENT=1; fi
if ((LXD_PRESENT == 0)); then
if command -v lxd >/dev/null 2>&1 || { command -v dpkg-query >/dev/null 2>&1 && dpkg-query -W -f='${Status}' lxd 2>/dev/null | grep -q 'install ok installed'; }; then
warn 'LXD appears to be installed outside snap. Automatic patching is NOT supported for this installation.'
UNKNOWN=1
else
log 'Canonical LXD snap is not installed.'
fi
fi
if ((MICROCLOUD_PRESENT == 0)); then
log 'MicroCloud snap is not installed.'
fi
if ((LXD_PRESENT == 0 && MICROCLOUD_PRESENT == 0 && UNKNOWN == 0)); then
log 'No affected Canonical snap installation detected; no changes made.'
exit 0
fi
# Never change the state of a clustered environment without explicit approval.
# If everything is already fixed, allow --apply to be an idempotent no-op.
needs_update() {
local pkg="$1" details raw channel notes current minimum
details="$(snap_details "$pkg")" || return 1
IFS='|' read -r raw channel notes <<< "$details"
current="$(release_version "$raw")" || return 1
minimum="$(required_version "$pkg" "$channel" "$current")" || return 1
! dpkg --compare-versions "$current" ge "$minimum"
}
if [[ "$MODE" == apply && "$CLUSTER_OK" -eq 0 ]]; then
if { ((MICROCLOUD_PRESENT)) && needs_update microcloud; } || \
{ ((LXD_PRESENT)) && needs_update lxd && cluster_detected; }; then
error 'Cluster/MicroCloud update requires coordinated maintenance.'
error 'After coordinating ALL cluster members, rerun with --apply --cluster-ok.'
exit 4
fi
fi
if ((LXD_PRESENT)); then check_or_patch lxd; fi
if ((MICROCLOUD_PRESENT)); then check_or_patch microcloud; fi
printf '\n'
if ((UNPATCHED)); then
error 'Result: UNPATCHED version(s) detected. Check installed channel and vendor rollout.'
exit 10
fi
if ((UNKNOWN)); then
error 'Result: NOT VERIFIED (manual intervention required).'
exit 11
fi
log 'Result: all detected Canonical LXD/MicroCloud snap versions meet the announced security minima.'
log 'Note: this verifies installed versions, not whether the host was compromised before patching.'