T06 · System Persistence
- Location
scripts/tunnel_service_install.sh:4- Finding
Persistent System-Wide Cloudflare Tunnel Service
- Content
View full analysis
'" >&2 exit 2 fi TOKEN="$1" sudo cloudflared service install "$TOKEN" # Ensure it's running sudo systemctl enable --now cloudflared sudo systemctl is-active cloudflared ``` ### Technical Analysis The script invokes `cloudflared service install` through `sudo`, creating a system-wide service using the supplied tunnel token. It then explicitly executes `systemctl enable --now cloudflared`, which starts the service immediately and configures it to start automatically after future reboots. An always-on service is consistent with the declared goal of operating a persistent Cloudflare Tunnel. However, cross-session persistence is not required for a temporary tunnel session, and the script offers no foreground or non-persistent alternative. It also performs the privileged registration without an explicit confirmation describing the persistence and credential-storage effects. Because tunnel routing is managed through the corresponding Cloudflare configuration, installing a token supplied by an untrusted party could connect the host persistently to an externally controlled tunnel. The service would continue operating after the initiating shell or agent session ends. ### Attack Path 1. An attacker supplies a tunnel token associated with a tunnel or Cloudflare configuration under the attacker’s control, or convinces the operator to use such a token. 2. The operator runs the documented installer with root privileges. 3. `cloudflared service install` stores the tunnel configuration or credential and registers a system service. 4. `systemctl enable --now cloudflared` immediately starts the connector and enables it across reboots. 5. The attacker configures the associated t ...[truncated 1020 chars]- Remediation
View remediation
