Insights · Security Architecture

Hardening against the next PHP2Shell: Kubernetes, containers, lateral movement and shift left security

KubernetesRKE2CIS

Key takeaway

Rebuild images instead of patching live, run containers without root, harden Kubernetes, deny lateral movement, gate the pipeline.

October 2026 gave defenders a gift. Every big incident maps to a control most organizations know they should have. Here they are, in priority order, kept simple.

1. Patch runtimes by rebuilding, not editing

PHP2Shell and Node2Shell both live in runtimes. Both had working exploits within days. Three moves:

  • Know your versions. Run php -v and node -v on every host and container. Generate an SBOM in your pipeline. The next Brotli bug then becomes a database query, not a fire drill.
  • Rebuild images instead of patching live containers. Fixes made inside a running container disappear on the next deploy. Pin base images by digest, rebuild them when they update, and redeploy.
  • Measure patch time. Log4j studies show exploitation continuing for years after disclosure. Set a patch deadline of days for critical CVEs, and track your real number.

2. Run containers without root

NIST SP 800-190 is clear: containers should run with least privilege. When a flaw like PHP2Shell lands, a process running as a normal user with no extra powers turns a catastrophe into an incident.

Make the image use a normal user:

FROM php:8.3-fpm-alpine
RUN addgroup -g 10001 app && adduser -u 10001 -G app -D app
USER 10001
COPY --chown=10001:10001 . /var/www/html

Enforce it in Kubernetes:

securityContext:
  runAsNonRoot: true
  runAsUser: 10001
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities: { drop: ["ALL"] }
  seccompProfile: { type: RuntimeDefault }

Enforce this with Pod Security Admission or policy as code, so privileged pods fail at the door. Practical details are in the OWASP Docker Cheat Sheet.

3. Choose hardened enterprise Kubernetes

Do not run vanilla upstream Kubernetes in production and harden it by hand. Choose an enterprise Kubernetes platform whose defaults already meet the controls auditors test, and keep them on. Look for:

  • CIS Benchmark conformance out of the box. Restricted pod security, API server hardening, and host controls should be configuration, not a project. Verify against the CIS Benchmarks. Controls you have not tested are controls you do not have.
  • FIPS mode cryptography for regulated environments.
  • A hardened supply chain. Signed artifacts released through a secured pipeline.
  • Defaults that resist drift. Hardened settings should stay on because they are the easy path, not a one time project.
  • Upstream conformance so your workloads stay portable.

Then run it as designed: restricted Pod Security Admission, secrets encryption at rest, audit logging, and default deny network policies. One note: most Kubernetes deployments do not enable seccomp profiles by default. Set seccompProfile: RuntimeDefault on purpose, per workload or across the cluster. The full control list is in the NSA and CISA Kubernetes Hardening Guidance.

4. Expect attackers to move sideways, and make it hard for them

Attackers rarely stop at the first machine. MITRE ATT&CK gives lateral movement its own tactic (TA0008) for a reason. The unpatched Tailscale SSH disclosure showed the pattern: one hacked device reaching root on nearby servers. Until a fix ships, the mitigations are architectural, and they are good practice anyway:

  • Default deny network policies, with explicit egress rules.
  • No standing SSH. Use short lived, certificate based access only.
  • Separate management planes. Keep VPNs, CI runners, and admin machines in separate trust domains.

CISA’s “Tale of Two SOCs” advisory is a free masterclass in which attacker behaviors real security teams catch, and which they miss.

5. Move security left, into the pipeline

NIST’s Secure Software Development Framework sets the standard, and peer reviewed studies (for example Feio et al., IEEE 2024) confirm security automation works when it lives inside CI. Five gates cover October’s incidents:

  • SBOM and dependency scanning: would have caught Brotli inside Node.js and Python images.
  • Base image scanning and auto rebuild: would have caught vulnerable PHP images.
  • Secrets scanning: would have caught OAuth token theft like the Salesloft Drift attack.
  • IaC policy and admission control: would have caught privileged pods and flat networks.
  • DAST before release: would have caught injection flaws.

6. Mind your certificates

The eMudhra compromise was contained because monitoring and revocation already existed. Your part is short. Keep a certificate inventory. Watch Certificate Transparency logs for your domains. Rehearse a fast certificate authority switch and reissue.

The checklist

  1. SBOM generated in CI. Runtime versions inventoried.
  2. Images rebuilt when base images update. Never patched in place.
  3. Everything runs without root, with a read only filesystem and no extra capabilities. Enforced at admission.
  4. Hardened Kubernetes: restricted pods, encrypted etcd, audit logging, default deny networks.
  5. No standing SSH anywhere. Short lived access only.
  6. Security gates in CI: SCA, secrets, IaC, DAST.
  7. Certificates inventoried. CT logs monitored. Reissue rehearsed.

Simple, testable, and it maps one to one with what actually hit in October. If you would like a partner to assess your estate against this baseline and close the gaps with you, that is a conversation worth having.

Explore our solutions

Sources