跳到正文
DEV Community· errorbudget·· 51 分鐘前AI 評分64

AI 協助發現 PHP 與 Java 執行環境漏洞後的 48 小時修補計劃

When AI finds the bug in your runtime: a 48-hour plan to patch every PHP and Java you run

AI 導讀

指南提出一套在安全通告發布後 48 小時內處理 PHP 與 Java 執行環境漏洞的應對計劃。流程包括盤點主機、應用程式內嵌環境、容器映像、廠商設備及建置工具,按暴露程度分環修補,並確認程序已重啟及載入修補後的程式碼;未能即時修補時則採取緩解措施並排查入侵跡象。

正文

Most vulnerabilities live in one product. You find the product, you patch it, you move on. A bug in a language runtime is different. When the flaw sits in PHP itself or in the Java virtual machine, every application on top of it is exposed at the same time: the CMS, the ticketing system, the CI server, the identity provider, and the vendor appliance nobody has logged into for a year.

Two recent bugs made this concrete. PHP2Shell (CVE-2026-109618 and CVE-2026-109619) gave remote code execution in PHP's engine, before any application code ran on Apache mod_php. Java4Shell (CVE-2026-114938) let crafted Base64 input corrupt memory in OpenJDK, with demonstrated code execution against Jenkins, Jira, Confluence and Keycloak. Both were found with AI assistance. Both arrived with patch windows measured in days, not weeks.

This is a plan for the next one. It is written from the operator's side: what to do in the 48 hours after a runtime advisory lands, and what to set up now so those 48 hours are boring.

What changed

Three things came together in these two disclosures, and none of them is going away.

Bugs that were hiding in plain sight. The Java4Shell crash was reported publicly in June 2026, and a fix was proposed in OpenJDK in September but never merged. The root cause behind PHP2Shell traces back to a 2020 bug report and a 2024 security audit, where exploitation was suspected but not proven. In both cases, the fix shipped only after someone showed working exploitation.

AI turns a crash into an exploit fast. The researcher behind Java4Shell says the AI assistant found the bug in about an hour. A first working exploit took two more hours, at an AI cost under $200. Later attack chains for other applications were built "almost autonomously". The same capability is available to attackers.

Disclosure no longer holds until patch day. PHP2Shell's CVE IDs leaked two days before the planned release, a demo video escaped, and one distributor published fixed builds six hours before the coordinated release. Exploitation attempts began about four days before the patches. Five days after release, CISA added both CVEs to its Known Exploited Vulnerabilities catalog. Three days later it warned that attackers were chaining them with a Linux kernel bug to get root.

The practical result: for a runtime bug with a public write-up, assume you have one to three days before automated exploitation reaches your edge. Your process has to fit inside that.

Step 1: find every runtime, not just the ones in your CMDB

The hard part is rarely the patch. It is knowing where the runtime is. CISA's Java4Shell alert said it directly: Java runtimes are often bundled with third-party applications, container images and appliances, and may not appear as separate entries in a software inventory.

Look in five places.

Where runtimes hide Example How to find them
OS packages openjdk-17-jre, php8.3-fpm Your package manager or patch tool
Bundled with an application The JRE inside Jira, Confluence, Elasticsearch or a monitoring agent Search the filesystem for the runtime library
Container images eclipse-temurin:21-jre, php:8.4-apache base layers SBOM or image scanner across the registry and running pods
Vendor appliances Load balancers, backup consoles, identity appliances Vendor advisories; ask the vendor
Build and dev tooling CI runners, build agents, developer base images The same scans, pointed at CI images and runner hosts

On Linux hosts, search for the runtime itself rather than trusting package lists. This finds bundled JVMs that no package manager knows about:

