What is Defense in Depth?

Defense in depth stacks independent security controls, so that when one control fails, the next one stops the attacker at the next step.

An attacker uses a zero-day to run code in a web app. A minimal image, no stored key, an egress allowlist, and a rebuild each stop one next step, which limits what the flaw can reach.

Every layer of a system has flaws that nobody has found yet. Defense in depth accepts that fact. It stacks independent controls, so that an attacker who exploits one layer meets another control. For each control, it asks one question: when this control fails, what stops the next step?

The idea is old, but the pace around it is new. AI tools now find flaws faster, and AI agents chain them faster. In November 2026, the FBI reported intrusions by AI agents that reached privileged access in under three hours. This page covers the controls that contain a breach, from patching and minimal images to isolation, rebuilds, egress limits, and detection.

Why does a single layer fail?

A layer fails in one of three ways: a flaw in its code, a mistake in its settings, or a credential that an attacker stole. No patch process closes a flaw before anyone knows about it. Railway and Northflank both disclosed intrusions in October 2026 that began with a previously unknown flaw.

Known flaws arrive in clusters. Between November 11 and November 19, 2026, researchers disclosed critical flaws across the whole web stack. The Linux kernel had its own flaws in the weeks and months before:

LayerFlawWhat an attacker getsFix, and the step until you can patch
Linux kernelCVE-2026-98432, an IPv4 TCP use-after-free since Linux 4.4Remote root, with no loginA vendor kernel and a reboot; until then, an nftables rule that drops IPv4 TCP packets with IP options
Linux kernelSCTPhantom (CVE-2026-64564), an SCTP use-after-free from about 2008Local root and container escape under the default seccomp profileKernels fixed since August; block the sctp module on hosts that do not use it
Apache httpdCVE-2026-119618, a race in mod_http2Unauthenticated code executionApache 2.4.71
nginxCVE-2026-123633 and CVE-2026-123007, two HTTP/2 flawsUnauthenticated code executionnginx 1.30.7 or 1.31.9; until then, turn off HTTP/2
PHPphpAfterShell (CVE-2026-126714), in the session file handlerCode execution, with a gadget chain in the applicationThe fixed PHP releases; until then, set session.upload_progress.enabled = 0
RubyRuby2Shell (CVE-2026-132825), a one-byte heap overflow in string case conversionPre-authentication code execution in default Rails and Sinatra apps (disputed)Ruby 3.3.14, 3.4.13, or 4.0.10
GhostscriptUpload2Shell (CVE-2026-125396), a use-after-free in the Type 1 font loaderCode execution from an uploaded file in WordPress, MediaWiki, and others (rated local, which the finders dispute)Ghostscript 10.08.0, including copies inside container images

AI found or exploited several of them. "The flaws were already there; AI helped us find them," Wiz wrote about the two nginx flaws that its AI harness found. Anthropic reported that an internal Claude research model wrote a remote root exploit for the kernel TCP flaw. At pwn.ai, a GPT model working with a researcher found the Ghostscript flaw. Attackers use the same tools, and a flaw that an attacker finds first is a zero-day.

So each control must assume that the control in front of it has failed. The rest of this page covers the controls in the order an attacker meets them.

How does defense in depth work?

Each control removes one step that an attacker needs. A useful stack has these controls:

  1. Reduce what an attacker can reach.
  2. Patch what runs, on a deadline.
  3. Ship images that hold only what runs.
  4. Isolate code that you cannot trust.
  5. Keep environments apart.
  6. Rebuild hosts instead of hunting for implants.
  7. Limit what leaves the network.
  8. Detect what gets through.

The controls must fail independently. Two controls that trust the same credential, the same kernel, or the same network count as one control, not two.

Reduce what an attacker can reach

Every system you keep is one an attacker can find. The FBI's first recommendation in its ARTEX advisory is an inventory of every internet-facing application. Its list includes "partner and supplier portals, mobile backends, employee applications, sales-support systems, legacy services, third-party integrations" as examples. The FBI calls such apps "peripheral systems receiving less security attention than flagship applications."

Make the inventory, then shrink it:

  • Delete old deployments. When a service moves, delete the old deployment instead of leaving it idle.
  • Check preview defaults. Some platforms publish branch previews on a public URL by default. Cloudflare Workers Builds, for example, publishes them on a workers.dev URL unless you turn that off.
  • Read the defaults of what you install. Some Helm charts and operators open an external listener with no authentication. Test from outside your network what actually answers.
  • Delete dangling DNS records. A record that points at a deleted cloud resource lets an attacker claim the resource and serve content as your subdomain.
  • Lock down your domains and mail. Add CAA records, so that only your certificate authorities can issue certificates for your domains. Watch Certificate Transparency logs for certificates you did not request. Publish DMARC with p=reject, backed by SPF and DKIM, and turn on registrar lock.

