Cloud & Backend Engineer Security Guide: What HTTPS/TLS Actually Encrypts in a URL
A surprisingly common misconception among developers is either believing that "HTTPS leaves the URL path and query parameters in plain text over the wire" OR, conversely, assuming that "because HTTPS encrypts the URL path, putting API keys and session tokens in ?token=... query strings is completely safe." Both beliefs are dangerously incomplete. As a Senior Cloud Engineer and Backend Engineer, let's break down exactly what happens at the packet level during a TLS 1.3 connection and how to architect leak-free web and API endpoints.
1. Over the Wire: What Network Observers See vs. What TLS Encrypts
When a client connects to https://api.example.com/v1/patients/9481?include=labs, the connection proceeds in two distinct phases:
- Before the TLS Session Is Established (Visible to ISPs, Wi-Fi Routers & Firewalls):
- The destination IP address and TCP port (
443). - The domain hostname (
api.example.com) via DNS lookup and the TLS Server Name Indication (SNI) extension (unless Encrypted Client Hello / ECH is negotiated).
- The destination IP address and TCP port (
- Inside the Encrypted TLS Tunnel (100% Encrypted Over the Wire):
- The HTTP method (
GET,POST). - The full URL path (
/v1/patients/9481) and query string (?include=labs). They are sent inside the HTTP request line after the TLS cryptographic handshake completes. - All HTTP headers (
Authorization,Cookie) and the request/response body.
- The HTTP method (
2. Why Putting Secrets in HTTPS Query Strings Still Causes Severe Data Leaks
If TLS encrypts the URL path and query string in transit, why is passing ?api_key=sk_live_... or ?reset_token=... in a URL still a critical security vulnerability (CWE-598)? Because URLs are logged and persisted in plain text at both ends of the TLS tunnel:
- Reverse Proxy, Load Balancer & CDN Access Logs: Nginx, AWS ALB, CloudFront, and Google Cloud Load Balancing log the full request URI by default into log buckets readable by operations teams and third-party SIEM tools.
- Browser History & Shoulder Surfing: Query strings remain visible in the address bar and sync across devices in browser history.
- Third-Party
RefererHeader Leakage: If the target HTML page loads an external script, image, or link without a strictReferrer-Policy: no-referrerheader, the browser sends the full URL (including query parameters) in theRefererheader to third-party servers.
3. Defense-in-Depth: Redacting Sensitive Query Params & Enforcing POST/Header Tokens
In production Django, FastAPI, and Go backends, I enforce strict header-based authentication (Authorization: Bearer ...), immediately exchange one-time email verification links for an HttpOnly; Secure; SameSite=Lax session via a 303 See Other redirect that strips the token from the browser URL bar, and configure strict security headers:
class SecurityHeadersAndTokenStripMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
response["Strict-Transport-Security"] = "max-age=63072000; includeSubDomains; preload"
response["Referrer-Policy"] = "strict-origin-when-cross-origin"
response["X-Content-Type-Options"] = "nosniff"
return response
4. Hire a Senior Cloud & Backend Engineer for Security Architecture
Need a security audit of your cloud load balancers, TLS termination, or API authentication flows? Explore my Cloud Engineer Pillar Guide, review my Backend Engineer Guide, or book a 1-Day Security & Cloud Audit Sprint.