THE DFIR BLOG
Menu

    Cyber Security

PHP2Shell: AI Didn't Find the Bug. It Made the Bug Cheap.

10/21/2026

0 Comments

 
On October 21, PHP shipped emergency fixes for two bugs in the language itself, CVE-2026-109618 and CVE-2026-109619. Together they're being called PHP2Shell. Both can lead to remote code execution with no login. PHP rates each one 9.2 on CVSS v4.0.

We've had bad PHP bugs before. What makes this one stick with me is not the score. It's that the flaw sat in PHP for over a decade, and the bug class looked too hard to weaponize. Then researchers working with frontier AI models showed it was.

​That's the part every security leader should sit with. The bar for "exploitable" just moved.
Picture

What actually broke

The short version: PHP doesn't clean up properly when it gives up on a request.

When a PHP request runs out of memory or hits a fatal error, PHP abandons it on the spot. Engineers call this a "bailout." It's fast, but it skips cleanup. Some internal state gets left half built or pointing at memory that's already been freed.

The two CVEs are two ways that leftover mess becomes dangerous:

  • CVE-2026-109618 is about corrupted memory left behind by the out of memory bailout. PHP's fix stops abandoning requests mid-flight and halts at a safe point instead.
  • CVE-2026-109619 is about stale shared state that survives into the next request on the same worker. That next request can touch memory the previous one already freed. The fix is a full reset between requests.

Two things make this worse than a typical app bug. First, it's in the runtime, so your code can be perfectly written and still exposed. Second, on Apache with mod_php, the problem can be reached during request startup, before any of your application code runs. PHP-FPM is exposed too. PHP's advisory confirms code execution on FPM for CVE-2026-109619. For CVE-2026-109618, the FPM risk comes from code analysis rather than a working exploit.

Beyond code execution, researchers also showed worker crashes and leaks of server memory. That last one matters for responders, and I'll come back to it.

One note of caution: vendor write-ups and PHP's own advisories group the individual techniques under the two CVE numbers a little differently. If you're mapping detections to a specific CVE, go by PHP's advisories.

The AI story, minus the hype

The headlines say AI found PHP2Shell. That's close, but not quite right, and the difference matters.

Here's what the reporting supports:

  • Calif found the bug family first, around August 1, as part of an OpenAI funded program, using OpenAI's GPT-5.6 Sol. They reported it to PHP with a working proof of concept in mid August.
  • A second research team independently found variants a few weeks later, also leaning on frontier models (Gemini 4 Argon and GPT-5.6 Sol) for discovery, exploit building and patch checking.
  • Quarkslab is reported to have flagged the out of memory weakness in an earlier audit, where it sat unfixed because no one had shown it was exploitable. Only one source says this and Quarkslab's published audit doesn't confirm it, so treat it as unverified.

Now the nuance. Calif itself gives a lot of the credit to a human. Its team knew a PHP exploitation technique from 2004, and that knowledge is what pointed the model in the right direction. Calif also pushed back on the idea that a model can surface every bug from simple prompts.

So my read is this. AI didn't magically discover a new class of flaw. It took a weakness that was known, deemed too hard to weaponize, and made weaponizing it cheap, in days instead of months.

That's not hype. That's an economics shift, and it's the real story.

About that "70% of the Internet" line

It traces back to W3Techs, which reports that about 69% of websites with a detectable server side language use PHP. That's a share of websites, not of the Internet, and not of vulnerable machines.

A lot of those sites sit behind managed hosts that patched within hours, or behind WAFs that had rules live before disclosure. The more honest measure is internet facing hosts running PHP. Estimates there range from about 1.3 million (researcher Silas Cutler) to 5.1 million (VirusTotal) depending on method. Mallory's analysis of Shodan banners found about 884,000 hosts advertising PHP 8.1 or older.

