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:

  1. 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).
  2. 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.

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 Referer Header Leakage: If the target HTML page loads an external script, image, or link without a strict Referrer-Policy: no-referrer header, the browser sends the full URL (including query parameters) in the Referer header 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.


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs