Skip to content

fix(cloudflared): stop logging the tunnel token - #3152

Merged
MichielMak merged 1 commit into
mainfrom
fix/cloudflared-token-in-logs
Oct 25, 2026
Merged

MichielMak merged 1 commit into
mainfrom
fix/cloudflared-token-in-logs

Conversation

@michiel-claude

Copy link
Copy Markdown
Contributor

Why

The wisdomsky/cloudflared-web image logs its full cloudflared command line at startup, tunnel token included. Anyone who can read container logs (Komodo, Docker tools, log shippers) could see it.

What changed

  • Image is now the official cloudflare/cloudflared:2026.10.3, pinned by digest.
  • It runs tunnel --no-autoupdate run and reads the token from the TUNNEL_TOKEN environment variable. cloudflared does not print that value.
  • TUNNEL_TOKEN comes from cloudflared/secrets.sops.env through the existing sops wrapper in stacks.toml.
  • Removed the web UI: its Traefik router, the /config volume and the homepage link. The homepage cloudflared widget stays, it only uses the Cloudflare API.
  • The tunnel stays remotely managed. Ingress rules come from Cloudflare (cloudflare/ OpenTofu), so no local config is needed.

Manual steps (before or right after merging)

  1. Add the token to SOPS: sops cloudflared/secrets.sops.env, add a TUNNEL_TOKEN= line with the current tunnel token, commit. Without this the tunnel will not start. The file doesn't have this key yet; the token was stored in the web UI's /config.
  2. Merge. Gitops redeploys the stack because compose.yaml changed. Check in Komodo that it deployed and that the logs show Registered tunnel connection. If it didn't redeploy, deploy the stack by hand.
  3. Rotate the tunnel token, because it was exposed in logs: Cloudflare dashboard → Zero Trust → Networks → Tunnels → the tunnel → refresh/rotate token.
  4. Put the new token in SOPS (sops cloudflared/secrets.sops.env), commit, then deploy the cloudflared stack by hand (a secrets-only change does not trigger Gitops).
  5. Optional: delete the old web UI data in ${DOCKER_DATA_DIR}/cloudflared/config (it holds the old token).

Remaining risk: Plex tokens

cloudflared also logged failed requests with their full URL, and Plex puts X-Plex-Token in the query string. These lines are logged at error level, so lowering the log level doesn't hide them without hiding real errors too. This PR doesn't fix that.

The Plex token was already in the logs. Rotating it means Plex → Settings → Devices → "Sign out of all devices", which logs out every client. That's your call.

🤖 Generated with Claude Code

Switch from wisdomsky/cloudflared-web to the official cloudflare/cloudflared
image. The web UI wrapper printed the full command line, tunnel token
included, to the container logs. The token now comes from TUNNEL_TOKEN in
secrets.sops.env, which cloudflared does not log.

This drops the web UI, its Traefik router and the homepage link. The
homepage widget stays: it only uses the Cloudflare API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🛡️ Trivy image scan — fixable HIGH/CRITICAL vulnerabilities found

The images below have known vulnerabilities with fixes available. Update to a patched image (digest) before merging.

cloudflare/cloudflared:2026.10.3@sha256:faa8e0a1475f137c910be6025f43c8e4092fdd35461b31e19fd1390657a1ff39

0 CRITICAL, 1 HIGH fixable vulnerabilities

CVE Package Installed Fixed Severity
CVE-2026-63209 github.com/klauspost/compress v1.18.0 1.18.7 HIGH

@MichielMak
MichielMak enabled auto-merge (squash) October 25, 2026 22:38
@MichielMak
MichielMak merged commit 6575fa1 into main Oct 25, 2026
2 of 3 checks passed
@MichielMak
MichielMak deleted the fix/cloudflared-token-in-logs branch October 25, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant