From 406e8dff787c05c38bbdf81240c48b422cb0257a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 11:52:33 +0000 Subject: [PATCH 1/2] fix(chart): always guard the audit syslog bridge with a token When api.audit.webhook.authSecretRef is unset, generate a kept Secret gameplane-audit-syslog-bridge-token and wire it to both the API's webhook Authorization header and the bridge's AUTH_HEADER, so the bridge never accepts unauthenticated POSTs from other workloads. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Claude --- charts/gameplane/templates/_helpers.tpl | 16 +++++++++++ charts/gameplane/templates/api.yaml | 7 +++-- .../templates/audit-syslog-bridge.yaml | 28 +++++++++++++++---- charts/gameplane/values.yaml | 10 +++---- docs/install.md | 3 ++ 5 files changed, 51 insertions(+), 13 deletions(-) diff --git a/charts/gameplane/templates/_helpers.tpl b/charts/gameplane/templates/_helpers.tpl index a08a89ec6..a31163445 100644 --- a/charts/gameplane/templates/_helpers.tpl +++ b/charts/gameplane/templates/_helpers.tpl @@ -312,3 +312,19 @@ applies the chart's ModuleSources), otherwise empty. true {{- end -}} {{- end -}} + +{{/* +gameplane.auditWebhookAuthRef returns "name/key" of the Secret holding the +audit webhook Authorization value, or "" when none applies. An explicit +api.audit.webhook.authSecretRef wins; otherwise, when the bundled syslog bridge +is the auto-wired sink, the chart-generated gameplane-audit-syslog-bridge-token +Secret is used so the bridge never runs without inbound authentication. +*/}} +{{- define "gameplane.auditWebhookAuthRef" -}} +{{- $w := .Values.api.audit.webhook -}} +{{- if $w.authSecretRef.name -}} +{{- printf "%s/%s" $w.authSecretRef.name $w.authSecretRef.key -}} +{{- else if and $w.syslogBridge.enabled (not $w.url) -}} +gameplane-audit-syslog-bridge-token/token +{{- end -}} +{{- end -}} diff --git a/charts/gameplane/templates/api.yaml b/charts/gameplane/templates/api.yaml index d892d6709..ea2c07eeb 100644 --- a/charts/gameplane/templates/api.yaml +++ b/charts/gameplane/templates/api.yaml @@ -480,12 +480,13 @@ spec: name: {{ .Values.api.oidc.clientSecretRef.name }} key: {{ .Values.api.oidc.clientSecretRef.key }} {{- end }} - {{- if .Values.api.audit.webhook.authSecretRef.name }} + {{- with include "gameplane.auditWebhookAuthRef" . }} + {{- $ref := splitList "/" . }} - name: GAMEPLANE_AUDIT_WEBHOOK_AUTH valueFrom: secretKeyRef: - name: {{ .Values.api.audit.webhook.authSecretRef.name }} - key: {{ .Values.api.audit.webhook.authSecretRef.key }} + name: {{ index $ref 0 }} + key: {{ index $ref 1 }} {{- end }} {{- if .Values.api.audit.s3.credentialsSecretRef.name }} - name: GAMEPLANE_AUDIT_S3_ACCESS_KEY diff --git a/charts/gameplane/templates/audit-syslog-bridge.yaml b/charts/gameplane/templates/audit-syslog-bridge.yaml index c030d0150..e5c636c39 100644 --- a/charts/gameplane/templates/audit-syslog-bridge.yaml +++ b/charts/gameplane/templates/audit-syslog-bridge.yaml @@ -7,6 +7,24 @@ {{- if not $b.syslog.addr }} {{- fail "api.audit.webhook.syslogBridge.enabled=true requires api.audit.webhook.syslogBridge.syslog.addr (your collector host:port)" }} {{- end }} +{{- if not .Values.api.audit.webhook.authSecretRef.name }} +{{- /* Generated once: lookup returns the live Secret on install and upgrade; offline renders regenerate it. */}} +{{- $old := lookup "v1" "Secret" .Release.Namespace "gameplane-audit-syslog-bridge-token" }} +# Shared token for the API → bridge call when api.audit.webhook.authSecretRef +# is unset, so the bridge never accepts unauthenticated POSTs. +apiVersion: v1 +kind: Secret +metadata: + name: gameplane-audit-syslog-bridge-token + namespace: {{ .Release.Namespace }} + labels: {{- include "gameplane.labels" . | nindent 4 }} + annotations: + helm.sh/resource-policy: keep +type: Opaque +data: + token: {{ dig "data" "token" "" ($old | default dict) | default (printf "Bearer %s" (randAlphaNum 43) | b64enc) }} +--- +{{- end }} # Generic HTTP-JSON → syslog relay. The API's audit webhook POSTs each event # here; this forwards it as RFC 5424 syslog to the configured collector. It # touches no Kubernetes API, so it runs with the default ServiceAccount and no @@ -44,16 +62,16 @@ spec: - { name: APP_NAME, value: {{ $b.appName | quote }} } - { name: FACILITY, value: {{ $b.facility | quote }} } - { name: SEVERITY, value: {{ $b.severity | quote }} } - {{- if .Values.api.audit.webhook.authSecretRef.name }} # Require the same shared token the API sends as its Authorization # header, so the bridge rejects unauthenticated POSTs from other - # workloads. Sourced from the Secret, never a flag/plain value. + # workloads. Sourced from the Secret, never a flag/plain value: the + # one in authSecretRef, or the chart-generated token Secret below. + {{- $ref := splitList "/" (include "gameplane.auditWebhookAuthRef" .) }} - name: AUTH_HEADER valueFrom: secretKeyRef: - name: {{ .Values.api.audit.webhook.authSecretRef.name }} - key: {{ .Values.api.audit.webhook.authSecretRef.key }} - {{- end }} + name: {{ index $ref 0 }} + key: {{ index $ref 1 }} ports: - { name: http, containerPort: 8514 } livenessProbe: { httpGet: { path: /healthz, port: http }, initialDelaySeconds: 5 } diff --git a/charts/gameplane/values.yaml b/charts/gameplane/values.yaml index ece6a4d9c..3437799b9 100644 --- a/charts/gameplane/values.yaml +++ b/charts/gameplane/values.yaml @@ -343,11 +343,11 @@ api: # above — automatically points the API's audit webhook at it, so each # audit event is forwarded to your syslog/SIEM collector. Off by default. # - # Auth: the bridge Service is a ClusterIP other pods can reach. Set - # `authSecretRef` above and the SAME token guards both the API→bridge call - # and the bridge's inbound check, so only the API can inject records — - # strongly recommended. Without it the bridge accepts unauthenticated POSTs - # (rely on NetworkPolicies to restrict who can reach :8514). + # Auth: the bridge Service is a ClusterIP other pods can reach, so the + # API→bridge call and the bridge's inbound check always share a token and + # only the API can inject records. Set `authSecretRef` above to supply + # your own; otherwise the chart generates one in the Secret + # gameplane-audit-syslog-bridge-token (kept across upgrades). # # Setting webhook.url explicitly disables the auto-wiring, so don't enable # the bridge and set webhook.url at the same time (the bridge would run diff --git a/docs/install.md b/docs/install.md index cb6dbf3eb..723a505a9 100644 --- a/docs/install.md +++ b/docs/install.md @@ -561,6 +561,9 @@ a slow or down sink never blocks or fails a request. `syslogBridge.syslog.addr` to your collector `host:port` (required when enabled), and optionally `network` (`tcp`/`udp`), `tls`, `facility`, and `severity`. Setting `webhook.url` explicitly overrides the auto-wiring. + The API and the bridge always share a token: the one in `authSecretRef`, + or, when that is unset, one the chart generates in the Secret + `gameplane-audit-syslog-bridge-token` (kept across upgrades). ```sh helm upgrade ... \ From d62a17fc552cb8a29b12f9394b3d3bcdc4a5d19f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 11:53:30 +0000 Subject: [PATCH 2/2] docs(changelog): add entry for the syslog bridge token Co-Authored-By: Claude Opus 5.5 Signed-off-by: Claude --- changelog/unreleased/1099-syslog-bridge-token.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 changelog/unreleased/1099-syslog-bridge-token.md diff --git a/changelog/unreleased/1099-syslog-bridge-token.md b/changelog/unreleased/1099-syslog-bridge-token.md new file mode 100644 index 000000000..de8190173 --- /dev/null +++ b/changelog/unreleased/1099-syslog-bridge-token.md @@ -0,0 +1,11 @@ +# Audit syslog bridge always requires a token + +With `api.audit.webhook.syslogBridge.enabled=true` and no +`api.audit.webhook.authSecretRef`, the chart now generates a token in the +Secret `gameplane-audit-syslog-bridge-token` (kept across upgrades) and gives +it to both the API and the bridge, so other pods can no longer post forged +audit records to the bridge. The bridge image now refuses to start without +`AUTH_HEADER` unless `ALLOW_UNAUTHENTICATED=true` is set. Tailscale tunnels +also cap how many forwarding sessions one tailnet peer can hold (a quarter of +the budget). No action is needed on upgrade. +[PR #1099](https://github.com/GameplanePanel/Gameplane/pull/1099)