The independent reviews of #316 found four follow-ups that were left out of that PR on purpose. To keep the role a drop-in replacement, #316 renders config.yml, the credentials file and the unit byte-identically to the role it was ported from. Each of the items below changes a rendered file, so on an existing host each one restarts the tunnel once.
The unit lets cloudflared update itself, and it is not hardened. The unit in tasks/configure.yml runs cloudflared tunnel ... run without --no-autoupdate, while the unit from upstream cloudflared service install does pass it. So cloudflared tries to update itself every day. Today that fails noisily: the binary belongs to root and the service user cannot write it. If it ever could write it, the update would bypass the role's sha256-pinned update path (_binary_update). The unit also has no sandboxing directives (NoNewPrivileges, ProtectSystem, ProtectHome, PrivateTmp, CapabilityBoundingSet=, and so on), and it orders on network.target rather than network-online.target.
The daemon owns its own config and credentials.config.yml, the tunnel credentials file and the config directory belong to the cloudflared service user (tasks/prereqs.yml, tasks/configure.yml). A compromised daemon could therefore rewrite its own ingress rules and credentials.
Ingress hostnames are rendered unquoted.templates/config.yml.j2 writes hostname: and service: as plain scalars. A wildcard hostname such as *.example.com, which Cloudflare supports, then parses as a YAML alias, and ingress validate and the daemon reject the file. validate.yml already accepts a leading *., so the role lets an input through that its template then breaks.
The DNS lookup per hostname reads one page only. The overwrite guard queries dns_records?name=<hostname> and reads only the first page, 100 records. The prune listing already pages through result_info.total_pages. In practice one name rarely has more than 100 records, so this is low risk, but it is inconsistent.
Proposal
Add --no-autoupdate to ExecStart. Add hardening directives that cloudflared tolerates: it needs outbound network access and read access to its config directory, and nothing else. Use After=network-online.target together with Wants=network-online.target. Update the stub's argv parsing and the ExecStart search in molecule/default.
Make root:<cloudflared_group> the owner, with files at 0640 and the directory at 0750. The service reads them through its group.
Render each ingress value with | to_json, which is valid YAML, or render the whole ingress list with to_nice_yaml. Add a wildcard ingress entry to the molecule scenario.
Follow result_info.total_pages in the per-hostname lookup, as the prune does. Extend the API stub to page.
Each item changes rendered output, and the first apply restarts the daemon once. Say so in the changelog fragment, so that a consumer can schedule it.
Open question for triage: one PR, or two? For example items 1–2 (security), then items 3–4 (robustness).
Acceptance criteria
The unit has --no-autoupdate, the agreed hardening directives and network-online.target ordering. systemd-analyze verify passes on the scenario.
Config, credentials and directory belong to root, readable by the service group (0640 files, 0750 directory). The daemon still starts and validates its config.
A wildcard ingress hostname renders, passes ingress validate and is covered in molecule/default.
The per-hostname DNS lookup pages, and the stub serves more than one page in at least one case.
Changelog fragment (minor_changes) that names the one restart on upgrade.
Assisted-by: Claude Code:claude-opus-5-5
## Problem
The independent reviews of #316 found four follow-ups that were left out of that PR on purpose. To keep the role a drop-in replacement, #316 renders `config.yml`, the credentials file and the unit byte-identically to the role it was ported from. Each of the items below changes a rendered file, so on an existing host each one restarts the tunnel once.
1. **The unit lets cloudflared update itself, and it is not hardened.** The unit in `tasks/configure.yml` runs `cloudflared tunnel ... run` without `--no-autoupdate`, while the unit from upstream `cloudflared service install` does pass it. So cloudflared tries to update itself every day. Today that fails noisily: the binary belongs to root and the service user cannot write it. If it ever could write it, the update would bypass the role's sha256-pinned update path (`_binary_update`). The unit also has no sandboxing directives (`NoNewPrivileges`, `ProtectSystem`, `ProtectHome`, `PrivateTmp`, `CapabilityBoundingSet=`, and so on), and it orders on `network.target` rather than `network-online.target`.
2. **The daemon owns its own config and credentials.** `config.yml`, the tunnel credentials file and the config directory belong to the `cloudflared` service user (`tasks/prereqs.yml`, `tasks/configure.yml`). A compromised daemon could therefore rewrite its own ingress rules and credentials.
3. **Ingress hostnames are rendered unquoted.** `templates/config.yml.j2` writes `hostname:` and `service:` as plain scalars. A wildcard hostname such as `*.example.com`, which Cloudflare supports, then parses as a YAML alias, and `ingress validate` and the daemon reject the file. `validate.yml` already accepts a leading `*.`, so the role lets an input through that its template then breaks.
4. **The DNS lookup per hostname reads one page only.** The overwrite guard queries `dns_records?name=<hostname>` and reads only the first page, 100 records. The prune listing already pages through `result_info.total_pages`. In practice one name rarely has more than 100 records, so this is low risk, but it is inconsistent.
## Proposal
1. Add `--no-autoupdate` to `ExecStart`. Add hardening directives that cloudflared tolerates: it needs outbound network access and read access to its config directory, and nothing else. Use `After=network-online.target` together with `Wants=network-online.target`. Update the stub's argv parsing and the `ExecStart` search in `molecule/default`.
2. Make `root:<cloudflared_group>` the owner, with files at `0640` and the directory at `0750`. The service reads them through its group.
3. Render each ingress value with `| to_json`, which is valid YAML, or render the whole ingress list with `to_nice_yaml`. Add a wildcard ingress entry to the molecule scenario.
4. Follow `result_info.total_pages` in the per-hostname lookup, as the prune does. Extend the API stub to page.
Each item changes rendered output, and the first apply restarts the daemon once. Say so in the changelog fragment, so that a consumer can schedule it.
Open question for triage: one PR, or two? For example items 1–2 (security), then items 3–4 (robustness).
## Acceptance criteria
- [ ] The unit has `--no-autoupdate`, the agreed hardening directives and `network-online.target` ordering. `systemd-analyze verify` passes on the scenario.
- [ ] Config, credentials and directory belong to root, readable by the service group (`0640` files, `0750` directory). The daemon still starts and validates its config.
- [ ] A wildcard ingress hostname renders, passes `ingress validate` and is covered in `molecule/default`.
- [ ] The per-hostname DNS lookup pages, and the stub serves more than one page in at least one case.
- [ ] Changelog fragment (`minor_changes`) that names the one restart on upgrade.
Assisted-by: Claude Code:claude-opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
The independent reviews of #316 found four follow-ups that were left out of that PR on purpose. To keep the role a drop-in replacement, #316 renders
config.yml, the credentials file and the unit byte-identically to the role it was ported from. Each of the items below changes a rendered file, so on an existing host each one restarts the tunnel once.tasks/configure.ymlrunscloudflared tunnel ... runwithout--no-autoupdate, while the unit from upstreamcloudflared service installdoes pass it. So cloudflared tries to update itself every day. Today that fails noisily: the binary belongs to root and the service user cannot write it. If it ever could write it, the update would bypass the role's sha256-pinned update path (_binary_update). The unit also has no sandboxing directives (NoNewPrivileges,ProtectSystem,ProtectHome,PrivateTmp,CapabilityBoundingSet=, and so on), and it orders onnetwork.targetrather thannetwork-online.target.config.yml, the tunnel credentials file and the config directory belong to thecloudflaredservice user (tasks/prereqs.yml,tasks/configure.yml). A compromised daemon could therefore rewrite its own ingress rules and credentials.templates/config.yml.j2writeshostname:andservice:as plain scalars. A wildcard hostname such as*.example.com, which Cloudflare supports, then parses as a YAML alias, andingress validateand the daemon reject the file.validate.ymlalready accepts a leading*., so the role lets an input through that its template then breaks.dns_records?name=<hostname>and reads only the first page, 100 records. The prune listing already pages throughresult_info.total_pages. In practice one name rarely has more than 100 records, so this is low risk, but it is inconsistent.Proposal
--no-autoupdatetoExecStart. Add hardening directives that cloudflared tolerates: it needs outbound network access and read access to its config directory, and nothing else. UseAfter=network-online.targettogether withWants=network-online.target. Update the stub's argv parsing and theExecStartsearch inmolecule/default.root:<cloudflared_group>the owner, with files at0640and the directory at0750. The service reads them through its group.| to_json, which is valid YAML, or render the whole ingress list withto_nice_yaml. Add a wildcard ingress entry to the molecule scenario.result_info.total_pagesin the per-hostname lookup, as the prune does. Extend the API stub to page.Each item changes rendered output, and the first apply restarts the daemon once. Say so in the changelog fragment, so that a consumer can schedule it.
Open question for triage: one PR, or two? For example items 1–2 (security), then items 3–4 (robustness).
Acceptance criteria
--no-autoupdate, the agreed hardening directives andnetwork-online.targetordering.systemd-analyze verifypasses on the scenario.0640files,0750directory). The daemon still starts and validates its config.ingress validateand is covered inmolecule/default.minor_changes) that names the one restart on upgrade.Assisted-by: Claude Code:claude-opus-5-5