Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog/unreleased/1099-syslog-bridge-token.md
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions charts/gameplane/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
7 changes: 4 additions & 3 deletions charts/gameplane/templates/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 23 additions & 5 deletions charts/gameplane/templates/audit-syslog-bridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
10 changes: 5 additions & 5 deletions charts/gameplane/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ... \
Expand Down