#!/usr/bin/env bash # ============================================================================= # check-php-nov2026-en.sh – https://www.hollop.net/en/php-security-check-november-2026.html # # Checks whether a Linux system is affected by the vulnerabilities fixed in the # PHP security release of 19 Nov 2026 (17 issues, several critical / RCE). # Fixed versions: 8.5.13 | 8.4.28 | 8.3.37 | 8.2.36 (8.1 and older: EOL) # # Checks: # 1. All PHP binaries found (CLI, FPM, CGI, /opt/remi, /opt/plesk, ...) # -> upstream version against fixed version # -> for distribution packages (Ubuntu/Debian/RHEL) also the # package changelog for the CVE IDs (backports!) # 2. Running PHP processes still using an old (deleted) binary # 3. Risky configuration per SAPI (cli/fpm/apache2/cgi): # session.upload_progress.enabled, fatal_error_backtraces, # zend.exception_ignore_args, date.timezone # 4. FPM pools with catch_workers_output, mixed session serializers # 5. Web server: nginx fastcgi_keep_conn on / Apache enablereuse=on # 6. Optional: PHP in running Docker containers (--docker) # # The script changes nothing on the system and sends no data. # # Usage: sudo ./check-php-nov2026-en.sh [--docker] [--checkmk] [--no-color] # Exit: 0 = OK, 1 = WARN, 2 = CRIT (affected) # ============================================================================= set -u # --- fixed version per branch --------------------------------------------- declare -A FIXED=( [8.2]=8.2.36 [8.3]=8.3.37 [8.4]=8.4.28 [8.5]=8.5.13 ) SUPPORTED_MIN_BRANCH="8.2" # PHP 8.6.0 (GA 19 Nov 2026) already contains the fixes # CVE IDs from the release (for backport detection in the package changelog) CVES="CVE-2026-129289 CVE-2026-115560 CVE-2026-126714 CVE-2026-129496 \ CVE-2026-129474 CVE-2026-129182 CVE-2026-129481 CVE-2026-129291 \ CVE-2026-129538 CVE-2026-15353 CVE-2026-128064 CVE-2026-48841" # --- options ---------------------------------------------------------------- DO_DOCKER=0; CHECKMK=0; COLOR=1 for a in "$@"; do case "$a" in --docker) DO_DOCKER=1 ;; --checkmk) CHECKMK=1; COLOR=0 ;; --no-color) COLOR=0 ;; -h|--help) sed -n '2,30p' "$0"; exit 0 ;; *) echo "Unknown option: $a" >&2; exit 3 ;; esac done [ -t 1 ] || COLOR=0 if [ "$COLOR" = 1 ]; then R=$'\e[31m'; G=$'\e[32m'; Y=$'\e[33m'; B=$'\e[1m'; N=$'\e[0m' else R=; G=; Y=; B=; N=; fi STATUS=0; CRIT_MSG=(); WARN_MSG=() out() { [ "$CHECKMK" = 1 ] || printf '%s\n' "$*"; } ok() { out " ${G}[OK]${N} $*"; } warn() { out " ${Y}[WARN]${N} $*"; WARN_MSG+=("$*"); [ "$STATUS" -lt 1 ] && STATUS=1; } crit() { out " ${R}[CRIT]${N} $*"; CRIT_MSG+=("$*"); STATUS=2; } info() { out " [INFO] $*"; } hdr() { out ""; out "${B}== $* ==${N}"; } # limit every external call: no stdin, max. 10 s run10() { timeout 10 "$@" /dev/null; } ver_ge() { [ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; } is_on() { case "${1,,}" in 1|on|yes|true) return 0;; *) return 1;; esac; } [ "$(id -u)" -ne 0 ] && [ "$CHECKMK" = 0 ] && \ echo "${Y}Note: without root some configs/processes may not be readable.${N}" # ============================================================================= hdr "1. PHP binaries & versions" # ============================================================================= mapfile -t CANDIDATES < <( { find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -maxdepth 1 \ \( -type f -o -type l \) 2>/dev/null find /opt -maxdepth 6 \( -type f -o -type l \) -path '*bin/php*' 2>/dev/null } | grep -E '/(php([0-9.]+)?|php-fpm([0-9.]+)?|php([0-9.]+)?-fpm|php-cgi([0-9.]+)?|php([0-9.]+)?-cgi|phpdbg([0-9.]+)?)$' \ | while read -r f; do readlink -f "$f"; done | sort -u ) declare -A BRANCH_CLI=() # branch -> CLI binary (for config checks) FOUND=0 for bin in "${CANDIDATES[@]}"; do [ -x "$bin" ] || continue # phpdbg: -v = oplog (interactive!), version only with -V vflag="-v"; [[ "$(basename "$bin")" == phpdbg* ]] && vflag="-V" vout=$(run10 "$bin" "$vflag" | head -n3) grep -qiE '^(PHP|phpdbg)' <<<"$vout" || continue v=$(head -n1 <<<"$vout" | grep -m1 -oE '[0-9]+\.[0-9]+\.[0-9]+') [ -n "$v" ] || continue FOUND=1 br="${v%.*}" sapi=$(head -n1 <<<"$vout" | sed -nE 's/.*\(([a-z0-9-]+)\).*/\1/p') [[ "$(basename "$bin")" == phpdbg* ]] && sapi="phpdbg" [ "$sapi" = "cli" ] && [ -z "${BRANCH_CLI[$br]:-}" ] && BRANCH_CLI[$br]="$bin" # determine package origin pkg=""; pkgver=""; origin="unknown (self-compiled?)" if command -v dpkg-query >/dev/null 2>&1 && pkg=$(dpkg -S "$bin" 2>/dev/null | head -n1 | cut -d: -f1) && [ -n "$pkg" ]; then pkgver=$(dpkg-query -W -f='${Version}' "$pkg" 2>/dev/null) if [[ "$pkgver" == *sury* ]]; then origin="deb.sury.org / ondrej PPA (upstream versions)" else origin="distribution package (backports possible)"; fi elif command -v rpm >/dev/null 2>&1 && pkg=$(rpm -qf "$bin" 2>/dev/null) && [ $? -eq 0 ]; then pkgver="$pkg" if [[ "$pkg" == *remi* || "$bin" == /opt/remi/* ]]; then origin="Remi repo (upstream versions)" else origin="distribution package (backports possible)"; fi fi out "" out " ${B}$bin${N} → PHP $v ($sapi)" out " Package: ${pkg:--} ${pkgver:+($pkgver)} – origin: $origin" if ver_ge "$br" "8.6"; then ok "PHP $v – branch 8.6+ contains the fixes" continue fi if ! ver_ge "$br" "$SUPPORTED_MIN_BRANCH"; then crit "$bin: PHP $v is end of life – no upstream fixes (only backports by distribution/Plesk possible)" continue fi fix="${FIXED[$br]}" if ver_ge "$v" "$fix"; then ok "PHP $v >= $fix – patched" continue fi # upstream version too old -> look for backport in changelog hits="" if [ -n "$pkg" ] && [[ "$origin" == distribution* ]]; then if command -v dpkg-query >/dev/null 2>&1; then for cl in /usr/share/doc/"$pkg"/changelog.Debian.gz /usr/share/doc/php"$br"-common/changelog.Debian.gz; do [ -r "$cl" ] || continue for c in $CVES; do zgrep -qF "$c" "$cl" 2>/dev/null && hits+="$c "; done break done else cl=$(rpm -q --changelog "${pkg}" 2>/dev/null) for c in $CVES; do grep -qF "$c" <<<"$cl" && hits+="$c "; done fi fi if [ -n "$hits" ]; then n=$(wc -w <<<"$hits") warn "$bin: upstream $v < $fix, but backport found in package changelog ($n of $(wc -w <<<"$CVES") CVEs): $hits– check completeness with your distributor" elif [[ "$origin" == distribution* ]]; then crit "$bin: PHP $v < $fix – AFFECTED (no backport found in changelog)" else crit "$bin: PHP $v < $fix – AFFECTED → install the update (apt update && apt upgrade)" fi done [ "$FOUND" = 0 ] && ok "No PHP binaries found on the host" # ============================================================================= hdr "2. Running PHP processes with outdated binary" # ============================================================================= stale=0 for p in /proc/[0-9]*; do exe=$(readlink "$p/exe" 2>/dev/null) || continue case "$exe" in */php*|*/httpd*|*/apache2*) if [[ "$exe" == *"(deleted)"* ]]; then crit "PID ${p#/proc/} still runs a deleted/replaced binary: $exe → restart the service" stale=1 fi ;; esac done # mod_php: libphp in memory, but file replaced? if grep -lsE 'libphp[0-9.]*\.so \(deleted\)' /proc/[0-9]*/maps >/dev/null 2>&1; then crit "Apache still holds an old libphp*.so in memory → restart apache2/httpd"; stale=1 fi [ "$stale" = 0 ] && ok "No processes with outdated PHP binary" # ============================================================================= hdr "3. Risky configuration per SAPI" # ============================================================================= php_ini() { # $1=cli-bin $2=php.ini|"" $3=scan-dir|"" $4=php-code # include stderr: an invalid date.timezone only shows up as a startup warning if [ -n "$2" ]; then PHP_INI_SCAN_DIR="$3" timeout 10 "$1" -c "$2" -d display_startup_errors=1 -r "$4" &1 else timeout 10 "$1" -d display_startup_errors=1 -r "$4" &1; fi } CODE='$k=["session.upload_progress.enabled","session.serialize_handler","fatal_error_backtraces","zend.exception_ignore_args","date.timezone","error_log"]; foreach($k as $x){$v=ini_get($x); echo $x,"=",($v===false?"":$v),"\n";} $tz=ini_get("date.timezone"); echo "tz_valid=",($tz===""||in_array($tz,timezone_identifiers_list(),true))?"1":"0","\n";' for br in $(printf '%s\n' "${!BRANCH_CLI[@]}" | sort -V); do cli="${BRANCH_CLI[$br]}" # Debian/Ubuntu layout: /etc/php/X.Y// ; otherwise only the CLI view ctxs=("cli||") for s in fpm apache2 cgi; do [ -f "/etc/php/$br/$s/php.ini" ] && ctxs+=("$s|/etc/php/$br/$s/php.ini|/etc/php/$br/$s/conf.d") done for ctx in "${ctxs[@]}"; do IFS='|' read -r sapi ini scan <<<"$ctx" out ""; out " ${B}PHP $br / $sapi${N} ${ini:+($ini)}" declare -A C=() while IFS= read -r line; do if [[ "$line" =~ Invalid\ date\.timezone\ value\ \'([^\']*)\' ]]; then C[tz_valid]=0; C[date.timezone]="${BASH_REMATCH[1]}"; continue fi [[ "$line" == *=* ]] || continue k="${line%%=*}"; v="${line#*=}" [ "$k" = tz_valid ] && [ "${C[tz_valid]-}" = 0 ] && continue [ "$k" = date.timezone ] && [ "${C[tz_valid]-}" = 0 ] && continue C[$k]="$v" done < <(php_ini "$cli" "$ini" "$scan" "$CODE") # CVE-2026-115560: session.upload_progress if is_on "${C[session.upload_progress.enabled]-1}"; then warn "PHP $br/$sapi: session.upload_progress.enabled=On (CVE-2026-115560) → set to Off if not needed" else ok "session.upload_progress.enabled=Off"; fi # CVE-2026-129474: 8.5 only – fatal_error_backtraces=1 + zend.exception_ignore_args=0 if [ "$br" = "8.5" ]; then if is_on "${C[fatal_error_backtraces]-1}" && ! is_on "${C[zend.exception_ignore_args]-0}"; then warn "PHP 8.5/$sapi: fatal_error_backtraces=On AND zend.exception_ignore_args=Off (CVE-2026-129474) → zend.exception_ignore_args=On (as in php.ini-production)" else ok "fatal_error_backtraces / zend.exception_ignore_args not critical"; fi fi # CVE-2026-129496: invalid date.timezone + error log to a file if [ "${C[tz_valid]:-1}" = "0" ]; then warn "PHP $br/$sapi: invalid date.timezone='${C[date.timezone]}' (Startup-Warning, CVE-2026-129496) ${C[error_log]:+– error_log=${C[error_log]}}" else ok "date.timezone valid/empty"; fi out " session.serialize_handler=${C[session.serialize_handler]:-?}" unset C done done [ ${#BRANCH_CLI[@]} -eq 0 ] && [ "$FOUND" = 1 ] && info "No CLI binary found – config checks skipped" # ============================================================================= hdr "4. PHP-FPM pools" # ============================================================================= POOLS=$(ls /etc/php/*/fpm/pool.d/*.conf /etc/php-fpm.d/*.conf /etc/opt/remi/*/php-fpm.d/*.conf \ /opt/plesk/php/*/etc/php-fpm.d/*.conf 2>/dev/null) if [ -z "$POOLS" ]; then ok "No FPM pool configuration found" else declare -A SER=() for f in $POOLS; do if grep -qE '^[[:space:]]*catch_workers_output[[:space:]]*=[[:space:]]*(yes|on|1|true)' "$f"; then warn "$f: catch_workers_output=yes (CVE-2026-129291, root privileges in FPM master possible) → set to 'no' until updated" fi if grep -qiE '^[[:space:]]*php(_admin)?_(value|flag)\[session\.upload_progress\.enabled\][[:space:]]*=[[:space:]]*(1|on|yes|true)' "$f"; then warn "$f: pool explicitly enables session.upload_progress" fi s=$(sed -nE 's/^[[:space:]]*php(_admin)?_value\[session\.serialize_handler\][[:space:]]*=[[:space:]]*([a-z_]+).*/\2/p' "$f" | tail -n1) SER[${s:-default}]=1 done if [ ${#SER[@]} -gt 1 ]; then warn "FPM pools use different session.serialize_handler (${!SER[*]}) – critical with a shared session.save_path (CVE-2026-115560)" fi info "FPM pools checked: $(wc -w <<<"$POOLS") file(s)" ev=$(grep -hsE '^[[:space:]]*events\.mechanism' /etc/php/*/fpm/php-fpm.conf /etc/php-fpm.conf 2>/dev/null | head -n1) info "FPM events.mechanism: ${ev:-not set (Linux default: epoll)}" fi # ============================================================================= hdr "5. Web server: FastCGI connection reuse (CVE-2026-129289)" # ============================================================================= hit=0 if [ -d /etc/nginx ]; then while read -r l; do [ -n "$l" ] && { warn "nginx: $l → FastCGI keepalive + PHP-FPM = request smuggling risk"; hit=1; }; done \ < <(grep -RnsE '^[^#]*fastcgi_keep_conn[[:space:]]+on' /etc/nginx 2>/dev/null) fi for d in /etc/apache2 /etc/httpd; do [ -d "$d" ] || continue while read -r l; do [ -n "$l" ] && { warn "Apache: $l → enablereuse with FPM backend = request smuggling risk"; hit=1; }; done \ < <(grep -RnsiE '^[^#]*enablereuse=on' "$d" 2>/dev/null) done [ "$hit" = 0 ] && ok "No fastcgi_keep_conn on / enablereuse=on found" # ============================================================================= if [ "$DO_DOCKER" = 1 ]; then hdr "6. Docker containers" # ============================================================================= if ! command -v docker >/dev/null 2>&1; then info "docker not installed" else while read -r id name; do [ -n "$id" ] || continue v=$(timeout 15 docker exec "$id" sh -c 'command -v php >/dev/null 2>&1 && php -r "echo PHP_VERSION;"' 2>/dev/null) [ -n "$v" ] || continue v="${v%%-*}"; br="${v%.*}" if ver_ge "$br" "8.6"; then ok "Container $name: PHP $v" elif ! ver_ge "$br" "$SUPPORTED_MIN_BRANCH"; then crit "Container $name: PHP $v is EOL" elif ver_ge "$v" "${FIXED[$br]}"; then ok "Container $name: PHP $v" else crit "Container $name: PHP $v < ${FIXED[$br]} – AFFECTED (rebuild/pull the image)"; fi done < <(timeout 15 docker ps --format '{{.ID}} {{.Names}}' 2>/dev/null) info "Docker check finished (only running containers with 'php' in PATH)" fi fi # ============================================================================= # Result # ============================================================================= if [ "$CHECKMK" = 1 ]; then # Checkmk local check: put a wrapper into /usr/lib/check_mk_agent/local/ (call with --checkmk) case $STATUS in 0) txt="Not affected by the PHP security release of 2026-11-19" ;; 1) txt="${#WARN_MSG[@]} warning(s): ${WARN_MSG[0]}" ;; 2) txt="${#CRIT_MSG[@]} critical: ${CRIT_MSG[0]}" ;; esac printf '%d "PHP Security 2026-11" crit=%d;warn=%d %s\n' "$STATUS" "${#CRIT_MSG[@]}" "${#WARN_MSG[@]}" "${txt//$'\n'/ }" exit 0 fi hdr "Result" case $STATUS in 0) out " ${G}${B}OK${N} – system not affected." ;; 1) out " ${Y}${B}WARNING${N} – PHP patched or backport detected, but ${#WARN_MSG[@]} configuration risk(s)." ;; 2) out " ${R}${B}AFFECTED${N} – ${#CRIT_MSG[@]} critical finding(s). Update PHP and restart PHP-FPM/Apache!" out " Ubuntu/Debian: apt update && apt list --upgradable 2>/dev/null | grep -i php" out " RHEL/Alma: dnf check-update 'php*'" ;; esac exit $STATUS