Pod HTTP modify header
Override HTTP request or response headers served by a target Kubernetes pod to test client and server resilience to missing, altered, or unexpected header values.
Pod HTTP modify header is a Kubernetes pod-level chaos fault that overrides HTTP request or response headers on the target pod for a configurable duration. You provide a map of header keys to values that the proxy then injects, replaces, or removes (when the value is empty). When the fault ends, headers return to normal immediately.
Use this fault to test how a client or server behaves when a header it depends on is missing, malformed, or carries an unexpected value: a missing Authorization, a flipped Cache-Control, a removed Content-Type, or a tampered correlation ID.
Use cases
Run this fault when you want to answer concrete questions like:
Authentication header tampering: Removing
Authorizationfrom the request or modifying its value verifies whether the server returns a clean401or leaks information about authentication failures.Cache directive resilience: Flipping
Cache-Controlfromno-storetomax-age=3600on responses reveals whether intermediate caches store sensitive data they should not.Tracing and correlation IDs: Stripping
X-Request-IDortraceparentshows whether logs and traces still correlate, or whether the request becomes invisible to observability.Content-type coercion: Changing
Content-Typefromapplication/jsontotext/htmlexposes clients that select parsers based on the header.Custom security headers: Removing
X-Frame-Options,Content-Security-Policy, orStrict-Transport-Securityfrom responses verifies whether browsers and downstream services degrade safely.
Prerequisites
Kubernetes version: 1.21 or later. Go to What's supported to confirm distribution support.
Target pods are Running: The application pods you intend to target are in the
Runningstate before the fault is launched.Privileged pods allowed: The cluster lets you schedule privileged pods in the chaos namespace. GKE Autopilot supports this fault but requires the one-time setup in Chaos on GKE Autopilot; other locked-down distributions may need similar exemptions.
Container runtime access: The chaos pod can reach the container runtime socket on the target node (
/run/containerd/containerd.sock,/var/run/docker.sock, or/var/run/crio/crio.sock).HTTP service on a known port: The target container serves HTTP, HTTPS, or gRPC traffic on a port you can specify with
TARGET_SERVICE_PORT.Workload selector defined: The chaos experiment knows the target workload by kind, namespace, and either names or labels.
Supported environments
Amazon EKS
Supported
Azure AKS
Supported
Google GKE
Supported
Red Hat OpenShift
Supported
Rancher
Supported
VMware Tanzu
Supported
Self-managed Kubernetes (CNCF-certified)
Supported
GKE Autopilot
Supported with Autopilot setup
EKS Fargate, ACI virtual nodes
Not supported (no access to container runtime sockets)
Permissions required
The fault runs under the chaos infrastructure's service account.
Resource (apiGroup)
Verbs
Why it is needed
pods ("")
get, list, create, delete, deletecollection, patch, update
Discover target pods and run the chaos pod on the same node
pods/log ("")
get, list, watch
Stream chaos pod logs for status and debugging
deployments, statefulsets, replicasets, daemonsets (apps)
get, list
Resolve the target workload to the pods it owns
events ("")
get, list, create, patch, update
Record fault progress as Kubernetes events
jobs (batch)
get, list, create, delete, deletecollection
Run the chaos job that drives the fault
The default Harness chaos infrastructure service account already includes these permissions.
Fault tunables
Configure the following fault parameters when you add Pod HTTP modify header to an experiment in Chaos Studio. Defaults are shown for reference.
Chaos parameters
HEADERS_MAP
JSON object of header key-value pairs to inject or replace. Set a value to "" to remove that header. Example: {"X-Auth-Token":"deadbeef","X-Trace-Id":""}.
{}
HEADER_MODE
Whether to modify request headers (sent to the server) or response headers (sent to the client).
response
TARGET_SERVICE_PORT
Port the target container listens on for HTTP traffic.
80
TOXICITY
Percentage of intercepted messages whose headers are modified, between 0 and 100. 100 modifies every matching message.
100
TOTAL_CHAOS_DURATION
Duration of the fault in seconds.
60
Proxy and interface
PROXY_PORT
Port the chaos proxy listens on inside the container's network namespace. Must not conflict with any port already in use on the target container.
20000
NETWORK_INTERFACE
Network interface inside the target container's namespace. Almost always eth0 for standard CNI plugins.
eth0
Targeting
TARGET_PODS
Comma-separated list of pod names to target. Empty selects from the workload's pods using POD_AFFECTED_PERCENTAGE.
""
TARGET_CONTAINER
Container in the pod whose network namespace to enter. Empty targets the first container in the pod spec.
""
NODE_LABEL
Label selector to filter target pods by the node they run on. Empty disables node-based filtering.
""
POD_AFFECTED_PERCENTAGE
Percentage of the workload's pods to target. 0 means one pod.
0
SEQUENCE
When multiple pods are targeted, inject parallel (all at once) or serial (one after another).
parallel
Runtime and helper
CONTAINER_RUNTIME
Container runtime on the target nodes. One of containerd, docker, crio.
containerd
SOCKET_PATH
Path to the container runtime socket on the target node. Set to match CONTAINER_RUNTIME.
/run/containerd/containerd.sock
RAMP_TIME
Wait period in seconds before and after the fault. Go to ramp time to read how it is applied.
0
Tunables that apply to every chaos fault are documented in common tunables for all faults.
Configure for your container runtime
Set CONTAINER_RUNTIME and SOCKET_PATH to match the runtime on the target node:
CONTAINER_RUNTIME
SOCKET_PATH
containerd (default)
/run/containerd/containerd.sock
docker
/var/run/docker.sock
crio
/var/run/crio/crio.sock
Fault execution in brief
Intercepts HTTP traffic on TARGET_SERVICE_PORT inside the container's network namespace and rewrites headers on either the request or response stream (as configured by HEADER_MODE) using the entries in HEADERS_MAP, optionally limited to a percentage of messages so other traffic is unaffected.
Expected behavior during fault execution
HTTP and HTTPS messages on
TARGET_SERVICE_PORTare rewritten according toHEADER_MODEandHEADERS_MAP. Existing headers with matching keys are replaced; new headers are added; headers with an empty value in the map are removed.Only messages selected by
TOXICITYare modified; the rest pass through unchanged. Bodies, status codes, and other headers are preserved.Traffic on other ports of the same container is not affected. gRPC headers and trailers carried over HTTP/2 are modified the same way.
Clients or servers that fail validation on missing or unexpected headers surface their own error responses (often
400or401); ones that silently fall back may continue to operate, which is itself a finding.
Signals to watch
Attach resilience probes to assert each layer:
Client error rate: Use an HTTP probe on the calling service to detect 4xx responses driven by missing or unexpected headers.
Authentication and authorization metrics: Use a Prometheus probe on auth failure counters when modifying
Authorizationor session headers.Trace continuity: Use a command probe to query your tracing system for orphan spans during the experiment window.
Verify the fault execution effect
While the experiment is running, confirm the headers are being rewritten:
Inspect headers returned to a client (when
HEADER_MODE=response).The response headers should reflect
HEADERS_MAP: added or modified keys present with the configured values, removed keys absent.Inspect headers received by the server (when
HEADER_MODE=request).Have the target application log the incoming request headers (or use an echo endpoint) and confirm the modifications appear there. Status codes, the response body, and headers outside
HEADERS_MAPshould be unchanged.
Recovery and cleanup
End of duration: The proxy is removed automatically and HTTP headers return to their original values.
Abort the experiment: Stopping the experiment from Chaos Studio triggers the same cleanup path.
Failed cleanup: If automated cleanup did not complete, restart the target pod to reset its network state.
Limitations
Serverless Kubernetes (EKS Fargate, ACI virtual nodes): These platforms do not expose container runtime sockets and reject the privileged access the fault needs. GKE Autopilot is supported once the one-time setup in Chaos on GKE Autopilot is in place.
Windows containers: This fault is supported on Linux pods only.
HTTPS without supplied certificates: This fault does not terminate TLS. If the target serves HTTPS and you need to modify encrypted headers, use Pod API modify header, which accepts CA, server, and client certificates as TLS inputs.
Pseudo-headers (HTTP/2
:method,:path,:status,:authority): These cannot be modified throughHEADERS_MAP. Use other faults (such as Pod HTTP status code) to control them.Hop-by-hop headers: Headers like
ConnectionandTransfer-Encodingare owned by the proxy itself and are not safe to override throughHEADERS_MAP.Port already bound: If
PROXY_PORTcollides with a port the target container is already using, the fault fails to start. Pick a port number outside the application's range.
Troubleshooting
Related faults
Pod HTTP latency: Delay HTTP responses instead of changing headers.
Pod HTTP modify body: Overwrite the HTTP response body.
Pod HTTP status code: Change the HTTP response status code returned to the client.
Pod HTTP reset peer: Reset HTTP TCP connections instead of altering headers.
Pod API modify header: Modify request or response headers with rich path, method, header, source, and destination filters (and HTTPS support via supplied TLS certificates).
Common pod fault tunables: Shared environment variables for selecting target pods and workloads.
Last updated
Was this helpful?