Cleaning up the cloud account

2026-12-03来源 dev.toEnglish

A cloud account grows over time. A test here, a tunnel for an experiment, a DNS record that was meant to go afterwards. None of it is dangerous when it is created. The problem is what is left behind when nobody remembers why it exists. I went through my Cloudflare account properly and found exactly one of those.

Read everything through the API, not the dashboard

A dashboard shows what you click on. An API shows everything. I started with a read-only token and a small script that listed it all: DNS records in both domains, tunnels and the hostnames they answer, access rules, Workers and security settings. The result was compared line by line with my own documentation.

The finding: an address nobody protected

A tunnel that publishes a service also answered one more hostname, left over from an old experiment. That hostname led straight to the server's SSH, with no login in front of it. The server only accepted keys, so nobody could get in. But the path went around the server's firewall and appeared in no documentation. It also made failed login attempts look as if they came from the server itself, so the protection that locks out password guessers never saw them.

I tested the path myself before removing it, and again afterwards to confirm it was closed. Leftovers from the same experiment went with it: two DNS records, an access rule and a tunnel that had not been up for months.

# Before: the forgotten hostname, through Cloudflare's client $ ssh -o ProxyCommand="cloudflared access ssh --hostname %h" probe@<forgotten-host> Authentications that can continue: publickey probe@<forgotten-host>: Permission denied (publickey). ← the server answered # After: DNS record removed $ ssh -o ProxyCommand="cloudflared access ssh --hostname %h" probe@<forgotten-host> Connection closed by UNKNOWN port 65535 ← the path is closed 

Real output from the test before and after. The hostname is redacted.

Tightening what remains

  • Always HTTPS and at least TLS 1.2 on both domains.
  • DNSSEC on the domain that lacked it.
  • A firewall rule that stops scanners looking for WordPress, .env files and the like. The site is static, so none of that exists, but they made up more than half of all traffic.
  • Protection against known bad bots, while search engines are still let in.
$ for p in / /wp-login.php /.env /xmlrpc.php; do curl -s -A "$BROWSER_UA" -o /dev/null -w "%{http_code} $p\n" https://veljkoradan.com$p; done 200 / 403 /wp-login.php 403 /.env 403 /xmlrpc.php 

After the firewall rule: the site answers, the scanners' favourite paths are blocked.

A mistake I made, and learned from

I turned on HSTS in Cloudflare for the website, a setting that tells browsers to use HTTPS only. It seemed obvious. But the site already sent its own HSTS header, which was stricter and lasted longer. Cloudflare's setting overrode it with a weaker one. I caught it later the same day and turned the setting off. The lesson: check what already applies before you "improve" something.

How changes are made now

  • Reading is free. Every change is shown first and approved, and the script refuses to change anything without an explicit flag.
  • Every change is logged.
  • The token only works from a single server and expires after 90 days.
  • The full state was saved before the changes, so everything can be restored.
  • A small script checks every day that the tunnel is up, that certificates and domains are not about to expire and that the sites answer, and only alerts when something changes.

The most dangerous thing in an account is rarely what you just set up. It is what you forgot to remove.

Originally published at veljkoradan.com.

原文:https://www.a8q9.cn/en/article/cleaning-up-the-cloud-account-79a2a1.html

相关文章