Skip to content
CYBER SECURE
SYSTEM
Let’s talk security

Why apt upgrade Missed Your Vulnerable Runtimes: Eliminating Shadow-$PATH Shims Across PHP2Shell, Node2Shell, and Java2Shell

Running sudo apt full-upgrade and seeing 0 not upgraded creates a dangerous illusion of safety on developer workstations, CI runners, and self-hosted application boxes. When we audited a freshly upgraded Ubuntu 24.04.5 LTS host against November 2026's critical runtime disclosures—PHP2Shell, Node2Shell, and Java2Shell—every Ubuntu distribution package on disk was already patched, yet typing php, node, or java in a terminal executed three separate unpatched binaries from 2024 and early 2025. In Part 3 of our 5-Part Linux & Full-Stack Hardening Series, here is how to uncover and permanently retire shadow-$PATH shims.

Diagram showing how user-space shims in herd-lite, ~/.nvm, /usr/local/php, and /etc/alternatives bypass apt full-upgrade across PHP2Shell, Node2Shell, and Java2Shell
Figure 1: Tracing how user-space shims and hijacked alternatives shadow patched Ubuntu 24.04 LTS packages—and unifying every runtime on verified builds.

1. Run a Non-Destructive Shadow-Binary Sweep First

Package scanners that only query dpkg -l or rpm -qa completely miss single-file binaries dropped into user home directories, manual make install trees under /usr/local, and per-user version managers prepended inside ~/.zshrc or ~/.bashrc. Run this read-only inspection across interactive and system contexts first:

# 1. Enumerate every candidate executable in the current shell PATH
which -a php php-fpm composer node npm pnpm deno bun java javac

# 2. Check Debian/Ubuntu symlink chains in /etc/alternatives
for bin in php java javac; do
  [ -e "/etc/alternatives/$bin" ] && echo "$bin -> $(readlink -f "/etc/alternatives/$bin")"
done

