Why a hacker needs the full picture
Every web vulnerability lives somewhere in a chain of components. A request leaves your browser, crosses several networks, passes through machines you never see, reaches an application, touches a database, and comes back. A bug in any link of that chain can become a finding: a DNS record that points at a forgotten server, a proxy that parses a request differently from the application behind it, a cache that stores a page it should not, a database query built from raw user input.
Beginners often treat "the website" as one box. Professionals see a pipeline, and they ask at each stage: who is parsing this, what do they trust, and do they agree with the next stage? Many of the most valuable bugs (request smuggling, cache poisoning, SSRF, host header attacks) exist only because two components in the pipeline disagree about the same bytes.
This lesson walks the whole pipeline once, end to end. Later lessons zoom into HTTP, cookies, encodings and the browser security model.
Clients and servers
The web is a client/server system.
- The client starts the conversation. Usually it is a browser, but it can be
curl, a mobile app, a script, a search-engine crawler, or your proxy. - The server waits for requests and answers them. "Server" can mean a physical machine, a virtual machine, a container, or just a process listening on a port.
Two facts matter for security:
- The client is under the attacker's control. Anything the browser enforces (hidden form fields, disabled buttons, JavaScript validation, maximum lengths) is a convenience, not a defense. An attacker can send any bytes they like with
curlor a proxy. The server must validate everything. - The server decides what is true. Authentication, authorization, prices, quantities and permissions must be decided server-side from data the client cannot forge.
Anatomy of a URL
A URL (Uniform Resource Locator) tells the client where a resource lives and how to talk to it:
https://alice:[email protected]:8443/products/view?id=42&lang=en#reviews
\___/ \_________/ \_______________/ \__/\____________/ \___________/ \______/
scheme userinfo host port path query fragment
| Part | Meaning | Security notes |
|---|---|---|
| scheme | Protocol: http, https, ftp, file, javascript, data... |
Dangerous schemes (javascript:) in links and redirects lead to XSS. Schemes drive SSRF filters (file://, gopher://). |
| userinfo | Optional credentials (deprecated) | Used in phishing: https://[email protected]/ really goes to evil.com. |
| host | Domain name or IP address | Basis of the origin and of cookie scope. Many filter bypasses abuse host parsing. |
| port | TCP port; defaults to 80 for http and 443 for https | Part of the origin. |
| path | Which resource | Path traversal (../), access control by path, parser differentials. |
| query | key=value pairs after ? |
The most common injection point. |
| fragment | After #; never sent to the server |
Processed only by browser JavaScript, so DOM XSS often lives here. |
The fragment never appears in the HTTP request. If you look for it in your proxy history you will not find it, which is why you must read the client-side JavaScript when testing DOM-based bugs.
Step 1: DNS, turning names into addresses
Computers route packets using IP addresses, but people use names. The Domain Name System translates shop.example.com into an address such as 93.184.216.34 (IPv4) or an IPv6 address.
A lookup walks a hierarchy:
- The browser checks its own cache, then the operating system cache and the
hostsfile (/etc/hostson Linux and macOS,C:\Windows\System32\drivers\etc\hostson Windows). - If nothing is cached, the OS asks a recursive resolver, typically from your ISP or a public service.
- The resolver asks a root server which servers handle
.com, then the.comTLD server which servers are authoritative forexample.com, then the authoritative name server, which gives the final answer. - The answer comes with a TTL (time to live) saying how long it may be cached.
Common record types:
| Type | Purpose |
|---|---|
A / AAAA |
Name to IPv4 / IPv6 address |
CNAME |
Alias from one name to another name |
MX |
Mail servers for the domain |
TXT |
Free text: SPF, DKIM, domain verification tokens |
NS |
Authoritative name servers |
You can query DNS yourself:
nslookup shop.example.com
dig +short A shop.example.com
dig +short CNAME shop.example.com
dig NS example.com
Security relevance
- Subdomain takeover. If
blog.example.comhas aCNAMEpointing to a third-party service where the account was deleted, an attacker can claim that resource and serve content on your domain. - DNS rebinding. An attacker-controlled name alternates between a public IP and an internal one with a very short TTL, tricking a browser or a server-side fetcher into reaching internal hosts.
- Reconnaissance. Enumerating subdomains reveals forgotten staging servers, admin panels and APIs: often the softest targets.
- Spoofing and hijacking. Poisoned caches or compromised registrar accounts redirect users to attacker servers, which is one reason TLS certificates matter.
Step 2: TCP/IP, reliable delivery
With an IP address, the client opens a TCP connection. The Internet Protocol (IP) moves packets between machines on a best-effort basis; the Transmission Control Protocol (TCP) sits on top and provides an ordered, reliable byte stream between two ports. A port number identifies a service on a machine: 80 for HTTP, 443 for HTTPS, 22 for SSH, 5432 for PostgreSQL, 3306 for MySQL, 6379 for Redis.
A connection starts with the three-way handshake:
Client -- SYN --> Server
Client <-- SYN/ACK -- Server
Client -- ACK --> Server (connection established)
Why you should care:
- Each handshake costs a network round trip, which is why browsers reuse connections (keep-alive) and why HTTP/2 and HTTP/3 multiplex many requests over one connection.
- A port scan simply tries handshakes to see which ports answer. Exposed databases and admin interfaces found this way are a classic finding.
- When two components share one TCP connection and disagree about where a request ends, you get request smuggling.
- The 5-tuple (source IP, source port, destination IP, destination port, protocol) identifies a connection. Servers behind proxies often see the proxy's address instead of yours, which is why headers like
X-Forwarded-Forexist (and why trusting them blindly is a bug).
TCP carries bytes, not meaning. What those bytes mean depends on the application protocol on top, here HTTP.
Step 3: TLS, making HTTP private
Plain HTTP is readable and modifiable by anyone on the path: the coffee-shop Wi-Fi, your ISP, a compromised router. HTTPS is HTTP inside a TLS (Transport Layer Security) tunnel. TLS provides three properties:
- Confidentiality: eavesdroppers see only encrypted data.
- Integrity: tampering is detected.
- Authentication: the client verifies it is talking to the real server, using an X.509 certificate.
A simplified TLS 1.3 handshake:
- The client sends
ClientHellowith supported cipher suites, a key share and the SNI (Server Name Indication), the hostname it wants, sent so a server hosting many sites can pick the right certificate. - The server answers with its key share and its certificate chain.
- The client validates the chain: is it signed by a certificate authority (CA) the OS or browser trusts, does the name match, is it within its validity dates, is it not revoked?
- Both sides derive symmetric session keys and the rest of the conversation is encrypted.
A certificate is only as trustworthy as the CAs your device trusts. That is exactly why, later in this chapter, you will install your proxy's own CA certificate in your browser: it lets the proxy decrypt your own traffic so you can inspect it. Doing that on someone else's device without consent would be an attack.
You can see TLS in action:
curl -v https://example.com 2>&1 | head -40
openssl s_client -connect example.com:443 -servername example.com </dev/null | openssl x509 -noout -subject -issuer -dates
Security relevance: missing HTTPS or mixed content, absent HSTS (the Strict-Transport-Security header that tells browsers to always use HTTPS), expired or mismatched certificates, weak or legacy protocol versions, and cookies without the Secure flag. TLS protects data in transit only; it does nothing against SQL injection or XSS, which arrive inside a perfectly encrypted request.
Step 4: HTTP, the conversation
Once the tunnel exists, the client sends an HTTP request and the server returns an HTTP response. HTTP is a stateless, text-based (in version 1.1) request/response protocol. The next lesson dissects it fully; here is a minimal exchange so you can see the shape:
GET /products/view?id=42 HTTP/1.1
Host: shop.example.com
User-Agent: Mozilla/5.0
Accept: text/html
Cookie: session=9f8e7d6c
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Set-Cookie: cart=3; Secure; HttpOnly
Cache-Control: no-store
<!doctype html><html>...
"Stateless" means each request is independent. The server does not inherently remember you between requests; cookies and tokens are layered on top to create the illusion of a session (see the cookies lesson).
Step 5: What happens on the server side
The word "server" hides a stack. A modern production request often passes through several layers:
Browser -> CDN / edge cache -> WAF -> load balancer -> reverse proxy
-> application server -> (cache, queue, other services) -> database
Web servers
A web server (nginx, Apache httpd, Microsoft IIS, Caddy) accepts connections, parses HTTP, and either serves static files (images, CSS, JavaScript) directly from disk or forwards the request to an application. Its configuration decides things like which directories are exposed, whether directory listings are on, and which headers are added.
Application servers and frameworks
The application server runs the business logic: Node.js with Express, Python with Django or Flask, PHP-FPM, Ruby on Rails, Java with Spring or Tomcat, ASP.NET. It receives a parsed request, runs routing (which code handles this path and method), authenticates the user, executes logic, and builds a response. Most of the vulnerabilities you will study (injection, broken access control, logic flaws) live here.
Databases
Applications persist data in databases: relational (PostgreSQL, MySQL, SQL Server, SQLite) or NoSQL (MongoDB, Redis, Elasticsearch). The application builds queries from request data. If it concatenates untrusted input into the query, you get SQL injection or NoSQL injection. Databases should never be reachable from the internet, but misconfigurations happen.
Reverse proxies and load balancers
A reverse proxy sits in front of one or more application servers. It terminates TLS, balances load, compresses, rate limits, caches, and rewrites headers. The application usually trusts what the proxy tells it (for example X-Forwarded-For, X-Forwarded-Proto, Host). Problems arise when:
- Two proxies and the application parse the same request differently (smuggling, path normalization tricks such as
/admin;/xor/%2e%2e/). - The application trusts a header the client could have set because the proxy did not strip it.
- A "internal only" path is blocked at the proxy but reachable by encoding or normalization differences.
CDNs and caches
A content delivery network (Cloudflare, Akamai, Fastly, CloudFront) places servers around the world to serve cached copies of content close to users. It reduces latency and absorbs attacks. The CDN decides, using a cache key (usually method, host, path and some of the query), whether two requests deserve the same stored response. If the key ignores something that changes the response (a header, a cookie), an attacker may poison the cache or make it store one user's private page for everyone: web cache poisoning and web cache deception.
Web application firewalls
A WAF inspects requests for known attack patterns. It is a speed bump, not a fix: encodings, parser differentials and alternative syntax regularly bypass it, which is why the encoding lesson matters.
Step 6: The browser renders the response
The response body is HTML. The browser parses it into the DOM (Document Object Model), then discovers more resources (CSS, scripts, images, fonts, fetches) and issues more requests, often to other origins (analytics, CDNs, ad networks, APIs). JavaScript then runs and can modify the DOM, call APIs with fetch, and store data in cookies, localStorage and IndexedDB.
Two consequences:
- A single page view is dozens of requests. Your proxy history will show all of them; the interesting ones are usually API calls (
/api/...) triggered by scripts. - What you see in "View source" (the original response) can differ from the live DOM after scripts run. XSS is about what ends up in the live DOM and gets executed.
The full request lifecycle
Putting it together for https://shop.example.com/products/view?id=42:
- The browser parses the URL and checks caches (HSTS list, HTTP cache, service workers).
- DNS resolves
shop.example.comto an IP (probably a CDN edge). - TCP handshake to port 443 (or QUIC/UDP for HTTP/3).
- TLS handshake, certificate validation.
- The browser sends the HTTP request with cookies for that site.
- The CDN checks its cache; on a miss it forwards to the origin through a load balancer and reverse proxy.
- The application authenticates the cookie, runs the handler, queries the database, renders a response.
- The response travels back, possibly being stored by the CDN and the browser cache.
- The browser parses HTML, fetches sub-resources (repeating steps 2 to 8 for other hosts), runs scripts and paints the page.
Now ask, for each step: what could I influence, and who trusts that influence? That is the attacker's mindset in one sentence.
Where the attacks live
| Layer | Example attacks |
|---|---|
| DNS | Subdomain takeover, rebinding, zone information leaks |
| TCP/network | Exposed services, port scanning, sniffing on plain HTTP |
| TLS | Downgrade, missing HSTS, bad certificates, stolen cookies without Secure |
| HTTP parsing | Request smuggling, header injection, host header attacks |
| Proxy / CDN / cache | Cache poisoning and deception, path confusion, trusted forwarded headers |
| Application | Injection, XSS, CSRF, IDOR, broken authentication, SSRF, logic flaws |
| Database | SQL/NoSQL injection, exposed instances, weak credentials |
| Browser | XSS, clickjacking, CORS misconfiguration, open redirects |
Hands-on exercises
Do these in your own browser and terminal, against sites you own or public ones where passive observation is fine (example.com is ideal).
- Walk a URL. Take
https://example.com/?a=1#b. Write down scheme, host, port (default), path, query, fragment. Open DevTools (F12), Network tab, load the page, and confirm the fragment is absent from the request line. - Resolve names. Run
nslookup example.comanddig +short NS example.com. Find the IP and the name servers. Trydig +short CNAME www.github.comand note aliases to CDNs. - Inspect the TLS certificate. Click the padlock in your browser, open the certificate, and note issuer, validity dates and the list of Subject Alternative Names. Compare with the
openssl s_clientcommand above. - Watch the waterfall. In the Network tab, reload a news site. Count the requests and the number of distinct hosts. Which are first-party and which third-party?
- Fingerprint the stack. With
curl -I https://example.com, read theServer,Via,X-Cache,CF-Cache-StatusorAgeheaders. What do they tell you about CDNs and caches in front of the site? - Break the illusion of the client. In DevTools Elements, remove a
disabledattribute or amaxlengthfrom any form field on a practice page and submit. Think about what the server would need to do to be safe.
Only test systems you own or have explicit permission to test. Passive observation of public pages is fine; sending attack payloads at third-party sites is not.
Checklist
- I can name the parts of a URL and say which part never reaches the server.
- I can explain what DNS does and describe two attacks that abuse it.
- I know the difference between TCP, TLS and HTTP and what each guarantees.
- I can describe what a reverse proxy, a CDN and a WAF each do.
- I understand why client-side restrictions are never security controls.
- I can narrate the nine steps of a request lifecycle from memory.
Key takeaways
- A web request is a pipeline of components; bugs often appear where two components disagree.
- The client is attacker-controlled, so the server must validate and authorize everything.
- TLS protects the channel, not the application logic.
- Proxies, CDNs and caches add trust relationships that attackers can exploit.
- Always ask: who parses this next, and do they interpret it the same way?
Further reading
- MDN: "How the Web works" and "What is a URL?"
- MDN: "Overview of HTTP"
- RFC 3986 (URI syntax), RFC 9110 (HTTP semantics), RFC 8446 (TLS 1.3)
- Cloudflare Learning Center: "What is DNS?" and "What is a CDN?"
- PortSwigger Web Security Academy: HTTP request smuggling, web cache poisoning and host header attacks