Threat Model: Network & Ingress¶
| Created | 2026-08-09 |
| Last reviewed | 2026-10-14 |
| Next review due | 2027-04-14 (6-month cadence, or on any change to the edge, firewall or ingress path) |
| Reviewers | Platform owner |
| Version | 2.2 |
| Surface owner | Platform / Network |
Scope: how traffic reaches the OVH k3s server. The Cloudflare edge (proxy, WAF, rate limit, Workers, Tunnel, Access), the host firewall, Traefik routing and TLS, the Tailscale admin path, and NetworkPolicy isolation inside the cluster. Also the CI identity that writes the edge config. Request authentication is in Authentication.
How these parts work: Cloudflare, OVH bare metal, Server Access, TLS, Network Policies.
Data flow diagrams¶
Node shapes: stadium = external entity, rectangle = process, cylinder = data store, subgraph = trust boundary.
Path 1: public request to the origin¶
flowchart LR
E1([E1 · Client]) -->|F1 HTTPS| P1
E7([E7 · First-party Workers]) -->|F13 HTTPS + signed header| P1
E2([E2 · Direct-to-origin attacker]) -.->|F4 HTTPS to node IP| P3
subgraph edge[trust boundary: Cloudflare edge]
P1[P1 · Cloudflare proxy<br/>WAF · rate limit · edge TLS · redirects · OG Worker]
end
P1 -->|F2 HTTPS + origin-pull cert| P2
subgraph host[trust boundary: OVH server]
P2[P2 · ufw 80/443 · ServiceLB]
P2 --> P3[P3 · Traefik<br/>LE cert · AOP on prod · host route]
P3 -->|F3 HTTP :8080/:8081| P4[P4 · api / frontend]
end
Prod hosts (tomoda.life, api, app, www) require the Cloudflare origin-pull client cert at TLS. Dev hosts (api-dev, app-dev) are proxied but accept any client, so F4 reaches dev. Admin hosts (argo-app, grafana, auth, ota, redis-*, pg-admin-*) are DNS-only and resolve to the node IP.
Path 2: edge-only services and admin access¶
flowchart LR
E3([E3 · Synthetic Worker]) -->|F5 service token| P5
E4([E4 · Operator]) -->|F7 GitHub login| P6
E4 -->|F8 WireGuard| P7
subgraph cf[trust boundary: Cloudflare Zero Trust]
P5[P5 · Access: loki-push]
P6[P6 · Access: docs]
end
P5 -->|F6 Tunnel| D1[(D1 · Loki)]
P6 --> D2[(D2 · Pages docs)]
subgraph ts[trust boundary: tailnet]
P7[P7 · tag:server :22 / :6443]
end
Path 3: east-west after a pod breach¶
flowchart LR
E5([E5 · Breached pod]) -.->|F9 denied| P4[P4 · api / frontend / async]
E5 -.->|F10 denied| D3[(D3 · Postgres, Redis, NATS)]
E5 -->|F11 allowed| D4[(D4 · Loki, monitoring)]
E5 -->|F12 allowed| E6([E6 · Internet])
DFD elements¶
| Ref | Type | Element | Source |
|---|---|---|---|
| E1 | External | Client (browser, mobile) | |
| E2 | External | Attacker connecting to the node IP | |
| E3 | External | Synthetic Worker | infrastructure/cloudflare/worker.tf |
| E4 | External | Operator | scripts/ovh/admin-users.sh |
| E5 | External | Breached workload in any namespace | |
| E7 | External | Synthetic and OG preview Workers calling the API | infrastructure/cloudflare/worker.tf, og_worker.tf |
| P1 | Process | Cloudflare proxy | infrastructure/cloudflare/zone_settings.tf, waf.tf, redirects.tf, og_worker.tf |
| P2 | Process | Host firewall and ServiceLB | scripts/ovh/bootstrap-node.sh |
| P3 | Process | Traefik | k8s/envs/platform/traefik/values.yaml |
| P4 | Process | App pods | k8s/apps/tomoda/ |
| P5, P6 | Process | Access apps | infrastructure/cloudflare/access.tf |
| P7 | Process | Tailscale grant | infrastructure/tailscale/policy.hujson |
| D1 | Store | Loki via Tunnel | infrastructure/cloudflare/tunnel.tf |
| D2 | Store | Docs Pages project | infrastructure/cloudflare/pages.tf |
| D3 | Store | Postgres (CNPG), Redis, NATS | k8s/envs/{dev,prod}/postgres/manifests/network-policy.yaml, k8s/envs/*/redis/values.yaml, k8s/envs/platform/nats/manifests.yaml |
| D4 | Store | Loki, monitoring | k8s/envs/platform/loki/, k8s/envs/platform/monitoring/ |
Assets and trust boundaries¶
Assets: user traffic and sessions on prod hosts, the node's admin ports, Postgres and Redis data, logs in Loki, internal docs, and the edge config itself (DNS, Access, zone settings, tailnet policy).
Boundaries: Cloudflare edge to origin (F2), public internet to the node (F4), tailnet to the node (F8), namespace to namespace (F9 to F11), and CI to the Cloudflare and Tailscale APIs.
Layered abuse protection¶
Abuse controls are layered so the edge absorbs the bulk of hostile traffic and the app only applies proportionate, logged, reversible controls. No layer hard-blocks a shared address.
| Layer | Control | Acts on | Where |
|---|---|---|---|
| Edge | Automatic L7 DDoS mitigation | Floods on proxied hosts | Cloudflare default |
| Edge | Cloudflare Free Managed Ruleset | Known exploit signatures | waf.tf waf_managed |
| Edge | Custom block rules: exploit and scanner paths, traversal sequences in the parsed or raw URI, attack tool user agents | Scanner traffic, on every host including /api/* |
waf.tf waf_custom |
| Edge | Rate limit, 20 requests per 10s per IP and colo, 10s block | Credential endpoints under /api/v1/auth/ |
waf.tf rate_limit |
| Origin | Traefik trusts forwarded headers only from Cloudflare ranges | Client IP spoofing | k8s/envs/platform/traefik/values.yaml |
| App | IP blocker, per-IP and per-account rate limits, login lockout | What gets past the edge, and direct-to-origin dev traffic | tomoda docs/backend/security/ip-blocker.md, rate-limiting.md |
Edge rules only block; none challenges, since a challenge page breaks the JSON and WebSocket clients on /api/* and /ws/*. The blocked patterns never match a real client, the Workers or the synthetic probes, so none needs an exemption. The app layer's thresholds, its shared-range exemptions (Cloudflare's published ranges, private and loopback addresses) and its unblock path are documented in the app repo.
First-party Workers. Cross-zone Worker subrequests reach the origin with the shared client IP 2a06:98c0:3600::103, and Cloudflare egress in general comes from its published ranges (IPv4 egress is 172.64.0.0/13), which every Cloudflare tenant shares. Our Workers therefore prove who they are with X-Tomoda-Worker-Auth, an HMAC-SHA256 over timestamp, Worker name, method and path, keyed by tomoda-worker-auth-secret (Cloudflare). An unsigned or invalid header is ignored, so the backend never depends on it being present.
Cost. The zone is on the Free plan and every control above is included, so the edge layer costs $0 a month. Paid options considered and rejected:
| Option | Price | What it would add | Why not |
|---|---|---|---|
| Pro plan | from $20/month | Full Cloudflare Managed Ruleset, 20 custom rules, 2 rate-limit rules with 1 minute periods and method or query fields, Super Bot Fight Mode | Free covers the scanner and flood cases; the app already limits per account and per IP at finer grain |
| Business plan | from $200/month | Regex in rules, 5 rate-limit rules with longer periods and blocks, custom block responses | Cost far above the risk at current traffic |
| Enterprise add-ons (Advanced Rate Limiting, Bot Management, firewall Logpush) | contract pricing | Counting by header or session, bot scores, WAF event export | Not available without an Enterprise contract |
STRIDE¶
Edge and origin (P1 to P4)¶
| Ref | Threat | Mitigation | Residual |
|---|---|---|---|
| F4, P3 | Spoofing. Attacker skips Cloudflare and hits prod on the node IP | Zone AOP on (infrastructure/cloudflare/origin_pulls.tf); Traefik TLSOption RequireAndVerifyClientCert on the prod Ingress (k8s/apps/tomoda/overlays/prod/cloudflare-aop.yaml). Handshake without the cert fails; a mismatched SNI with Host: api.tomoda.life gets 421 |
Low. Cloudflare's shared origin-pull CA means any Cloudflare zone can present a valid cert; a per-zone cert closes that |
| F4, P3 | Spoofing. Same bypass on dev | None. Dev has no AOP (k8s/apps/tomoda/base/ingress.yaml), and the node IP is public through DNS-only admin records |
Medium. Gap: dev skips edge TLS policy and Cloudflare DDoS, and shares the node with prod |
| F1, F2 | Tampering. Traffic downgraded or intercepted | Edge: SSL mode strict, so Cloudflare validates the origin cert chain, expiry and hostname; TLS 1.2 minimum, TLS 1.3 on, Always Use HTTPS, automatic HTTPS rewrites (zone_settings.tf). API sends HSTS. Origin: Let's Encrypt certs, prod via DNS-01 (k8s/envs/platform/cert-manager/cluster-issuer.yaml) |
Low |
| F3 | Information disclosure. Traefik to pod is plain HTTP | Single node, pod network only; node-to-node traffic would use flannel wireguard-native (scripts/ovh/k3s-server.yaml) |
Low |
| F13, P4 | Spoofing. Attacker poses as a first-party Worker to skip the app's IP blocker | Workers sign each API call with an HMAC over timestamp, Worker name, method and path; the key lives in Secret Manager and the Worker binding only. The backend accepts a 5 minute clock skew and ignores invalid headers | Low. A captured header replays only for the same method and path within the skew window |
| P3 | Spoofing. Client forges X-Forwarded-For to dodge IP limits |
Traefik trusts forwarded headers only from Cloudflare ranges; externalTrafficPolicy: Local keeps the source IP. Backend ClientIP walks XFF right to left past the pod CIDR and Cloudflare ranges, falling back to X-Real-IP; CF-Connecting-IP is not read (tomoda backend/internal/api/context.go, config.prod.yaml) |
Low. Cloudflare ranges are hard-coded in both places and drift when Cloudflare changes them |
| P1, P4 | Denial of service. Request floods, scanners and credential stuffing | Layered as above: Cloudflare L7 DDoS, the Free Managed Ruleset, custom block rules for exploit paths, traversal and attack tools, and a per-IP rate limit on the credential endpoints (infrastructure/cloudflare/waf.tf). Behind it the app's IP blocker and per-IP and per-account limits (backend/internal/middleware/) |
Medium. Free plan limits: 10s rate-limit window, no regex, no bot scores, and WAF events only in the dashboard. DNS-only and direct-to-origin dev traffic gets no edge protection (finding 1) |
| P2 | Elevation. Exposed host ports | ufw default deny; only 80/443 and 41641/udp public; 22 and 6443 only on tailscale0 (scripts/ovh/bootstrap-node.sh). Traefik dashboard and metrics ports are not in the Service |
Low. Any ADMIN_CIDRS passed at bootstrap stay as public 22/6443 rules until removed by hand |
| P3 | Tampering. An Ingress claims a hostname or proxies out of the cluster | Admin hosts must carry the oauth2-proxy middleware (policy/admin_ingress_auth.rego, CI-enforced). external-dns TXT registry won't overwrite records it doesn't own |
Low. Gap: nothing restricts which namespace may claim which host; allowExternalNameServices=true lets an Ingress proxy to any host |
Edge-only services (P5, P6)¶
| Ref | Threat | Mitigation | Residual |
|---|---|---|---|
| F5, D1 | Spoofing. Anyone writes to Loki through the Tunnel | Access app loki-push, service-token-only policy; Tunnel catch-all returns 404 (access.tf, tunnel.tf) |
Low. The service token expires after a year and pushes stop; no expiry alert |
| F7, D2 | Information disclosure. Internal docs read without login | Access app on docs.tomoda.life, tomoda-labs GitHub members; Pages preview deployments off (pages.tf) |
Medium. Gap: the Access app covers only docs.tomoda.life, not the project's *.pages.dev hostname |
| P6 | Coverage. Admin UIs outside Access | Admin UIs sit behind oauth2-proxy or Argo CD Dex at Traefik, not Access; see Authentication | Low. Accepted: one gate per admin UI, enforced by the conftest policy |
Admin path (P7)¶
| Ref | Threat | Mitigation | Residual |
|---|---|---|---|
| F8 | Spoofing. Stolen or rogue tailnet device reaches the server | Grant allows only tcp:22 and tcp:6443 to tag:server; policy tests deny 80/443 (policy.hujson). SSH is key-only and per-person; 6443 needs the admin kubeconfig |
Medium. Gap: the grant source is autogroup:member, so every member reaches both ports. Device approval and key expiry live in the admin console (tailscale_tailnet_settings manages nothing) |
| P7 | Elevation. Breached server pivots into operator devices | No grant has tag:server as a source; the server can't open connections to members |
Low |
| P7 | Spoofing. Rogue device tagged tag:server |
Only autogroup:admin owns the tag |
Low |
East-west (F9 to F12)¶
| Ref | Threat | Mitigation | Residual |
|---|---|---|---|
| F9 | Elevation. Breached pod reaches app pods | Ingress policies on api, async, frontend (k8s/apps/tomoda/base/network-policy.yaml), enforced by k3s's built-in controller |
Low |
| F10 | Elevation. Breached pod reaches Postgres, Redis or NATS | Prod Postgres admits 5432 only from the prod backend pods, prod pgAdmin and its own instances; dev tooling in data is denied. Each env's Redis admits 6379 only from that env's backend pods and its Redis Insight (allowExternal: false). NATS admits 4222 only from the api and async pods in tomoda-dev and tomoda-prod |
Low. Credentials are required on top of the policy |
| F11 | Information disclosure. Breached pod reaches Loki or monitoring | None | Medium. Gap: no policy for Loki, monitoring, Argo CD or Photon |
| F12 | Information disclosure. Exfiltration from a breached pod | None | Medium. Gap: no egress policy anywhere |
Edge config control plane (CI)¶
| Ref | Threat | Mitigation | Residual |
|---|---|---|---|
| CI | Elevation. A PR branch runs code as the apply identity | The github-actions WIF pool accepts tokens only from tomoda-labs/devops; fork PRs get no OIDC token. Applies run as terraform-apply, bound through job_workflow_ref to terraform-apply.yml on refs/heads/main (infrastructure/gcp/wif.tf). Plans run as terraform-ci, which is read-only in GCP (infrastructure/gcp/service_accounts.tf) |
High, accepted. Plans load the write-capable Cloudflare API token, Tailscale OAuth client and GitHub App key, so any branch push can change DNS, Access, the tailnet policy or GitHub settings; see Release Integrity |
Findings and recommendations¶
- Medium: dev origin open without Cloudflare. Apply the AOP
TLSOptionto the dev Ingress too, or allow 80/443 only from Cloudflare ranges once every host is proxied. - Medium: node IP published by DNS-only admin hosts. Proxy the admin hosts, or move them behind Access through the Tunnel and drop their public records.
- Medium: docs
*.pages.devhostname outside Access. Add it to thedocsAccess app'sdestinations. - Medium: east-west and egress gaps. Add ingress policies for Loki and monitoring, and a default-deny egress policy per app namespace.
- Medium: tailnet access is all-or-nothing. Grant 22/6443 to a named group, and manage device approval in
tailscale_tailnet_settings. - Low: edge protection is Free-plan coarse. The rate limit counts in 10s windows, rules cannot use regex, and WAF events are visible only in the dashboard. Revisit Pro if credential stuffing or scanner volume grows past what the app layer absorbs.
- Low: shared origin-pull CA. Move to a per-zone AOP certificate.
- Low: Ingress host and ExternalName freedom. Extend
policy/to tie hosts to namespaces, and turn offallowExternalNameServicesunless a route needs it. - Low: loki-push token expiry. Alert before the Access service token expires.