# Every JVM on the host, bundled or not, with its version
find / -xdev -name libjvm.so 2>/dev/null | while read -r lib; do
  home=${lib%/lib/*}; echo "$home: $("$home/bin/java" -version 2>&1 | head -1)"
done

# Every PHP binary, FPM daemon and Apache module
find / -xdev -type f \( -name php -o -name 'php[0-9]*' -o -name 'php-fpm*' -o -name 'libphp*.so' \) 2>/dev/null

For containers, scan the images you actually run, not only the ones in the registry. List the running images in Kubernetes, then generate an SBOM or run a scanner against each:

kubectl get pods -A -o jsonpath='{range .items[*]}{range .spec.containers[*]}{.image}{"\n"}{end}{end}' | sort -u
syft <image> -o table | grep -Ei 'openjdk|jre|jdk|php'   # or: trivy image <image>

Write the result down in one place, with an owner per row. You will reuse it for the next runtime bug, and the one after.

Step 2: rank by exposure, using the advisory's conditions

Runtime advisories usually come with conditions. Use them to sort the list, not to dismiss it.

  • Internet-facing and unauthenticated input first. Java4Shell needs attacker-controlled Base64 to reach the decoder. Login forms, token parsing, file uploads and API gateways are exactly where that happens. PHP2Shell's worst path needs only an unauthenticated request to a mod_php site.
  • Check the deployment detail that changes the risk. For PHP2Shell, mod_php was exploitable before application code ran, while PHP-FPM needed an application code path. For Java4Shell, only x86-64 hosts with AVX-512 VBMI were exposed; ARM hosts were not.
  • Do not let a condition become an excuse. "We run PHP-FPM" lowered the risk for PHP2Shell; it did not remove it. Hardware changes when a VM migrates or a node pool is upgraded. Treat conditions as an ordering tool.

Step 3: patch in rings, with a clock

A clock keeps the work honest. One that has worked for runtime bugs:

Ring What is in it Target
0 Internet-facing services that take unauthenticated input Patched or mitigated within 24 hours
1 Other internet-facing services, VPN-reachable admin tools, CI runners 48 hours
2 Internal services 7 days
3 Appliances waiting on a vendor fix Mitigate now; patch on vendor release

Three things make the rings move faster.

Patch the base images first. If your containers inherit from a small set of base images, rebuilding those images patches most of the fleet in one move. Keep that set small for exactly this reason.

Pre-approve the change. Regulated environments need change control. Agree in advance that a runtime fix with a vendor advisory and active exploitation is a pre-approved emergency change, with the review done after the fact. Agreeing that during the incident costs a day you do not have.

Separate "update" from "restart". The package manager installs the fix; it does not replace the code in running processes. That is the next step.

Step 4: prove the old code is gone

A patched package with an unrestarted process is a common false sense of safety. The JVM or PHP worker keeps the old library mapped in memory until it restarts.

On hosts, check for processes still using a deleted (replaced) runtime library:

grep -lE '(libjvm|libphp|php-fpm).*\(deleted\)' /proc/[0-9]*/maps 2>/dev/null \
  | cut -d/ -f3 | xargs -r ps -o pid,lstart,cmd -p

Any process listed is still running old code. On Debian and Ubuntu, needrestart -b lists services that need a restart after an update. For JVMs, comparing each process start time with the package install time gives the same answer.

For containers, the check is the image digest. A rebuilt image tag means nothing until the pods are running the new digest:

kubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{"\t"}{.status.containerStatuses[*].imageID}{"\n"}{end}'

Then confirm the version from inside the service: java -version from the service's own runtime path, or the PHP version reported by the running SAPI rather than the command-line binary. They can differ.

Step 5: use mitigations as a bridge, not a destination

When a ring cannot meet its clock, a documented mitigation buys time. Both recent bugs had one.

  • Java4Shell: start the JVM with -XX:-UseBASE64Intrinsics to turn off the vulnerable decoder. Or use -XX:UseAVX=2 on x86-64 only, since JVMs on ARM fail to start with it.
  • PHP2Shell: the researchers suggested memory_limit=-1, plus session.upload_progress.enabled=0 for PHP-FPM. That removes PHP's memory cap, so pair it with operating-system or container memory limits.

Record every mitigation with an expiry date and an owner. Mitigations that outlive the incident become the next audit finding, and sometimes the next outage.

Step 6: hunt, because you may have been late

If a service was internet-facing and unpatched while exploitation was active, patching ends the exposure. It does not undo a compromise. PHP2Shell exploitation started before the fix existed, so "we patched on day one" is not proof of anything.

Hunt on every ring 0 and ring 1 system:

  • Crashes before the patch. Failed exploitation often crashes the worker. Look for JVM hs_err_pid files and worker segmentation faults in Apache or PHP-FPM logs.
  • Unexpected child processes. Shells or download tools started by a JVM or PHP worker.
  • New files in web roots, upload folders and temp directories, and new accounts, keys or tokens in the affected applications.
  • Signs of the next step. In the PHP2Shell attacks, that meant a root-level kernel exploit. Check for root processes whose parent is a web user.

Our guide to webshell detection in Java and PHP estates covers the signals and the first hour of response in detail. The fix guides for PHP2Shell and Java4Shell have the version and mitigation specifics.

Set it up before the next one

The 48 hours go well when the work is done in advance:

  1. A standing runtime inventory. Use the five places above, refreshed weekly, with an owner per row.
  2. A small set of base images, rebuilt automatically when the upstream runtime publishes a security release.
  3. A pre-approved emergency change for exploited runtime vulnerabilities.
  4. A restart check that runs after every patch and fails loudly if an old library is still mapped.
  5. A fast signal. Watch the CISA KEV catalog and runtime security announcements. We publish fix guides for exploited infrastructure bugs, with an RSS feed, for the same reason.

The volume of findings is not slowing down. The PHP security team says it has published 15 CVEs since 1 July and worked through more than 100 invalid, duplicate or unreproducible reports, much of it driven by AI-assisted research. Expect more runtime-level bugs, found faster, with less warning. The teams that cope will be the ones that already know where every runtime lives.

Sources


Originally published on errorbudget.io, where we also publish fix guides for actively exploited vulnerabilities.

來源:DEV Community · dev.to