HTTP for Security Work
Know HTTP requests, responses, headers, cookies and sessions well enough to read raw traffic and spot where web attacks hide.
Beginner · about 4 hours · difficulty 2/5
Learn first: How the Internet and TCP/IP Work
Web application security is mostly the art of reading and modifying HTTP. Before you learn attacks, you must be able to read a raw request.
Anatomy
A request has a method (GET, POST, PUT, DELETE), a path with query string, headers and an optional body. A response has a status code, headers and a body. Codes to know: 200, 301/302, 400, 401, 403, 404, 500.
State: cookies and sessions
HTTP is stateless, so apps remember you with cookies or tokens in headers (Authorization: Bearer ...). Cookie flags matter:
HttpOnly: JavaScript cannot read it (limits XSS damage).Secure: only sent over HTTPS.SameSite: controls cross-site sending (key CSRF defense).
Security headers
Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options or CSP frame-ancestors. Missing headers are common low-severity findings.
The attacker's view
Everything the client sends can be changed: hidden form fields, cookies, headers like X-Forwarded-For, JSON bodies, and the order of requests. A proxy such as Burp Suite lets you intercept and edit them. The server must never trust client input.
Pitfalls
- Believing client-side validation protects anything. It is a convenience for users only.
- Confusing 401 (not authenticated) with 403 (authenticated but not allowed).
Move on when you can open browser DevTools, inspect a login request, and explain every header and cookie involved.
Key concepts
- Methods, paths and status codes
- Request and response headers
- Cookies and session tokens
- Cookie flags (HttpOnly, Secure, SameSite)
- Security response headers
- Browser DevTools network tab
- curl for raw requests
Mini project
Use curl to log in to a local practice app, store the session cookie, and request an authenticated page, documenting every request and response header.
Check yourself
Why does a price sent in a hidden form field give an attacker control over the price?
Free resources
- MDN: HTTP (MDN)
- OWASP HTTP Headers Cheat Sheet (OWASP)
- PortSwigger Web Security Academy (PortSwigger)