DEV Community

Cover image for PHP2Shell: When the Vulnerability Is in the Runtime, Not Just the Application
JacivaldoCarvalho
JacivaldoCarvalho

Posted on

PHP2Shell: When the Vulnerability Is in the Runtime, Not Just the Application

What two critical PHP vulnerabilities teach us about SBOMs, containers, DevSecOps, and automated security patching.

In application security, we often focus our efforts on source code analysis, dependency management, and API protection.

But what happens when the vulnerability exists in the runtime responsible for executing the application itself?

On October 21, 2026, the PHP project released emergency security updates addressing two critical vulnerabilities, identified as CVE-2026-109618 and CVE-2026-109619, collectively known as PHP2Shell.

Both received a CVSS v4.0 score of 9.2 and may allow unauthenticated remote code execution (RCE), depending on the conditions required for exploitation.

This incident highlights an important security challenge: an application can have secure code and still be vulnerable because of the infrastructure running it.

1. The Technical Problem: Vulnerabilities in the PHP Core

Unlike common vulnerabilities found in frameworks, libraries, or plugins, PHP2Shell involves internal mechanisms responsible for processing HTTP requests.

The two vulnerabilities have distinct characteristics:

CVE-2026-109618 — Memory corruption during allocation failure handling.

Under certain out-of-memory conditions, PHP may interrupt request processing without properly restoring its internal state. Subsequent cleanup operations may then access uninitialized memory structures.

CVE-2026-109619 — Reuse of invalid global state.

The runtime may retain references to memory regions associated with previous requests. When this state is not properly reinitialized, subsequent requests may access memory that has already been freed.

Potential consequences include remote code execution, sensitive information disclosure, and service disruption.

The risk is not limited to a specific application.

Environments using PHP-FPM, Apache with mod_php, php-cgi, FrankenPHP, or LiteSpeed may be exposed, depending on their versions and configurations.

This means that fixing application code alone does not eliminate the vulnerability.

2. Why Updating Dependencies Is Not Enough

Consider an API developed with Laravel and deployed inside a Docker container.

The development team uses static analysis, automated testing, dependency scanning, and CI/CD pipelines.

Even with these practices in place, the base container image may still contain a vulnerable PHP version.

The execution stack extends far beyond application code:

PHP / Laravel Application
        |
Composer Dependencies
        |
PHP Runtime
        |
System Libraries
        |
Container Base Image
        |
Operating System / Host
        |
Cloud Infrastructure
Enter fullscreen mode Exit fullscreen mode

A vulnerability in any of these layers can compromise the security of the service.

For this reason, security must cover the entire execution environment.

This is where Software Supply Chain Security becomes essential.

3. SBOM: Understanding Your Components Before Applying Fixes

A Software Bill of Materials (SBOM) is a structured inventory of the software components used in an application.

It can document packages, libraries, versions, and component identification information.

When a critical vulnerability is disclosed, the operational question is no longer simply:

"Which applications use PHP?"

Instead, it becomes:

"Which applications, containers, and servers are running vulnerable PHP versions, which are exposed to the internet, and which services depend on them?"

Tools such as Syft, Trivy, and Grype help automate this process.

A defensive example using Syft:

syft my-api:latest -o cyclonedx-json > sbom.json
Enter fullscreen mode Exit fullscreen mode

This command generates an inventory of the components identified in the container image.

Next, we can perform a vulnerability scan:

trivy image my-api:latest
Enter fullscreen mode Exit fullscreen mode

These checks help identify potentially affected components, but they do not replace validation against official vendor security advisories.

It is also important to remember that Linux distributions may apply security fixes through backporting, preserving version numbers that may still appear outdated.

Therefore, vulnerability assessments must consider both the origin of the packages and their actual patch status.

4. Containers Do Not Eliminate Runtime Vulnerabilities

A common misconception is that using Docker automatically makes an application secure.

Containers provide isolation mechanisms, but they do not fix vulnerabilities in the components running inside them.

If an image contains a vulnerable runtime, creating new containers from that image simply reproduces the problem.

Figure 1: Multiple containers created from the same vulnerable image inherit the affected PHP runtime. Container isolation does not fix vulnerabilities in the underlying software components.

Figure 1: Multiple containers created from the same vulnerable image inherit the affected PHP runtime. Container isolation does not fix vulnerabilities in the underlying software components.

For PHP2Shell, the PHP project released the following patched versions:

PHP Branch Patched Version
PHP 8.2 8.2.35
PHP 8.3 8.3.36
PHP 8.4 8.4.27
PHP 8.5 8.5.12

Older, unsupported versions require additional attention, migration, or security patches maintained by specific vendors.

One defensive approach is to update the base image to a patched runtime version:

FROM php:8.4.27-fpm

WORKDIR /var/www/html

COPY . .

CMD ["php-fpm"]
Enter fullscreen mode Exit fullscreen mode

This example illustrates a runtime update but is not intended to represent a complete production-ready Dockerfile.

After updating the runtime, the image must be rebuilt, tested, and deployed to replace existing containers.

A basic workflow could look like this:

docker build --pull --no-cache -t my-api:patched .
docker run --rm my-api:patched php -v
trivy image my-api:patched
Enter fullscreen mode Exit fullscreen mode

