
Implementing Cloudflare Zero Trust to Defend Against OSINT Leaks
Overview
Although I was using Cloudflare Proxy, there was an issue where the Origin IP and port information were exposed to OSINT (Open Source Intelligence) search engines such as Censys and Shodan.
After identifying the cause, I blocked direct access to the Origin, made management ports private, and even configured ZTNA based on Cloudflare Tunnel.
Problem Analysis
Although the service was running through Cloudflare, the Origin IP, rather than the Proxy IP, was identified in OSINT search engines.
Root Cause Analysis
The reasons for the server's IP exposure were as follows:
- TLS certificate exposure
- Scanners like Censys continuously scan public IPs on the internet.
- When directly connecting to port 443 of the Origin IP, Nginx was returning the actual service certificate.
- The IP and domain could be correlated through the SAN (Subject Alternative Name) of the certificate, etc.
- Inadequate inbound firewall policy (firewall settings for ports 80 and 443 were not configured, allowing access that bypassed the proxy)
Nginx Security Hardening
Configure Nginx not to unnecessarily return the actual certificate upon direct IP-based access.
SSL Handshake Rejection Configuration
ssl_reject_handshake is supported in Nginx 1.19.4 and later.
First, check the version.
File: /etc/nginx/sites-available/default
This setting is used to reject TLS handshakes coming into the default server.
If an attacker specifies the actual domain as the SNI, the legitimate server block can be selected, so this alone cannot block Origin access.
Firewall Policy Changes
Automatically update the inbound access list in preparation for changes to Cloudflare IP ranges.
File: cloudflare_ip_update.sh
Since issues may arise where you cannot access the server due to script errors or other unavoidable reasons, it is recommended to manage SSH port 22 directly from the instance management dashboard.
These days, we wash computers, not just characters

@Binci
Replacing the Public IP
Return the existing public IP and get a new ephemeral IP allocated.
Regenerating SSH Host Keys
This is not strictly necessary if there is no actual key leakage, but it was changed to prevent fingerprinting.
Zero Trust Network Access
Now, access via Cloudflare Tunnel instead of directly exposing to the public internet.
Installing cloudflared

Create a tunnel in the Cloudflare One Dashboard and obtain a token.
Check after installation.
Configuring Split Tunnels and Private Networks

First, check the server's IP.
Example:
The private IPv4 ranges are as follows:
Private IP Ranges
10.0.0.0/8172.16.0.0/12192.168.0.0/16
Team & Resources/Devices > Devices > Device profiles > Profile > Split Tunnels

If the private network range you want to access is included in Exclude, adjust the range.

Networks/Routes > Routes > CIDR Routes
Add the private network.

Access
After installing the Cloudflare One Agent (WARP Client), log in to the team domain used during configuration.
