infra(gateway): enable Envoy HTTP access logs for the Cilium GatewayClass (netsec F7) #76

Merged
sirius merged 1 commit from wt/t_e662b03a into master 2026-11-27 06:30:59 +00:00
3 changed files with 77 additions and 0 deletions
Showing only changes of commit 1caaae9a63 - Show all commits

infra(gateway): enable Envoy HTTP access logs for the Cilium GatewayClass

Finding F7: cilium-envoy emitted no request-level record, so the netsec
design's application-layer rules had no input stream.

CiliumGatewayClassConfig kube-system/cilium binds spec.telemetry.accessLogs
(JSON, HTTP target) to the cilium GatewayClass via spec.parametersRef, so
Cilium renders an access log into every Gateway listener's HTTP connection
manager and writes one JSON line per request to the cilium-envoy container
stdout (/var/log/pods/kube-system_cilium-envoy-*/cilium-envoy/*.log).

Fields are an explicit allowlist: method, path, response code/flags, duration,
bytes, authority, CF-Connecting-IP (real client, since Envoy is hostNetwork
behind cloudflared), X-Forwarded-For, peer, User-Agent, CF-Ray, upstream host.
No bodies, no header dumps: Authorization/Cookie never reach disk. Application
log level stays info (no debug/trace).
Lance Walters 2026-11-27 01:30:39 -05:00

View file

@ -0,0 +1,52 @@
# Envoy access logging for every Gateway served by the Cilium GatewayClass.
#
# Finding F7 (2026-11-27 netsec audit): cilium-envoy emitted no request-level
# record at all, so the design's HTTP attack-shape rules (§4d: traversal,
# `union select`, `%00`, .env/.git probes, high-rate 401/403 per client,
# scanner user-agents) had no input stream.
#
# Cilium 1.20 renders this into the Gateway listeners' HTTP connection manager
# and writes one JSON line per request to the cilium-envoy container's stdout,
# i.e. /var/log/pods/kube-system_cilium-envoy-*/cilium-envoy/*.log, which the
# node log store (Alloy -> Loki) already tails.
#
# Deliberately NOT logged:
# * no debug/trace Envoy application logging (disk is the constraint here);
# * no request/response headers wholesale and no bodies -- Authorization,
# Cookie and Set-Cookie therefore never reach disk. Only the named fields
# below are emitted, each an explicit command operator.
#
# `client_ip` is the real client identity: Envoy is hostNetwork, so the raw
# peer is cloudflared on the Pi (10.10.0.1). Cloudflare sets CF-Connecting-IP
# and cloudflared forwards it; `peer` and `x_forwarded_for` are kept so a
# missing/forged CF-Connecting-IP is visible rather than silently trusted.
apiVersion: cilium.io/v2alpha1
kind: CiliumGatewayClassConfig
metadata:
name: cilium
namespace: kube-system
spec:
description: Cilium GatewayClass with HTTP access logging (netsec F7)
telemetry:
accessLogs:
- format: JSON
targets:
- HTTP
json:
gateway: "%CILIUM_GATEWAY_NAMESPACE%/%CILIUM_GATEWAY_NAME%"
start_time: "%START_TIME%"
method: "%REQUEST_HEADER(:METHOD)%"
path: "%REQUEST_HEADER(X-ENVOY-ORIGINAL-PATH?:PATH)%"
protocol: "%PROTOCOL%"
response_code: "%RESPONSE_CODE%"
response_flags: "%RESPONSE_FLAGS%"
duration_ms: "%DURATION%"
bytes_received: "%BYTES_RECEIVED%"
bytes_sent: "%BYTES_SENT%"
authority: "%REQUEST_HEADER(:AUTHORITY)%"
client_ip: "%REQUEST_HEADER(CF-CONNECTING-IP)%"
x_forwarded_for: "%REQUEST_HEADER(X-FORWARDED-FOR)%"
peer: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
user_agent: "%REQUEST_HEADER(USER-AGENT)%"
cf_ray: "%REQUEST_HEADER(CF-RAY)%"
upstream_host: "%UPSTREAM_HOST%"

View file

@ -0,0 +1,23 @@
# The Cilium GatewayClass, declared here so the access-log configuration is
# bound by GitOps rather than a hand patch.
#
# Why this file exists at all: the cilium Helm chart creates the GatewayClass
# (controllerName io.cilium/gateway-controller) but has no values knob for
# `spec.parametersRef`, and Cilium only reads `spec.telemetry.accessLogs` from
# the CiliumGatewayClassConfig referenced there. Owning the object here keeps
# the binding in sirius/homek8s and applied by Flux.
#
# The rendered spec is byte-for-byte the chart's GatewayClass plus parametersRef,
# so a Helm upgrade and this manifest agree on every other field.
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: cilium
spec:
controllerName: io.cilium/gateway-controller
description: The default Cilium GatewayClass
parametersRef:
group: cilium.io
kind: CiliumGatewayClassConfig
name: cilium
namespace: kube-system

View file

@ -3,3 +3,5 @@ kind: Kustomization
resources:
- namespace.yaml
- gateway.yaml
- gatewayclass.yaml
- gatewayclass-config.yaml