#!/usr/bin/env bash # FlowHardware : correctif de sécurité # Faille : CVE-2026-8674 (UBUNTU-CVE-2026-8674) # Logiciel : glibc # Source : https://get.flowhardware.ch/glibc-cve-2026-8674.sh # # Corriger : curl -fsSL https://get.flowhardware.ch/glibc-cve-2026-8674.sh | sudo bash # Vérifier seulement : curl -fsSL https://get.flowhardware.ch/glibc-cve-2026-8674.sh | sudo bash -s -- --check # # Ce script met à jour uniquement le logiciel concerné, depuis les dépôts officiels de votre distribution, # puis vérifie la version installée. Il ne touche à rien d'autre. set -u PKG='glibc' REF='CVE-2026-8674' MODE="${1:-${FH_MODE:-}}" say() { printf '%s\n' "$*"; } [ "$(id -u)" = 0 ] || { say "Lancez ce script en root (sudo)."; exit 1; } . /etc/os-release 2>/dev/null || { say "Système non reconnu (/etc/os-release absent)."; exit 1; } case "$ID" in ubuntu) KEY="ubuntu:$VERSION_ID";; alpine) KEY="alpine:$(printf '%s' "$VERSION_ID" | cut -d. -f1,2)";; *) KEY="$ID:${VERSION_ID%%.*}";; esac FIX='' case "$KEY" in 'ubuntu:22.04') FIX='2.35-0ubuntu3.18';; 'ubuntu:24.04') FIX='2.39-0ubuntu8.12';; 'ubuntu:26.04') FIX='2.43-2ubuntu2.7';; esac KERNEL=0 case "$PKG" in linux|linux-*|kernel|kernel-*) KERNEL=1;; esac if command -v dpkg-query >/dev/null 2>&1; then maxver() { best=''; while read -r v; do [ -n "$v" ] || continue; if [ -z "$best" ] || dpkg --compare-versions "$v" gt "$best"; then best=$v; fi; done; printf '%s' "$best"; } bins() { dpkg-query -W -f='${source:Package} ${Package} ${db:Status-Status}\n' 2>/dev/null | awk -v s="$PKG" '$1==s && $3=="installed" {print $2}'; } current() { dpkg-query -W -f='${source:Version}\n' $(bins) 2>/dev/null | sort -u | maxver; } vulnerable() { [ -z "$FIX" ] || dpkg --compare-versions "$1" lt "$FIX"; } BINS=$(bins) [ -n "$BINS" ] || { say "$PKG n'est pas installé sur cette machine : rien à faire."; exit 0; } CUR=$(current) if ! vulnerable "$CUR"; then say "OK : $PKG $CUR est déjà corrigé contre $REF."; exit 0; fi if [ "$MODE" = "--check" ]; then say "VULNÉRABLE : $PKG $CUR (corrigé à partir de ${FIX:-la prochaine version})."; exit 2; fi export DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a NEEDRESTART_SUSPEND=1 say ">>> Mise à jour de la liste des paquets" apt-get update -qq -o DPkg::Lock::Timeout=300 || say "(apt-get update a signalé des erreurs, on continue)" TARGETS=$BINS if [ $KERNEL = 1 ]; then META=$(dpkg-query -W -f='${Package} ${db:Status-Status}\n' 2>/dev/null | awk '$2=="installed" && $1 ~ /^linux-(image|headers|modules|generic|virtual|kvm|cloud)/ && $1 !~ /[0-9]+\.[0-9]+\.[0-9]+/ {print $1}') [ -n "$META" ] && TARGETS=$META fi say ">>> Installation du correctif : $(echo $TARGETS)" apt-get install -y --only-upgrade -o DPkg::Lock::Timeout=300 -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold $TARGETS || { say "ÉCHEC : apt-get a renvoyé une erreur."; exit 3; } NEW=$(current) elif command -v rpm >/dev/null 2>&1; then bins() { rpm -qa --qf '%{SOURCERPM} %{NAME}\n' 2>/dev/null | sed -E 's/^(.+)-[^-]+-[^-]+\.src\.rpm /\1 /' | awk -v s="$PKG" '$1==s || $2==s {print $2}' | sort -u; } current() { for b in $(bins); do rpm -q --qf '%{EPOCHNUM}:%{VERSION}-%{RELEASE}\n' "$b"; done 2>/dev/null | sort -V | tail -1; } vulnerable() { [ -z "$FIX" ] && return 0; [ "$(rpm --eval "%{lua: print(rpm.vercmp('$1', '$FIX'))}")" = "-1" ]; } BINS=$(bins) [ -n "$BINS" ] || { say "$PKG n'est pas installé sur cette machine : rien à faire."; exit 0; } CUR=$(current) if ! vulnerable "$CUR"; then say "OK : $PKG $CUR est déjà corrigé contre $REF."; exit 0; fi if [ "$MODE" = "--check" ]; then say "VULNÉRABLE : $PKG $CUR (corrigé à partir de ${FIX:-la prochaine version})."; exit 2; fi say ">>> Installation du correctif : $(echo $BINS)" dnf -y upgrade --refresh $BINS || yum -y update $BINS || { say "ÉCHEC : dnf a renvoyé une erreur."; exit 3; } NEW=$(current) elif command -v apk >/dev/null 2>&1; then current() { apk info -v 2>/dev/null | sed -n "s/^$PKG-\([0-9].*\)$/\1/p" | head -1; } vulnerable() { [ -z "$FIX" ] || [ "$(apk version -t "$1" "$FIX")" = "<" ]; } CUR=$(current) [ -n "$CUR" ] || { say "$PKG n'est pas installé sur cette machine : rien à faire."; exit 0; } if ! vulnerable "$CUR"; then say "OK : $PKG $CUR est déjà corrigé contre $REF."; exit 0; fi if [ "$MODE" = "--check" ]; then say "VULNÉRABLE : $PKG $CUR (corrigé à partir de ${FIX:-la prochaine version})."; exit 2; fi apk update -q && apk upgrade --no-cache "$PKG" || { say "ÉCHEC : apk a renvoyé une erreur."; exit 3; } NEW=$(current) else say "Gestionnaire de paquets non pris en charge."; exit 1 fi if vulnerable "$NEW"; then say "ÉCHEC : $PKG est toujours en version $NEW (attendu : $FIX ou plus). Le correctif n'est peut-être pas encore publié pour votre version." exit 3 fi say "OK : $PKG mis à jour de $CUR vers $NEW." if [ $KERNEL = 1 ]; then say "FH_REBOOT_REQUIRED : le nouveau noyau sera utilisé au prochain redémarrage." elif command -v needrestart >/dev/null 2>&1; then needrestart -r a -q >/dev/null 2>&1 || true say "Services concernés redémarrés." elif command -v needs-restarting >/dev/null 2>&1; then for s in $(needs-restarting -s 2>/dev/null); do systemctl try-restart "$s" >/dev/null 2>&1 || true; done say "Services concernés redémarrés." fi exit 0