New research has revealed that threat actors are abusing Cloudflare Tunnels to establish covert communication channels from compromised hosts and retain persistent access.
“Cloudflared is functionally very similar to ngrok,” Nic Finn, a senior threat intelligence analyst at GuidePoint Security, said. “However, Cloudflared differs from ngrok in that it provides a lot more usability for free, including the ability to host TCP connectivity over cloudflared.”
A command-line tool for Cloudflare Tunnel, cloudflared allows users to create secure connections between an origin web server and Cloudflare’s nearest data center so as to hide the web server IP addresses as well as block volumetric distributed denial-of-service (DDoS) and brute-force login attacks.
![Cybersecurity](https://thehackernews.com/new-images/img/b/R29vZ2xl/AVvXsEiltwxN6CgTsOwvK4Kb9RC48ffApMCcXD3j2Gc3db9P1-x8PHByrz3vE32zvTg2ob2gKgFCjZBxfrCvkNyecbAPGYBfbb0Tj5AljTS_uYaanG6sEjZCK8NhoD2rHwk-Eh24yrpazpnZZiKsiHdbNkq2XVUeD-T-sZ2yW29dfOwyrVq3f31mu0hw25FnVzTn/s728-e3650/3.png)
For a threat actor with elevated access on an infected host, this feature presents a lucrative approach to set up a foothold by generating a token required to establish the tunnel from the victim machine.
“The tunnel updates as soon as the configuration change is made in the Cloudflare Dashboard, allowing TAs to enable functionality only when they want to conduct activities on the victim machine, then disable functionality to prevent exposure of their infrastructure,” Finn explained.
![](https://thehackernews.com/new-images/img/b/R29vZ2xl/AVvXsEj33906InMhFQp15r_pgpkgmSVZVNo4E_HBK9eQThf2XkrtrtVtwak4S-TjU-rBtvTjISn31Fz_3xriytw0bYMVaN2tHzWVBcWkTJ5-6BdYEu5pR-05IEoW_NmXZqzg9d6gzepT3g2ky9Mq5tS56UcP3YP1ROpNluEfoJX-44dHWj9EjQkPLhjQqVV93hFg/s728-e365/Cf.jpg)
“For example, the TA could enable RDP connectivity, collect information from the victim machine, then disable RDP until the following day, thus lowering the chance of detection or the ability to observe the domain utilized to establish the connection.”
Even more troublingly, the adversary could take advantage of the tunnel’s Private Networks functionality to stealthily access an range of IP addresses (i.e., endpoints within a local network) as if they were “physically collocated with the victim machine hosting the tunnel.”
![Cybersecurity](https://thehackernews.com/new-images/img/b/R29vZ2xl/AVvXsEgNmNiBV8c8Rp0Xy6N9lCX9JL2cBlrjkSeuW4JhgOVQ3mKTsYV4pPvh3nDz32D97D8XcWQ53EJ1p4n2VX0gZH_YrBZBqElUMfzFWgb50P8lv1iac_1f-p5liZzC1ISVWJygv2s1Qm36rOHwk_kPXUNNT3nbSDr144QYZ6XGq0aXRDOrFfSlUnHnc0x4Fe_F/s728-e3650/cis-d.gif)
That said, the technique has already found takers in the wild. Earlier this year, Phylum and Kroll detailed two different software supply chain attacks targeting the Python Package Index (PyPI) repository in which fraudulent packages were observed downloading cloudflared to remotely access the endpoint via a Flask web application.
“Organizations using Cloudflare services legitimately could potentially limit their services to specific data centers and generate detections for traffic like Cloudflared tunnels that route to anywhere except their specified data centers,” Finn said. “This method might aid in the detection of unauthorized tunnels.”
To identify possible misuse of cloudflared, it’s recommended that organizations implement adequate logging mechanisms to monitor for anomalous commands, DNS queries, and outbound connections, alongside blocking attempts to download the executable.