The number I'd actually worry about is the old stuff. About 35% of WordPress sites still run unsupported PHP. Upstream fixes only ship as releases for 8.2 through 8.5, with source patches for 7.4, 8.0 and 8.1. Anything older gets nothing. That long tail is where the real exposure lives.

How it unfolded

The coordinated disclosure was planned for October 22. It broke two days early. Times are UTC, and a few vary by source.

When (UTC) What happened
Oct 21, ~14:00 PHP releases 8.5.12, 8.4.27, 8.3.36 and 8.2.35, plus source fixes for 7.4 to 8.1
Oct 21, from ~07:34 Exploitation attempts reported; over 100 proof of concept repos on GitHub by afternoon, though VulnCheck says most don't work
Oct 21, 03:02 Cloudflare WAF protections go live for all plans, including free
Oct 20, ~19:33 PHP pre-announces an emergency release; CERT-EU issues advisory 2026-018 the same day
Oct 20, ~15:20 An anonymous Hacker News post leaks both CVE numbers
Aug 19 to 24 A second team independently finds and reports variants
Aug 11 to 14 Calif reports to PHP with a working proof of concept
~Aug 1 Calif finds the bug family

The response was dramatic. Wikimedia took PHP systems offline as a precaution. In the Netherlands, the national cyber agency pulled its own site, and other government and hospital sites went down too. As of October 21, there were attempts but no publicly confirmed breaches, and neither CVE was on CISA's KEV list.

What I'd do this week

If I were walking into a leadership sync tomorrow, this is the list I'd bring.

  1. Find every PHP runtime, not just every PHP app. Think appliances, vendor products, control panels, Windows software that bundles PHP, and container images. Dependency scanners often miss PHP because it's the runtime, not a package.
  2. Patch internet facing systems first. Fixed releases are 8.5.12, 8.4.27, 8.3.36 and 8.2.35. For distro packages, check the changelog for the CVE IDs since version numbers may not move.
  3. Restart and rebuild. A patched package does nothing while old workers keep running. Containers need fresh images.
  4. Get end of life PHP off the internet. If it's older than 7.4, there's no fix coming. Isolate it or shut it down.
  5. Treat WAFs as a bridge. Cloudflare, Imperva and others shipped rules fast, and that helped. Every one of them calls it a stopgap, and attackers were already tweaking payloads to get around them.
  6. Ask vendors in writing. Which build fixes both CVEs, when was it deployed, and were workers restarted.
  7. Don't stop at one workaround. The config level mitigations are different for each CVE. Applying one set leaves the other bug open. Patching is the only complete fix.

Quick checks you can run today

These assume a Debian or Ubuntu style Linux host. Adjust paths for your setup and try them on one box before rolling them out.

Find every PHP runtime on a host, including the ones hiding inside vendor software:

# Executables named php, php-fpm or php-cgi (with or without a version suffix),
# plus Apache's mod_php module, which is usually not executable
sudo find / -xdev -type f -regextype posix-extended \( \
  -regex '.*/(php|php-fpm|php-cgi)[0-9.]*' -perm -u+x \
  -o -regex '.*/libphp[0-9.]*\.so' \) 2>/dev/null

Check whether a PHP build is on a fixed upstream release:

php -r '
$fixed = ["8.5"=>"8.5.12","8.4"=>"8.4.27","8.3"=>"8.3.36","8.2"=>"8.2.35"];
$v = PHP_VERSION; $b = PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;
if (!isset($fixed[$b]))
  echo "$v: no upstream release fix; patched only if your distro backported it, else isolate\n";
elseif (version_compare($v, $fixed[$b], "<"))
  echo "$v: older than upstream fix {$fixed[$b]}; vulnerable unless your distro backported it\n";
else
  echo "$v: on a fixed upstream release\n";'

Distro packages often keep the old version number, so look for the CVE IDs in the changelog instead:

# Debian / Ubuntu (reads the installed changelog, works offline)
zgrep -E 'CVE-2026-1096(18|19)' /usr/share/doc/php*-common/changelog.Debian.gz
# RHEL / Alma / Rocky
rpm -q --changelog php-common | grep -E 'CVE-2026-1096(18|19)'