# 3. Scan /usr/local, /opt, and user dot-directories for standalone runtimes
ls -ld /usr/local/php* /usr/lib/jvm/* ~/.nvm/versions/node/* ~/.config/herd-lite* ~/.sdkman/candidates/java/* 2>/dev/null

2. Trap #1: PHP2Shell (`CVE-2026-109618` & `CVE-2026-109619`) Hidden Behind Herd-Lite & `/usr/local/php`

At first glance, Ubuntu's /usr/bin/php8.3 -v printed PHP 8.3.6 (cli)—a version number that looks older than the upstream 8.3.36+ fix floor if you ignore Debian revision suffixes. Checking Ubuntu's actual security changelog proved the distribution package was already safe:

# Verify backported PHP2Shell & upload_progress patches in Ubuntu's changelog
zgrep -iE '109618|109619|115560' /usr/share/doc/php8.3-common/changelog.Debian.gz
# Output:
#   - debian/patches/CVE-2026-109618_109619.patch: Avoid state corruption via ...
#   - debian/patches/CVE-2026-115560.patch: Session.upload_progress.enabled is off by default

Yet running plain php -v in a terminal returned PHP 8.4.1 (built: Nov 21 2024)! Two separate shadow layers were intercepting PHP invocations:

  • User-Space Installer Shim (~/.config/herd-lite/bin/php): One-line Laravel/PHP developer installers prepend ~/.config/herd-lite/bin to ~/.zshrc and ~/.bashrc, freezing a static PHP binary in place forever unless manually updated.
  • Hijacked System Alternatives (/etc/alternatives/php -> /usr/local/php/bin/php): Two old source builds in /usr/local/php and /usr/local/php8 had been registered in update-alternatives years earlier. Deleting /usr/local/php without updating alternatives breaks /usr/bin/php with a dangling symlink!
# Cleanly retire Herd-Lite shim, purge /usr/local/php*, and repoint update-alternatives
mv ~/.config/herd-lite ~/.config/herd-lite.disabled
sed -i 's|^\(.*herd-lite.*\)$|# [retired unpatched PHP shim] \1|' ~/.bashrc ~/.zshrc
sudo rm -rf /usr/local/php /usr/local/php8
sudo update-alternatives --remove php /usr/local/php/bin/php 2>/dev/null || true
sudo update-alternatives --set php /usr/bin/php8.3

3. Trap #2: Node2Shell (`CVE-2026-111497`) Inside Dormant & Default NVM Trees

Why Workstation & CI Node Binaries Still Matter Without an Open Port: CVE-2026-111497 corrupts heap memory inside node:zlib's C Brotli stream decoder. Any local CLI workflow—npm install, pnpm, webhook test runners, or AI coding agents—using fetch() / undici to read a malicious or compromised upstream HTTPS response with Content-Encoding: br traverses the vulnerable decoder.

Because APT has zero visibility into ~/.nvm/versions/node/, our host was still defaulting to v22.12.0 alongside four ancient v10, v12, v14, and v16 directories from 2021. Promoting NVM in place preserved global CLI tools while removing every vulnerable binary:

export NVM_DIR="$HOME/.nvm" && . "$NVM_DIR/nvm.sh"
# Install latest patched Node 22 LTS (>= 22.23.4; installed v22.23.5) and migrate global CLIs
nvm install 22 --reinstall-packages-from=22.12.0
nvm alias default 22
# Remove unpatched 22.12.0 and legacy EOL branches
nvm uninstall 22.12.0
rm -rf ~/.nvm/versions/node/v10* ~/.nvm/versions/node/v12* ~/.nvm/versions/node/v14* ~/.nvm/versions/node/v16*

4. Trap #3: Java2Shell (`CVE-2026-114938`) & Orphaned Third-Party Vendor JDK `.deb`s

Checking Java revealed a classic split-brain setup: Ubuntu had automatically upgraded openjdk-21-jre to 21.0.13.1+2-1~24.04.1 (containing all nine November 17, 2026 CVEs including CVE-2026-114938), and checking grep -o 'avx512[^ ]*' /proc/cpuinfo confirmed the workstation's CPU lacked avx512_vbmi instructions anyway. However, a manually installed Oracle jdk-23 package (23.0.2, which reached End of Life in March 2025) held a higher priority in /etc/alternatives/java, leaving every java and javac command running an 18-month-unpatched JVM.

# Purge orphaned non-LTS Oracle JDK 23 and unify java + javac on patched OpenJDK 21 LTS
sudo apt-get -y purge jdk-23
sudo apt-get -y install openjdk-21-jdk default-jdk
java -version && javac -version
Runtime Shadow Binary Found First in $PATH Unified Patched Binary Verified
PHP ~/.config/herd-lite/bin/php (8.4.1, Nov 2024) /usr/bin/php8.3 (8.3.6-0ubuntu0.24.04.14, CVE-2026-109618/19 patched)
Node.js ~/.nvm/versions/node/v22.12.0/bin/node (Brotli vulnerable) ~/.nvm/versions/node/v22.23.5/bin/node (Brotli 1.2.1+ safe)
Java / Javac /usr/lib/jvm/jdk-23.0.2-oracle-x64 (EOL Mar 2025) /usr/lib/jvm/java-21-openjdk-amd64 (21.0.13.1+2 LTS)

Questions When Auditing Developer & Bastion Runtimes

What about Deno, Bun, pyenv, rustup, or SDKMAN installations in home directories?

Every user-space toolchain manager (~/.deno, ~/.bun, ~/.pyenv, ~/.sdkman, ~/.cargo) operates outside OS package management. Include home-directory binary sweeps in quarterly workstation and bastion reviews—either running each tool's native self-updater (deno upgrade, bun upgrade, sdk upgrade) or removing unused runtimes.

Why do systemd services sometimes run a different runtime version than an SSH session on the same server?

Interactive shells source ~/.bashrc or ~/.zshrc (picking up ~/.nvm or ~/.local/bin), whereas systemd units inherit a minimal clean PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin unless overridden via Environment=. Auditing both which -a in login shells and /proc/<pid>/exe on running services catches mismatches in either direction.

Continue to the Final Guide in Our 5-Part Series

Next: locking down Linux kernel LPE primitives (io_uring, TTY line disciplines, BPF JIT, and SUID binaries) while keeping Electron desktop apps working safely under Ubuntu 24.04 AppArmor.

INTERACTIVE PHP2SHELL EXPOSURE & CONTAINMENT LAB

Test your PHP SAPI & upload-progress posture

Select your active PHP branch and Server API mode to inspect worker heap exposure and generate a non-overridable FPM containment snippet.

01 / PHP RELEASE LINE
02 / SAPI & UPLOAD_PROGRESS
Runtime memory boundary and containment diagramUNTRUSTED INPUTPre-Auth StreamHTTP / SOCKETRUNTIME GATEUnpatched StubOVERFLOW PATHWORKER HEAPExposed MemoryACTION NEEDED
HIGH EXPOSURE • CVE-2026-109618 & CVE-2026-109619 REACHABLE

Multipart upload-progress UAF and OOM longjmp() worker reuse are both reachable on unpatched shared worker pools. Lock upload_progress off immediately and stage patched FPM binaries.

php_admin_flag[session.upload_progress.enabled] = off
pm.max_requests = 300
; Upgrade target: PHP 8.2.35+ / 8.3.36+ / 8.4.27+ / 8.5.12+