In production environments, verified images should be used, preferably pinned by digest. The exact artifact validated during testing should then be promoted to production.

In Kubernetes, the process also requires verifying that Pods are actually running the updated image.

Updating an image in the container registry without replacing running workloads does not guarantee that the vulnerability has been eliminated.

5. DevSecOps: Turning Security Patching into an Automated Process

Incidents such as PHP2Shell demonstrate that response speed is an essential part of operational security.

A DevSecOps strategy can organize the remediation process into a structured workflow:

Inventory → Detection → Prioritization → Remediation → Validation → Monitoring

Within a CI/CD pipeline, these activities can be automated.

For example:

Git Repository
      |
CI Pipeline
      |
Container Image Build
      |
SBOM Generation
      |
Vulnerability Scanning
      |
Automated Testing
      |
Security Policies
      |
Container Registry
      |
Controlled Deployment
      |
Observability
Enter fullscreen mode Exit fullscreen mode

A security policy may prevent images containing known critical vulnerabilities from being promoted, while considering exposure criteria, approved exceptions, and patch availability.

Automation can also create dependency update requests and execute regression tests.

However, automated remediation should not mean uncontrolled deployment.

Runtime updates may introduce compatibility issues.

For this reason, security pipelines should include functional validation, health checks, progressive deployments, and rollback strategies.

The goal is to reduce the exposure window without compromising service availability.

6. A WAF Is a Protection Layer, Not a Permanent Fix

During the PHP2Shell disclosure, vendors such as Cloudflare and AWS published guidance and protective measures to reduce exposure to exploitation attempts.

These measures are particularly valuable when updating every affected system requires additional time.

However, the PHP project made it clear that no complete mitigation can replace patching the vulnerable runtime.

This distinction is essential:

  • Web Application Firewall (WAF): Helps block potentially malicious traffic patterns.
  • Security patching: Fixes the vulnerability in the affected component.
  • Observability: Enables monitoring of exploitation attempts, errors, and abnormal behavior.
  • Incident response: Establishes procedures when there are indications of compromise.

These controls complement one another.

None should be treated as a universal replacement for the others.

Security should be part of the development process from the very first git init.

Security should not begin when a vulnerability is discovered or when an application reaches production. It must be considered from the earliest stages of development, integrated into architecture decisions, dependency management, CI/CD pipelines, infrastructure provisioning, and runtime maintenance.

This is the foundation of Security by Design and the DevSecOps mindset: security is not a final checkpoint, but a continuous responsibility throughout the entire software lifecycle.

Because security should start with git init, not with a critical CVE.

7. The Role of DevOps and SRE During a Critical Vulnerability

For DevOps and Site Reliability Engineering (SRE) teams, the challenge does not end when the security team identifies a vulnerability.

Teams must determine which services are affected, assess the potential impact, and apply fixes safely.

A structured response may include:

Identification: Locate servers, containers, and images running affected versions.

Prioritization: Evaluate internet exposure, service criticality, and potential exploitation paths.

Containment: Apply temporary network and WAF controls when appropriate.

Remediation: Update packages and images, rebuild artifacts, and replace affected workloads.

Validation: Run tests, verify runtime versions, and monitor operational indicators.

Investigation: Analyze logs, events, and evidence of potential compromise. Applying a patch removes the known vulnerability, but it does not automatically resolve the consequences of a previous intrusion.

From an SRE perspective, the response must balance security and reliability.

Metrics such as time to identification, time to remediation, inventory coverage, and deployment success rate help assess operational maturity.

It is also important to establish emergency patching procedures that do not depend exclusively on regular maintenance windows.

8. Automated Patching: Moving from Reaction to Prevention

The most important lesson from PHP2Shell goes beyond the two vulnerabilities themselves.

It highlights the need to transform security into a continuous operational capability.

A mature organization should be able to answer questions such as:

  • Which vulnerable components are currently running in production?
  • Which container images and services depend on those components?
  • Is a patched version available?
  • Which workloads need to be rebuilt?
  • How can the fix be validated without causing downtime?
  • How can we demonstrate that every affected environment has been updated?

Combining asset inventories, SBOMs, vulnerability scanners, CI/CD pipelines, security policies, and observability makes it possible to build this capability.

AI-powered tools can also assist with vulnerability classification and the preparation of remediation changes.

However, decisions with operational impact must follow authorization policies, testing requirements, and audit mechanisms.

Automation should strengthen response capabilities, not eliminate the controls required to operate critical systems safely.

Conclusion

PHP2Shell demonstrates how vulnerabilities in foundational software components can affect applications regardless of the quality of their source code.

For DevOps and SRE professionals, this incident reinforces five key principles:

  1. Application security also means runtime security.
  2. Containers must be continuously updated and verified.
  3. SBOMs and asset inventories are essential for identifying exposure.
  4. DevSecOps pipelines should incorporate vulnerability detection and remediation.
  5. Observability and automation must be part of the operational security response.

The challenge is not simply discovering a vulnerability. It is knowing where it exists, understanding its impact, and being able to fix it quickly, verifiably, and safely.

This is one of the fundamental challenges of applying Site Reliability Engineering principles to modern cybersecurity.


Technical References

Top comments (0)