No match means the fix isn't in that package yet.

Check container images too, since each one carries its own PHP:

docker images --format '{{.Repository}}:{{.Tag}}' | while read -r img; do
  ver=$(docker run --rm --entrypoint php "$img" -r 'echo PHP_VERSION;' </dev/null 2>/dev/null)
  [ -n "$ver" ] && echo "$img -> PHP $ver"
done

After patching, restart workers and confirm nothing old is still running:

sudo systemctl restart php8.3-fpm apache2
ps -o pid,lstart,cmd -C php-fpm8.3,apache2   # every start time should be after the patch

If you truly can't patch yet, PHP's advisories list partial workarounds for CVE-2026-109619. Those settings do nothing for CVE-2026-109618, which has its own partial workarounds in its advisory, such as a low post_max_size and request size limits at the front end. Treat all of them as a stopgap:

; php.ini (partial mitigation for CVE-2026-109619 only)
session.upload_progress.enabled = 0   ; disables upload progress bars
fatal_error_backtraces = 0            ; PHP 8.5 only

One script to check a host

If you'd rather run one thing, here's a read-only script that pulls the checks above together. It finds PHP binaries and mod_php modules, compares each version to the fixed release for its branch, looks for distro backports in package changelogs, flags workers still running a binary that was replaced on disk, and optionally checks local Docker images. It exits 1 if anything needs attention, so it drops into a fleet tool or CI job easily.

I tested it on Ubuntu 24.04 against real and simulated PHP 7.2, 8.1, 8.3, 8.4 and 8.5 builds, and it passes ShellCheck.

#!/usr/bin/env bash
# php2shell-check.sh
# Finds PHP runtimes on a Linux host and flags ones exposed to PHP2Shell
# (CVE-2026-109618 and CVE-2026-109619).
#
# Read-only. It changes nothing on the host. Run as root for full coverage:
#   sudo bash php2shell-check.sh                # host checks
#   sudo bash php2shell-check.sh --containers   # also check local Docker images
#
# Exit codes: 0 = nothing flagged, 1 = something needs attention, 2 = no PHP found

set -u

CVE_RE='CVE-2026-1096(18|19)'
FIXED_85="8.5.12"; FIXED_84="8.4.27"; FIXED_83="8.3.36"; FIXED_82="8.2.35"
CHECK_CONTAINERS=0
[ "${1:-}" = "--containers" ] && CHECK_CONTAINERS=1

flagged=0
found=0

say()  { printf '%s\n' "$*"; }
hdr()  { printf '\n== %s ==\n' "$*"; }
flag() { flagged=1; printf '  [!] %s\n' "$*"; }
ok()   { printf '  [ok] %s\n' "$*"; }
info() { printf '  [i] %s\n' "$*"; }

[ "$(id -u)" -ne 0 ] && say "Note: not running as root, some paths and processes may be missed."

# Compare a PHP version against the upstream fixed release for its branch.
classify() {
  local v="$1" major minor fixed
  major=${v%%.*}; minor=${v#*.}; minor=${minor%%.*}
  case "$major.$minor" in
    8.5) fixed=$FIXED_85 ;;
    8.4) fixed=$FIXED_84 ;;
    8.3) fixed=$FIXED_83 ;;
    8.2) fixed=$FIXED_82 ;;
    8.1|8.0|7.4) echo NO_UPSTREAM_RELEASE; return ;;
    *) echo NO_FIX; return ;;
  esac
  # sort -V puts the lower version first
  if [ "$(printf '%s\n%s\n' "$v" "$fixed" | sort -V | head -1)" = "$fixed" ]; then
    echo FIXED
  else
    echo "OLDER:$fixed"
  fi
}