Admin paths need their own controls, such as an identity-aware proxy and just-in-time roles. Privileged access management covers them.

Patch on a deadline, and patch what actually runs

A fix protects nobody until it is deployed. Set patch deadlines by risk, not by maintenance window:

  • Days for what is exploited or exposed. CISA's Known Exploited Vulnerabilities catalog lists flaws that attackers already use. On November 20, 2026, CISA gave federal agencies three days to fix two new entries. Give every KEV entry and every critical flaw that the internet can reach a fix or an interim step within days. Give everything else weeks, not a quarter.
  • Automate the routine. Use Dependabot security updates or Renovate for dependencies. Use unattended-upgrades or dnf-automatic on hosts that you cannot rebuild yet. In clusters, use rolling node image updates, such as EKS managed node group updates or the Bottlerocket update operator.
  • Patch the image and the runtime, not only the host. Ruby2Shell lives in the Ruby interpreter, so bundle update does not fix it. A scan that reads only Gemfile.lock misses it. A host update "does not update a separate copy of Ghostscript inside an existing container image or application bundle," the Upload2Shell finders note.
  • Scan what you deploy. Scan the images in your registry and your clusters with a tool such as Trivy or Grype. Scan against a software bill of materials (SBOM) for each image. A repository scan misses what the base image brought along.
  • Give every third-party component an owner. An ingress controller, an operator, or a VPN gateway is internet-facing code that nobody upgrades unless someone owns it.
  • Turn off what you do not use. Most interim steps in the table above turn off a feature, such as HTTP/2 or the SCTP module. They buy days, not months.

Ship images that hold only what runs

A code execution bug needs tools for its next step: a shell, a package manager, or curl. An image that holds only the application gives it none of them. It also gives a scanner far fewer packages to flag. The smallest image starts FROM scratch and copies in only the binary and its certificates. A Dockerfile for a Go service looks like this:

FROM golang:1.26@sha256:<digest> AS build
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -trimpath -o /out/server ./cmd/server

FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /out/server /server
USER 65534:65534
ENTRYPOINT ["/server"]

UID 65534 is the nobody user, so the process runs without root. Pin every base image by digest, and rebuild on a schedule so that the copied certificates stay current.

Where FROM scratch is too bare, start from a hardened minimal base:

Then enforce the same limits in Kubernetes. Apply the restricted Pod Security Standard to each namespace with the label pod-security.kubernetes.io/enforce: restricted. Set a security context on each container:

securityContext:
  runAsNonRoot: true
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ['ALL']
  seccompProfile:
    type: RuntimeDefault

A read-only root filesystem needs an emptyDir volume for each path that the application writes.

Put untrusted code in a microVM, not a container

Containers share the host kernel. A container escape is one step from the node, and from everything that the node's identity can reach. The kernel flaws in the table show both ways out. CVE-2026-98432 is a remote root exploit in the host's TCP stack, which takes every container on that host at once. SCTPhantom escaped containers in six of eight tests under the default seccomp profile, with no added capabilities.

Animation: three containers share one host kernel, so an exploit from untrusted code in container A reaches the other containers and the node identity. In three microVMs, each workload runs on its own guest kernel. The same exploit lands in the guest kernel of microVM A. It stops at the VM boundary, so the other microVMs and the host are untouched.CONTAINERSTHE OLD WAYCONTAINER ACONTAINER BCONTAINER CWORKLOADUNTRUSTEDWORKLOADREACHEDWORKLOADREACHEDHOST KERNELEXPLOITEDNODE IDENTITYREACHEDMICROVMSKERNEL PER VMMICROVM AMICROVM BMICROVM CWORKLOADUNTRUSTEDWORKLOADNEIGHBORWORKLOADNEIGHBORGUEST KERNELEXPLOITEDGUEST KERNELGUEST KERNELHOST KERNELNODE IDENTITYCREDENTIALSVM BOUNDARYKERNEL EXPLOIT · CONTAINER VS MICROVMILLUSTRATIVE · HOST STILL NEEDS PATCHES

A microVM runs its own kernel and network stack. An exploit that a workload's own code or traffic triggers lands in one sandbox, not on the host. The host still needs its kernel patches and a closed network, because traffic that reaches the host's own TCP stack can still exploit it. Code that you did not write and cannot review belongs behind a VM boundary. Examples are an AI agent that runs generated code, a CI build of an outside pull request, and a customer workload.

