Repository navigation
Description
Problem
The perimeter NetworkPolicies allow egress to public TCP 443 with the private ranges excluded: renovate-perimeter (k8s/devops/renovate/networkpolicy.yaml), devops-default-perimeter, and the policies of crawl4ai and SearXNG. Public 443 also reaches the Cloudflare tunnel hosts of the cluster. When cloudflare.access.public_ip_bypass is set (docs/CONFIGURATION.md, about line 200), a request from the homelab public address skips Cloudflare Access, so a pod in such a perimeter can reach cluster services (for example the LLM gateway) through the tunnel. The comment "no path to the gateway" (renovate-perimeter, about lines 5-6) is then not fully true. Found in the review of PR #6014; the gap is older than that PR.
Expected behavior
- A pod in a perimeter policy cannot reach a cluster service through its tunnel host: for example Access does not bypass requests from the cluster's own egress address for those hosts, or the bypass is limited to the hosts that need it, or a rule needs a service token for requests that come from the cluster.
- A check proves it from one pod of each perimeter (a request to the gateway tunnel host gets 403 or no route).
- The comments of the perimeter policies say what is true.
Related
- feat(k8s): run self-hosted Renovate as a CronJob in devops #6014, feat(k8s): run self-hosted Renovate as a CronJob in devops #4905, fix(cloudflare): find the edge rule that answers 403 for the webhook route #5035 (the edge rule that answers 403 for the webhook route).
Proposed design
Problem statement
The perimeter NetworkPolicies of the product base allow egress to public TCP 443 with the private ranges excluded. Public TCP 443 also reaches the Cloudflare tunnel hosts of the cluster. The Access application of the wildcard *.<domain> carries the policy homelab-public-ip-bypass with the workstation's public address, and a pod egresses through that same address. So a pod in a perimeter (renovate-perimeter, devops-default-perimeter, crawl4ai-perimeter, searxng-perimeter) reaches cluster services, such as the LLM gateway, through their tunnel hosts with no Access login. The comment of renovate-perimeter, crawl4ai-perimeter and searxng-perimeter that says the pod gets no path to the gateway is therefore false.
Acceptance criteria
Requirement: Bypass stays off the cluster-service tunnel hosts
devops cloudflare access sync SHALL attach the public-IP bypass policy only to the tunnel hosts that the configuration names as bypass hosts, and SHALL attach no bypass rule to a tunnel host that serves a cluster service.
Scenario: Sync of the gateway tunnel host
- WHEN a test runs the sync for the gateway tunnel host with
cloudflare.access.public_ip_bypassset to the homelab public address - THEN the built policy payload for that host holds no
bypassdecision and noipinclude rule for that address.
Requirement: Cluster-service tunnel hosts require a service token
The Access policy of a tunnel host that serves a cluster service MUST require a Cloudflare Access service token, so that a pod that holds no token is refused with 403.
Scenario: Service-token rule of the gateway tunnel host
- WHEN a test builds the policy payload for the gateway tunnel host
- THEN the payload holds a rule that names a service token, and no rule admits an anonymous request.
Requirement: Perimeter comment states the tunnel path
Each perimeter NetworkPolicy that this repository ships, and the matching sentences of docs/CLUSTER.md, MUST state the tunnel path and MUST cite issue #6021, and MUST NOT claim that the pod has no path to the gateway.
Scenario: Comment of a shipped perimeter policy
- WHEN a test walks the NetworkPolicy manifests under
k8s/devops/and the perimeter sentences ofdocs/CLUSTER.md - THEN each policy whose egress allows public TCP 443 names the tunnel path and cites fix(k8s): Close the tunnel path from the egress perimeters #6021, no sentence claims that the pod has no path to the gateway, and the test reads the raw file text so the comments are covered.
Requirement: Perimeter egress rules stay
The perimeter policies MUST keep their CoreDNS, OpenTelemetry and public HTTPS egress rules.
Scenario: Egress rules of renovate-perimeter
- WHEN a test reads
k8s/devops/renovate/networkpolicy.yaml - THEN the egress holds the UDP and TCP 53 rule to
kube-system, the TCP 4318 rule tootel, and the TCP 443 rule to public addresses.
Existing Tool Considered
No alternatives check has run on this item. Cloudflare Access, the Zero Trust platform the cluster already uses, covers the need: it lets each self-hosted application (one hostname) carry its own policies, so the public-IP bypass can be scoped to the hosts that need it (git, the API) and a cluster-service host can require a service token. It lacks nothing for this, and no open library replaces it. The change does not build a replacement: it extends the project's own devops cloudflare access sync, whose include rules hold only email and IP today (src/devops_cli/cloudflare/client.py:242) and whose sync manages one application per domain (src/devops_cli/cloudflare/client.py:842), to emit a service-token rule and to scope the bypass per host. That code costs about 1,200 tokens to write, about 400 tokens per later fix until it matches the tool, and about half a day of elapsed work. The comment fix needs no tool and no new code.
Key questions
- Which file holds
cloudflare.access.public_ip_bypass, and which code applies the setting to the Cloudflare Access policy?:cloudflare.access.public_ip_bypassis declared insrc/devops_cli/config/settings.py:616(cloudflare.public_ip_bypassat:655) and documented atdocs/CONFIGURATION.md:200._resolve_bypass_ipsreads it insrc/devops_cli/commands/cloudflare.py:793;_build_policy_include_rulesturns each address into an{"ip": {"ip": ...}}include rule atsrc/devops_cli/cloudflare/client.py:242; andsync_access_applicationattaches that rule as abypass-decision policy to the Access application of the synced domain (src/devops_cli/cloudflare/client.py:842,:869). [sources: src/devops_cli/config/settings.py:616, src/devops_cli/commands/cloudflare.py:793, src/devops_cli/cloudflare/client.py:242, src/devops_cli/cloudflare/client.py:842, docs/CONFIGURATION.md:200] - Which files hold the perimeter policies that the issue names?:
devops-default-perimeterisk8s/devops/networkpolicy.yaml,renovate-perimeterisk8s/devops/renovate/networkpolicy.yaml,crawl4ai-perimeterisk8s/devops/crawl4ai/networkpolicy.yaml, andsearxng-perimeterisk8s/devops/searxng/networkpolicy.yaml. Each egress allows public TCP 443 with the private ranges excluded. [sources: k8s/devops/networkpolicy.yaml:5, k8s/devops/renovate/networkpolicy.yaml:10, k8s/devops/crawl4ai/networkpolicy.yaml:9, k8s/devops/searxng/networkpolicy.yaml:8] - What does the comment of
renovate-perimeterclaim today?:k8s/devops/renovate/networkpolicy.yaml:5saysdevops-default-perimeterskips the pod,so it gets no path to the gateway, the cache Valkey, Qdrant or the API server.k8s/devops/crawl4ai/networkpolicy.yaml:5andk8s/devops/searxng/networkpolicy.yaml:3repeat the claim for their pods, anddocs/CLUSTER.md:262repeats it for Renovate (:215for Crawl4AI,:238for SearXNG). The public TCP 443 egress rule of each policy makes the claim false for the tunnel path. [sources: k8s/devops/renovate/networkpolicy.yaml:5, k8s/devops/crawl4ai/networkpolicy.yaml:5, k8s/devops/searxng/networkpolicy.yaml:3, docs/CLUSTER.md:262] - How does the cluster close the tunnel path from a pod in a perimeter to a cluster service?: Scope the public-IP bypass to the hosts that need it, and make each tunnel host that serves a cluster service require a Cloudflare Access service token. The wildcard application of the domain covers every host today (
k8s/README.md:934), and git relies on the bypass (k8s/README.md:939), so the bypass must move off the wildcard onto the host-specific applications that need it. A pod holds no service token, so Access answers 403 for the cluster-service hosts. (best practice) [sources: k8s/README.md:934, k8s/README.md:939, src/devops_cli/cloudflare/client.py:242, src/devops_cli/cloudflare/client.py:842]- Chosen: Scope the bypass per host and require a service token on the cluster service hosts. The wildcard application covers every host (
k8s/README.md:934), so the bypass must be scoped; git needs the bypass (k8s/README.md:939); a pod holds no service token, so Access answers 403. - Rejected: Remove
cloudflare.access.public_ip_bypass. It removes the owner's direct access to every host, including the git and API hosts that need it (k8s/README.md:939), more than the issue needs. - Rejected: Restrict the perimeter NetworkPolicy egress to named destinations. The perimeters need public TCP 443 to hosts that share Cloudflare anycast addresses, such as the npm registry. An ipBlock cannot separate the tunnel host.
- Rejected: Give the perimeter pods a separate egress address. It needs a CNI egress gateway and keeps the bypass. It costs more and gives the same result.
- Chosen: Scope the bypass per host and require a service token on the cluster service hosts. The wildcard application covers every host (
- How does the repository guard the perimeter comments offline?: Extend the per-policy invariant tests under
tests/invariants/with a test that reads the raw text of each shipped NetworkPolicy and asserts that every manifest whose egress allows public TCP 443 names the tunnel path and cites fix(k8s): Close the tunnel path from the egress perimeters #6021, and that none claims the pod has no path to the gateway.tests/invariants/test_k8s_renovate.py:475already asserts the egress ofrenovate-perimeterand:507reads raw lines for the license check, so the pattern exists and the test runs offline. The proposal's cited pathtests/test_architectural_invariants.pydoes not exist; the module istests/invariants/test_architectural_invariants.py, and its docstring shows it holds Python source invariants, not manifest text. (best practice) [sources: tests/invariants/test_k8s_renovate.py:475, tests/invariants/test_k8s_renovate.py:507, tests/invariants/test_architectural_invariants.py:1, tests/support/k8s_tree.py:147]- Chosen: A pytest in the per-policy invariant tests that reads the manifest text.
tests/invariants/test_k8s_renovate.py:475already asserts the egress ofrenovate-perimeter,:507reads raw lines, and the tests run offline. - Rejected: A pytest in
tests/invariants/test_architectural_invariants.py. That module holds Python source invariants (tests/invariants/test_architectural_invariants.py:1), not manifest text. - Rejected: A kube-linter custom check. kube-linter checks schemas and objects. It has no rule for comment text.
- Rejected: No guard. The false claim can return with the next edit.
- Chosen: A pytest in the per-policy invariant tests that reads the manifest text.
- Who creates the Cloudflare Access service token that the cluster-service tunnel hosts require?: The owner creates one service token in the Cloudflare Zero Trust dashboard and names it in the policy of each cluster-service tunnel host. No client in this repository holds or sends it, so it stays unused and no Secret reaches the cluster. Recommendation: create it as
homelab-cluster-servicewhen the change lands, then re-rundevops cloudflare access syncfor those hosts. (a person decides)
Open questions
- Who creates the Cloudflare Access service token that the cluster-service tunnel hosts require? (a person decides)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-17: none.
Tool: none found.
Reason: Searches found no open, maintained tool that scopes the Cloudflare Access public-IP bypass per host or adds a service-token rule; the fix belongs to the project's own access sync code and the manifest comments.
Lacks:
- No open tool scopes an Access bypass rule to named hosts
- No tool emits a service-token Access policy from project settings
- No tool checks NetworkPolicy comment text for a false claim
- Cloudflare Access is a hosted platform, not an open library
Activity
dan-petty commentedon Nov 16, 2026
A live security gap lets pods bypass Cloudflare Access to reach cluster services.Both address NetworkPolicies in the cluster, but dan-petty/homelab#346 adds missing policies to uncovered namespaces while the candidate closes the tunnel bypass in existing perimeter policies.devops-cli-service commentedon Nov 16, 2026
Owner question: Who creates the Cloudflare Access service token that the cluster-service tunnel hosts require? (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 17, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (5)
Searches run:
dan-petty commentedon Nov 18, 2026
This is stupid. Cloudflare is to protect external parties from requesting my services. I'm not trying to protect my project from accessing itself.