report_version() {
  local where="$1" v="$2" backported="$3" c branch
  c=$(classify "$v")
  branch=$(echo "$v" | cut -d. -f1,2)
  # A Debian/Ubuntu backport only counts for its own branch (php8.3-common covers 8.3)
  if [ "$backported" = yes ] && [ -n "$BACKPORT_BRANCHES" ]; then
    case " $BACKPORT_BRANCHES " in *" $branch "*) ;; *) backported=no ;; esac
  fi
  case "$c" in
    FIXED) ok "$where: PHP $v is on a fixed upstream release" ;;
    OLDER:*)
      if [ "$backported" = yes ]; then
        ok "$where: PHP $v, distro package lists the CVE fix (backport)"
      else
        flag "$where: PHP $v is older than upstream fix ${c#OLDER:} and no backport was found"
      fi ;;
    NO_UPSTREAM_RELEASE)
      if [ "$backported" = yes ]; then
        ok "$where: PHP $v, distro package lists the CVE fix (backport)"
      else
        flag "$where: PHP $v has only source patches upstream; no backport found, patch or isolate"
      fi ;;
    NO_FIX) flag "$where: PHP $v gets no upstream fix at all; isolate or retire it" ;;
  esac
}

# ---------------------------------------------------------------------------
hdr "Distro packages (backport check)"
backport=no
BACKPORT_BRANCHES=""   # filled for Debian/Ubuntu; RHEL packages apply to the host's one PHP
if command -v dpkg >/dev/null 2>&1; then
  for cl in /usr/share/doc/php*-common/changelog.Debian.gz; do
    [ -e "$cl" ] || continue
    pkg=$(basename "$(dirname "$cl")")
    if zgrep -qE "$CVE_RE" "$cl" 2>/dev/null; then
      ok "$pkg changelog mentions the PHP2Shell CVEs"; backport=yes
      BACKPORT_BRANCHES="$BACKPORT_BRANCHES ${pkg#php}"; BACKPORT_BRANCHES="${BACKPORT_BRANCHES%-common}"
    else
      info "$pkg changelog does not mention the PHP2Shell CVEs yet"
    fi
  done
fi
if command -v rpm >/dev/null 2>&1; then
  for pkg in $(rpm -qa --qf '%{NAME}\n' 2>/dev/null | grep -E '^php[0-9]*-common$|^php-cli$' | sort -u); do
    if rpm -q --changelog "$pkg" 2>/dev/null | grep -qE "$CVE_RE"; then
      ok "$pkg changelog mentions the PHP2Shell CVEs"; backport=yes
    else
      info "$pkg changelog does not mention the PHP2Shell CVEs yet"
    fi
  done
fi
[ "$backport" = no ] && info "No patched distro package detected (fine if PHP was built from source)"

# ---------------------------------------------------------------------------
hdr "PHP binaries and modules on disk"
while IFS= read -r bin; do
  found=1
  case "$bin" in
    *.so)
      info "$bin: Apache mod_php module; its version follows the matching php package above"
      continue ;;
  esac
  v=$("$bin" -v 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
  if [ -z "$v" ]; then
    info "$bin: could not read a version"
    continue
  fi
  report_version "$bin" "$v" "$backport"
done < <(find / -xdev -type f -regextype posix-extended \( \
           -regex '.*/(php|php-fpm|php-cgi)[0-9.]*' -perm -u+x \
           -o -regex '.*/libphp[0-9.]*\.so' \) 2>/dev/null | sort -u)

# ---------------------------------------------------------------------------
hdr "Running PHP and web worker processes"
any_proc=0
stale=0
for pid in $(ps -eo pid=,comm= | awk '$2 ~ /^(php|php-fpm|php-cgi|apache2|httpd|lsphp|frankenphp)/ {print $1}'); do
  any_proc=1
  exe=$(readlink "/proc/$pid/exe" 2>/dev/null || true)
  name=$(ps -o comm= -p "$pid" 2>/dev/null)
  case "$exe" in
    *"(deleted)"*)
      stale=1
      flag "PID $pid ($name) is still running a binary that was replaced on disk; restart it to load the fix" ;;
  esac