On AWS, Nitro Sandboxes run each workload in a lightweight child VM with its own kernel. On EKS, a pod opts in with runtimeClassName: confidential-sandbox, as the EKS sandboxing guide describes. Read the limits first. The parent can read the block devices it presents. A sandbox whose traffic the parent routes can reach the parent's instance metadata service.

A confidential VM protects data from the operator and the host. It does not protect against a flaw in the code inside it. NEAR AI reported that an attacker used a remote code execution flaw in SGLang to run code on one of its confidential inference servers. Confidential computing "does not protect against a vulnerability in the software running inside the environment," in NEAR AI's words. Patch the code inside a trusted execution environment as closely as any internet-facing server.

On a laptop, the same rule applies to coding agents and browser automation. OrbStack machines share one lightweight VM, and by default they can read your Mac's home directory. An OrbStack isolated machine turns those integrations off, and you mount back only the project that the agent needs. For example:

orb create --isolated --isolate-network --mount ~/src/my-project ubuntu agent-sandbox

OrbStack's documentation says that isolated machines are not a full security boundary against a kernel exploit. Put anything hostile, such as malware or an attack tool you have not reviewed, in a full VM or a cloud sandbox.

Your own AI agents need the same limits. A prompt injection in a web page, a ticket, or a tool result can steer an agent that holds real permissions. OWASP ranks prompt injection first in its Top 10 for LLM applications. Give each agent scoped, read-only data. Require a person to approve writes and outbound messages, and keep the agent's egress on an allowlist.

Treat every environment like production

Attackers do not read environment names. A development environment holds real credentials, CI tokens, copies of data, and network paths to production. It also gets less attention. Fireworks AI disclosed that its second intruder used development machines at a breached cloud provider to reach part of its production systems.

  • Use the same controls everywhere. MFA, just-in-time access, secret scanning, workload identity, and rebuilds apply to development as much as to production.
  • Give each environment its own accounts and keys. A development credential then cannot act as production.
  • Leave no trust path from development to production. Share no roles, credentials, or network routes. Copy production data into development only after you mask it.

Raze and rebuild

Persistence turns a short intrusion into a long one. The FBI lists what ARTEX agents leave behind: web shells, open-source remote access tools, new SSH key pairs, and credentials added to existing OAuth applications. A hunt removes only the artifacts that someone finds. Destroying the host and rebuilding it from code removes every artifact on the host at once, including the ones nobody found.

Make every service rebuildable from declarative code, and keep critical state outside the thing you rebuild. Then rebuild on a schedule:

  • Rebuild development every week. Erase the cluster, reinstall its nodes, redeploy its services with new credentials, and check that everything works.
  • Rebuild production into capacity that serves no traffic, and have a person approve the cutover.
  • Put every security control in the rebuild code, including the host firewall, the audit log, and the network policies. Check from outside the network that each rebuilt host exposes only what it should.

A rebuild also patches the kernel. A host rebuilt every week from a current image boots the fixed kernel within a week.

A rebuild has a limit. It removes what lives on hosts, not what lives in identity systems. An OAuth application credential, a new IAM user, or a consent grant survives any number of rebuilds. Audit them separately, as the FBI asks: review credential additions, app role assignments, and consent grants.

Limit what leaves

The FBI's behavioral indicators for ARTEX include calls to LLM APIs, such as api.anthropic.com or api.deepseek.com, from systems with no reason to make them. They also include high-frequency sequential requests against sign-in and search endpoints. Three controls follow:

  • An egress allowlist on servers. An implant then cannot reach its model or its drop site.
  • Rate limits and record caps on every API that returns customer records, with an alert on sequential lookups. In Kubernetes, Envoy's rate limit filters can enforce the limits at the gateway.
  • Error responses without internals. Never return stack traces, SQL errors, or internal paths to an unauthenticated caller.

In Kubernetes, start from a NetworkPolicy that denies all egress for a namespace:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-egress
spec:
  podSelector: {}
  policyTypes:
    - Egress

Then allow DNS and each destination that the workload needs. Cilium's DNS-based policies and security groups for pods on Amazon EKS can allow destinations by name or group. An Envoy-based egress gateway, such as the Istio egress gateway, can allow outbound HTTPS by hostname and log every connection.

Detect what gets through

Plant canary credentials. An agent tries every credential it finds. A fake cloud key in a config file, or a fake database password in a wiki, sends an alert on its first use. Thinkst Canarytokens makes them at no cost. In clusters, eBPF tools such as Falco and Tetragon alert when a container starts a shell or connects somewhere new. In a FROM scratch image, any shell at all is an alert.

