Repository navigation
feat(gke-edge): TLS policy, Cloud Armor on every backend, TLS from a Secret (agent-relay 0.7.59) - #477
Conversation
…Secret (agent-relay 0.7.59) The GKE Ingress's FrontendConfig only set the HTTPS redirect, so Google's default SSL policy applied (TLS 1.0 and later), and no backend had a Cloud Armor policy. Chart (all three values empty by default; default renders unchanged apart from the helm.sh/chart labels): - gkeIngress.sslPolicy: Compute SSL policy name, rendered as FrontendConfig spec.sslPolicy. - gkeIngress.securityPolicy: Cloud Armor policy name, set on the BackendConfig of every backend behind the Ingress (api, cast, both history edges, actors edge, relaygate edge) plus new policy-only BackendConfigs for the dashboard, the edge-deny Service and Relayfile. The dashboard and Relayfile Services are child-chart objects, so the render refuses until their backend-config annotation names the derived BackendConfig. - gkeIngress.tlsSecretName: a kubernetes.io/tls Secret instead of the ManagedCertificate, for an edge behind a proxy or CDN. Terraform: - modules/gcp/edge-security: google_compute_ssl_policy (MODERN or RESTRICTED, TLS 1.2 minimum) and an optional Cloud Armor policy: OWASP preconfigured rules (preview by default), per-client sign-in rate limit, source-IP allowlist with default deny, Cloudflare origin lockdown, a shared-secret origin header rule and client-address path rules keyed on the proxy's client-IP header. Labels on the policy. - examples/gcp creates the SSL policy by default and exports it as gkeIngress.sslPolicy in chart_values; Cloud Armor is opt-in. Docs: docs/gcp-install/3-EDGE-HARDENING.md, chart README, module README, registry entry opt.agent-relay.gke-edge-hardening. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
Reviewed against the f6b9x4unfg GKE POC values (13 Render
1.
2. Rotating the origin secret header causes an outage
3. Docs:
4. Small
No blockers from the POC side apart from item 1, which should be measured before the docs state a number. |
[Medium impact] The documentation fix appears safe to merge; no blocking issues remain.
|
…nce, Cloudflare WAF pointer Review feedback on #477: - origin_secret_header takes values (1-3 accepted values) instead of one value, so rotation is add-next, switch the proxy, drop-old with no 403 window. - The guide no longer states trustedProxies: 2 behind Cloudflare. The Google load balancer appends two X-Forwarded-For entries, so the expected value is 3; the guide says to raise the measured value by one and how to measure it from the audit log. - Per-client path rules behind Cloudflare: point at Cloudflare WAF custom rules; client_ip_rules stay for other fronting proxies. - Note which resources carry labels, and to compare Cloudflare's published ranges before each apply. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks for the review against the POC values. Addressed in 34090c4:
|
…ured trustedProxies - client_ip_rules take optional hosts and are documented as the way to say which clients may reach which paths behind a proxy: rules apply in list order, and a closing ["/"] rule shuts every other path. Test covers vendor ranges on the history upload paths plus a closed remainder. Cloudflare WAF is the alternative when a vendor's list exceeds Cloud Armor's advanced-rule quota. - trustedProxies: measured on a live GKE install, the Google load balancer appends two X-Forwarded-For entries, so the value is 2 without a fronting proxy and 3 behind Cloudflare (expected, not yet measured). The guide shows how to read the header from the relay-webapp access log. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…l-safe validation Review feedback on #477: - A client_ip_rules entry admitted its clients with a terminal allow at priority 2000+, so those requests skipped the rate limits (and the connecting-address allowlist). A rule whose ranges fit one expression (4, or 3 with hosts) is now a single deny rule ("these paths and not one of these clients"): it admits nobody, and its clients continue to the rate limits and allowlist. A longer list cannot be negated across rules, so it still admits; it can carry its own per-client rate_limit (throttle keyed on the client address), and the module refuses a long rule with neither a rate_limit nor unthrottled = true while rate_limits is set. - origin_secret_header validation used "== null ||" around attribute reads, which fails on null before Terraform 1.9 (both sides are evaluated). It is now a conditional. - Guide: raise trustedProxies for Cloudflare only after direct requests to the load balancer are refused; otherwise a direct caller can forge its address. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s own limit Second review round on #477. The deny-only form for short lists let an approved client fall through to later client rules (a vendor admitted by its own rule was then denied by a closing "/" rule), and it ignored a rule's rate_limit. client_ip_rules now have one form and one meaning: the first rule whose paths (and hosts) match decides the request. Its clients are admitted, by a throttle keyed on the client address when the rule has a rate_limit, and everyone else on those paths is denied. Because an admitted request meets no later rule: - every rule must set rate_limit or unthrottled = true; - a rule for every path ("/" without hosts) is refused while rate_limits is non-empty, since those limits could never apply; the sign-in limit is then written as a narrower rule ahead of it. Tests cover a short vendor list ahead of a staff-only "/" rule, a one-range rule with a rate_limit, and both refusals. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… in vendor rules Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ay which release they need The GKE guide installs agent-relay-2026.11.16 (chart 0.7.54, Terraform from that tag), which has neither the gkeIngress edge keys nor the edge_* Terraform inputs, and its chart would ignore the keys without an error. - 0-START-HERE.md: step 4 keeps the pinned release's resource list and plan count (29); step 14 points at the hardening guide instead of claiming the TLS policy exists. - 3-EDGE-HARDENING.md and the values template: these controls need chart 0.7.59 or later and the Terraform from the same release, with a command to check. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Self-review finding, fixed in c0c043f: the GKE guide installs the pinned release |
…e expression Review feedback on #477: path_regex went into the quoted Cloud Armor expression as written, so a regex escape such as \. was consumed by the expression's string reader and the rule failed to apply. Backslashes are now doubled, as they already are for client rule paths and hosts. Test added. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review feedback on #477: GKE leaves a backend's security policy in place when spec.securityPolicy is absent and detaches only on an empty name, so clearing the chart value did not detach it and Terraform could not delete the policy. The removal steps now patch every BackendConfig to an empty name, wait, then clear the values and destroy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…aform removes it Review feedback on #477: managed-values.json keeps the old sslPolicy until an apply, and the apply cannot delete a policy still in use. The steps now clear it with an override in values.yaml, wait, then apply and regenerate. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Why
Two findings from the GCP self-host hardening review:
redirectToHttps, so Google's default SSL policy applied and the load balancer accepted TLS 1.0 and 1.1. The EKS path pinsELBSecurityPolicy-TLS13-1-2-2021-06.It also adds what an install behind a fronting proxy (Cloudflare) needs: a certificate from a Secret, and a policy that only admits the proxy.
What changes
Chart
agent-relay0.7.59Three new
gkeIngressvalues, all empty by default. Default renders are unchanged apart from thehelm.sh/chartlabels.gkeIngress.sslPolicyFrontendConfig.spec.sslPolicygkeIngress.securityPolicyspec.securityPolicy.nameon the BackendConfig of every backend behind the IngressgkeIngress.tlsSecretNamekubernetes.io/tlsSecret inspec.tlsinstead of the ManagedCertificate (not rendered)"Every backend" means: api, cast, history read, history ingest, actors edge and relaygate edge (their existing BackendConfigs keep timeouts and health checks), plus new policy-only BackendConfigs
<name>-dashboard,<name>-edge-denyand<name>-files. The dashboard and Relayfile Services belong to child charts, so the render refuses until theircloud.google.com/backend-configannotation names the derived BackendConfig, and prints the value to set. No child chart changes.Terraform
terraform/modules/gcp/edge-security:google_compute_ssl_policy(MODERNorRESTRICTED, TLS 1.2 minimum;COMPATIBLE/TLS 1.0 are refused by validation).security_policy.create): OWASP preconfigured rules at sensitivity 1, a per-client rate limit on sign-in paths, a source-IP allowlist with default deny (also usable alone, as a pure allowlist), Cloudflare origin lockdown (published ranges only), a shared-secret origin header rule, and path rules keyed on the proxy's client-IP header (origin.user_ip). Labels on the policy.terraform/examples/gcpcalls it: the SSL policy is created by default and exported asgkeIngress.sslPolicyinchart_values; Cloud Armor is opt-in (edge_security_policy).Docs
docs/gcp-install/3-EDGE-HARDENING.md(steps and "Done when" checks for TLS policy, Cloud Armor, Cloudflare in front, includingtrustedProxies: 2and which hostnames a Cloudflare Universal certificate covers), chart README "GKE edge hardening", module README, GKE skill inputs, registry entryopt.agent-relay.gke-edge-hardening.Defaults chosen, and why
gkeIngress.sslPolicy: empty in the chart, on by default through Terraform. The chart cannot create a Compute resource, and a name that does not exist in the project stops the Ingress from syncing, so a chart default would break every install that upgrades. Insteadterraform/examples/gcpcreates the policy and puts its name inmanaged-values.json, which the guide already passes tohelm upgrade. New guided installs get TLS 1.2+ with no extra step; an existing install gets it the next time it re-applies step 4 and upgrades (plan shows one resource to add; the documented plan count goes from 29 to 30). Opt out withedge_ssl_policy = { create = false }. Bring-your-own installs create it with onegcloudcommand.methodenforcementplus the language-specific rule sets are left out (the API uses PUT/PATCH/DELETE).Design notes for review
client_ip_rules(which trustCF-Connecting-IP) requireorigin_secret_header. That value is in Terraform state and readable in the policy; the docs say so.Tests
ci/agent-relay/render.sh: defaults render none of the three; with them set, the FrontendConfig carriessslPolicyand keeps the redirect, every BackendConfig carries the policy, every Service the Ingress routes to is bound to a BackendConfig that has it, timeouts and health checks survive; actors/files overlay;tlsSecretNamedrops the ManagedCertificate and annotation; each refusal.terraform test(mock provider): 10 runs in the module, 3 new runs inexamples/gcp.scripts/ci/charts.sh static agent-relay,ci/agent-relay/render.sh,scripts/ci/version-bump.sh,node ci/self-hosted-requirements/registry.mjs check,terraform fmt/validate/test, tflint, terraform-docs, checkov on the changed module and example: all pass. Local Helm is 4.1.3, so the subdomain golden hash check was skipped locally and runs in CI.Not proven
Nothing here has run against a live GCP project: no
terraform apply, no real load balancer. Unproven until a live install: that GKE attaches the policies as rendered, the Cloud Armor rule expressions and quotas (seven advanced rules with Cloudflare on),trustedProxies: 2behind Cloudflare, and long-lived WebSocket/SSE connections through Cloudflare.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.