done
[ "$any_proc" -eq 0 ] && info "No PHP or web worker processes running"
[ "$any_proc" -eq 1 ] && [ "$stale" -eq 0 ] && ok "No workers running stale binaries"

# ---------------------------------------------------------------------------
hdr "Partial mitigation settings (CVE-2026-109619 only)"
if command -v php >/dev/null 2>&1; then
  up=$(php -r 'echo ini_get("session.upload_progress.enabled");' 2>/dev/null)
  if [ "$up" = "1" ]; then
    info "CLI php.ini has session.upload_progress.enabled = On (FPM and Apache may use a different php.ini)"
  else
    info "CLI php.ini has session.upload_progress.enabled = Off"
  fi
fi
info "These settings are a stopgap only. Patching is the fix."

# ---------------------------------------------------------------------------
if [ "$CHECK_CONTAINERS" -eq 1 ]; then
  hdr "Local Docker images"
  if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
    while read -r img; do
      v=$(docker run --rm --entrypoint php "$img" -r 'echo PHP_VERSION;' </dev/null 2>/dev/null)
      [ -n "$v" ] || continue
      found=1
      # Distro backports inside images are not checked here, so treat OLDER as a flag
      report_version "image $img" "$v" no
    done < <(docker images --format '{{.Repository}}:{{.Tag}}' | grep -v '<none>')
  else
    info "Docker not available, skipped"
  fi
fi

# ---------------------------------------------------------------------------
hdr "Result"
if [ "$found" -eq 0 ]; then
  say "No PHP runtime found on this host."
  exit 2
elif [ "$flagged" -eq 1 ]; then
  say "Action needed: see the [!] lines above."
  exit 1
else
  say "Nothing flagged. Still review logs from Oct 20 onward for signs of earlier compromise."
  exit 0
fi

A clean result means you're patched, not that you weren't hit. The next section covers that second question.

The forensics question: were we hit before we patched?

Patching closes the door. It doesn't tell you whether someone already walked through it. A few principles I'd hold the team to:

  • Preserve first, then patch. Restarting workers and redeploying wipes state. Grab web server logs, PHP error logs and config before you touch anything.
  • Start the clock on October 20. That's when details leaked, not when patches shipped. Your review window should cover everything since.
  • Look for the usual post exploitation signs. New or changed PHP files in web roots and temp directories, PHP worker processes spawning shells, new scheduled tasks for the web user, and unexpected outbound connections.
  • Watch for noisy crashes. These bugs live in out of memory and fatal error handling, so a spike in memory errors and worker crashes around that window is worth a closer look.
  • Purge sessions. Session data touched during the exposure window shouldn't be trusted.
  • Rotate secrets. This is the one people will skip. One of these bugs can leak server memory without ever running code. If a host sat unpatched after October 20, assume anything in memory (API keys, database credentials, tokens) may be out there.

Starter triage commands

Run these before patching or restarting anything, and keep the output with your case notes.

Preserve logs and config with hashes so they hold up later:

case_dir=/srv/ir/php2shell-$(hostname)-$(date -u +%Y%m%dT%H%MZ)
sudo mkdir -p "$case_dir"
# Only archive paths that exist on this host
paths=$(ls -d /var/log/apache2 /var/log/httpd /var/log/nginx /var/log/php* /etc/php /etc/php-fpm* /etc/php.ini 2>/dev/null)
sudo tar czf "$case_dir/evidence.tgz" $paths
sudo sha256sum "$case_dir/evidence.tgz" | sudo tee "$case_dir/SHA256SUMS"

Look for PHP files and override files created or changed since the leak:

sudo find /var/www /tmp /var/tmp /dev/shm -xdev -type f \
  \( -name '*.php*' -o -name '.htaccess' -o -name '.user.ini' \) \
  -newermt '2026-10-20 00:00:00' -ls 2>/dev/null