Turn on audit logs before you need them, because you can scope an incident only from logs that existed when it began. Log reads of secrets and credential stores, not only writes. If your logs cannot rule out access to a credential store, you must rotate every credential in that store. In Kubernetes, the API audit log is off unless you configure it. GitHub keeps clone events for only 7 days unless you stream its audit log.

How does defense in depth compare with perimeter security?

AreaPerimeter securityDefense in depth
AssumptionThe inside is trustedEvery control can fail
A flaw in the appThe attacker is inside, with the app's accessThe attacker meets a minimal image, an isolation boundary, and an egress allowlist
CredentialsLong-lived, shared inside the networkShort-lived, scoped to one workload
PersistenceFound by a hunt, if at allRemoved by a scheduled rebuild
DetectionAlerts on the perimeterCanaries, runtime alerts, and audit logs on every layer

A perimeter is still a control. The firewall, the proxy, and the private network stay. Defense in depth adds the controls behind them.

Advanced Topics

Remove the bug class, not only the bug

Several flaws in the table are memory-safety bugs: use-after-free flaws in the Linux kernel and Ghostscript, and a heap overflow in the Ruby interpreter. CISA, the NSA, the FBI, and their partners ask software makers to publish memory-safe roadmaps. The guidance cites Google Project Zero's finding that 67% of the zero-days it tracked in 2021 were memory-safety bugs. Write new services in a memory-safe language, such as Rust, Go, or Java. Where you cannot rewrite, fuzz every parser that reads untrusted input, with cargo-fuzz, libFuzzer, or OSS-Fuzz for open-source projects.

Find controls that share a failure mode

List what each control trusts: a credential, a kernel, a network, an identity provider. Two controls that trust the same thing fail together. Containers on one host share a kernel. Services in one cloud account can share a role. Admin tools behind one proxy can share one header. For each shared dependency, add a control that does not trust it, or accept the risk in writing.

Test the controls like an attacker

A control that nobody has tested is an assumption. Point an agentic penetration test at a rebuilt copy of the environment, with a scope that assumes one control has already failed. For example, start the agent inside a web container, and record which control stops it. Then give the outside pentest team the same starting point.

Defense in Depth with Spice

The Spice runtime ships as a minimal image. It builds FROM scratch, holds only the spiced binary and the files it needs, and runs as nobody. It has no shell and no package manager. The CUDA images run on NVIDIA's CUDA runtime base instead. The runtime is written in Rust, but it also loads C and C++ libraries such as DuckDB. So give its process the same isolation as any other.

A self-hosted runtime should encrypt and authenticate its endpoints. This Spicepod turns on TLS and API keys, and it loads the key from a secret store:

version: v1
kind: Spicepod
name: secure-runtime

secrets:
  - from: aws_secrets_manager:spice-runtime
    name: aws

runtime:
  tls:
    enabled: true
    certificate_file: /etc/spice/tls/tls.crt
    key_file: /etc/spice/tls/tls.key
  auth:
    api_key:
      enabled: true
      keys:
        - ${ secrets:api_key }

Data that you no longer hold cannot leak. A retention policy expires the local copy of an accelerated dataset on a schedule. The accelerated dataset retention policy recipe runs a worker that inserts rows into a dataset, and shows the policy evict the old ones.

For AI agents, secure AI sandboxing gives each agent temporary, scoped datasets instead of production databases. Isolated agent data stacks give each customer's agent its own Spice runtime. That runtime holds only one customer's datasets and credentials.

Defense in Depth FAQ

Defense in depth is a security design that stacks independent controls. When one control fails, the next one stops the attacker at the next step. Examples are patching, minimal images, isolation, rebuilds, egress limits, and detection.

Not a strong one. Containers share the host kernel, so a kernel flaw or a container escape reaches the host. Run code that you cannot trust, such as agent-generated code, in a microVM with its own kernel.

Fix a known exploited vulnerability, or a critical flaw that the internet can reach, within days. In November 2026, CISA gave federal agencies three days for two new entries in its catalog. Fix other flaws within weeks.

A cleanup removes only the artifacts that someone finds. A rebuild from code removes every artifact on the host, found or not. It also boots the current kernel and issues new credentials.

A canary credential is a fake key or password that you plant where an attacker would look. Nobody has a reason to use it. So its first use sends an alert that is rarely a false alarm.

See Spice in action

Get a guided walkthrough of how development teams use Spice to query, accelerate, and integrate AI for mission-critical workloads.

Get a demo (opens in a new tab)