Count memory exhaustion errors with no script attached, plus worker crashes:

# Covers Debian/Ubuntu and RHEL default log locations, including rotated .gz files
logs="/var/log/php*.log* /var/log/php*/*.log* /var/log/apache2/error.log* /var/log/httpd/error_log* /var/log/nginx/error.log*"
sudo sh -c "zgrep -hE 'Allowed memory size .* in Unknown on line 0' $logs 2>/dev/null" | wc -l
sudo sh -c "zgrep -hE 'SIGSEGV|signal 11|zend_mm_heap corrupted' $logs 2>/dev/null" | tail -20

Flag any shell or download tool started directly by a PHP or web worker:

ps -eo pid=,ppid=,comm= | awk '
  {name[$1]=$3; parent[$1]=$2}
  END {
    for (p in name)
      if (name[p] ~ /^(sh|bash|dash|curl|wget|python3?|perl|nc)$/ &&
          name[parent[p]] ~ /^(php-fpm|php-cgi|apache2|httpd)/)
        print p, name[p], "<- parent", parent[p], name[parent[p]]
  }'

Check persistence the web user could have planted:

# The web user is www-data on Debian/Ubuntu and apache or nginx on RHEL
web_user=www-data
sudo crontab -l -u "$web_user" 2>/dev/null
sudo ls -la "$(getent passwd "$web_user" | cut -d: -f6)/.ssh" 2>/dev/null

These aren't vendor confirmed indicators. They're a reasonable first pass while the industry publishes proper Sigma and YARA rules.

That last point about secrets is the forensics lesson in this whole episode. "No webshell found" is not the same as "nothing was taken."

The bigger takeaway

For years, a lot of risk decisions quietly leaned on one assumption: this bug is real, but nobody will bother to weaponize it. Too hard, too fiddly, not worth the effort.

PHP2Shell is a clear sign that assumption is aging out. The flaw sat in PHP for over a decade. A skilled researcher plus a frontier model turned it into a working chain in days.

So here's what I'd change in how we run programs:

  • Revisit your "accepted risk" and "theoretical only" findings. Some of them aren't theoretical anymore.
  • Shrink the gap between disclosure and patch. Leaks will keep happening, and the time attackers need to catch up is falling fast.
  • Invest in knowing what you run. Inventory of runtimes, not just apps, was the thing that separated calm teams from panicked ones this week.
  • Plan for memory leaks and silent data exposure in your incident playbooks, not just code execution.

Defenders have the same models attackers do. The teams that use them to find and fix old bugs first will be the ones writing the calm postmortems next time.

Sources

  • Help Net Security: PHP2Shell patched
  • Imperva: When PHP runs out of memory
  • Cloudflare: WAF protections for php2shell
  • SecurityWeek: leaked critical PHP flaws
  • watchTowr: PHP2Shell FAQ
  • Tenable: PHP2Shell FAQ
  • Check Point: what we know
  • Brandefense: timeline
  • Dead Neurons: PHP2Shell explained
  • W3Techs: server side language usage
0 Comments



Leave a Reply.

    RSS Feed

    Subscribe to Newsletter

    Categories

    All
    AI
    CISO
    CISSP
    CKC
    Data Beach
    Incident Response
    LLM
    SOC
    Technology
    Threat Detection
    Threat Hunting
    Threat Modelling

  • Infosec
  • Mac Forensics
  • Windows Forensics
  • Linux Forensics
  • Memory Forensics
  • Incident Response
  • Blog
  • About Me
  • Infosec
  • Mac Forensics
  • Windows Forensics
  • Linux Forensics
  • Memory Forensics
  • Incident Response
  • Blog
  • About Me
Home·Blog·About·The Book·gouravnagar.com·LinkedIn·RSS
© 2026 Gourav Nagar · The DFIR Blog · Practical digital forensics and incident response since 2015