HTTP
The Hypertext Transfer Protocol carries the web and most APIs: requests with a method, path and headers, answered with a status code, headers and a body. Usually wrapped in TLS as HTTPS.
- OSI layer
- 7 Application
- Carried in
- TCP (HTTP/1.1, HTTP/2); QUIC over UDP (HTTP/3)
- Ports
- 80/tcp, 443/tcp (HTTPS), 443/udp (HTTP/3), 8080/tcp (proxies, dev)
- Wireshark filter
http || http2 || http3- Encrypted
- no
Packet structure
HTTP/1.1 is text. A request line, headers, an empty line (\r\n\r\n), then the optional body:
POST /api/login HTTP/1.1
Host: app.example.com
User-Agent: Mozilla/5.0 (...)
Content-Type: application/json
Content-Length: 39
Cookie: session=abc123
{"user":"alice","password":"hunter2"}
HTTP/1.1 302 Found
Location: /dashboard
Set-Cookie: session=def456; Secure; HttpOnly; SameSite=Lax
Content-Length: 0
HTTP/2 carries the same meaning in binary frames, many requests multiplexed over one connection as streams:
Select a field to see what it does.
How it works
| Method | Use |
|---|---|
| GET, HEAD | Read (HEAD: headers only) |
| POST | Submit data, call an action |
| PUT, PATCH, DELETE | Change resources (APIs) |
| OPTIONS | CORS preflight, allowed methods |
| CONNECT | Open a tunnel through a proxy (HTTPS via proxy) |
| TRACE | Echo the request; should be disabled |
| Status | Meaning |
|---|---|
| 1xx | Informational (101 Switching Protocols: WebSocket upgrade) |
| 2xx | Success (200 OK, 201 Created, 204 No Content) |
| 3xx | Redirect (301/308 permanent, 302/307 temporary, 304 Not Modified) |
| 4xx | Client error (400, 401 needs auth, 403 forbidden, 404, 405, 429 rate limit) |
| 5xx | Server error (500, 502 bad gateway, 503 unavailable, 504 gateway timeout) |
Message length: Content-Length or Transfer-Encoding: chunked. When a proxy and a back end disagree on which one counts, you get request smuggling.
Versions: HTTP/1.1 sends one request at a time per connection (browsers open about 6). HTTP/2 multiplexes streams over one TLS connection (ALPN h2). HTTP/3 runs over QUIC on UDP 443, announced with the Alt-Svc header or an HTTPS DNS record.
In Wireshark
| Filter | Shows |
|---|---|
http.request | HTTP/1.x requests |
http.request.method == "POST" | POSTs (logins, uploads) |
http.response.code >= 400 | Errors |
http.host contains "example" | Requests to a host |
http.user_agent contains "curl" | Requests by user agent (scripts, scanners, malware) |
http.authorization | Basic/Bearer credentials in clear text |
http.cookie | Cookies |
http2.type == 1 | HTTP/2 HEADERS frames (needs TLS keys) |
http2.type == 3 | RST_STREAM (Rapid Reset floods) |
tcp.port == 80 && !http | Non-HTTP on port 80 |
File › Export Objects › HTTP extracts downloaded files. HTTPS needs the TLS session keys (see TLS).
What normal looks like: almost everything on 443 encrypted; plain HTTP mostly redirects to HTTPS, OCSP/CRL checks, updates and IoT devices.
Security notes
- Clear-text HTTP exposes credentials (Basic auth, form posts), cookies and content to anyone on the path. Use HTTPS everywhere plus HSTS.
- Web attacks travel in requests: SQL injection, XSS, path traversal, SSRF, command injection show up in paths, parameters, headers and bodies. Look for encoded payloads (
%27,../,<script>). - Request smuggling and desync: conflicting
Content-LengthandTransfer-Encodingbetween front end and back end. - HTTP/2 Rapid Reset (CVE-2023-44487): open and cancel streams in a loop to overload servers.
- Scanners and C2: odd user agents, many 404s in a short time (dirbusting), regular beacons with identical sizes and intervals.
- Security headers (CSP, HSTS, X-Frame-Options, …) protect the browser; check them with the CSP Checker.
- Host header attacks: password reset poisoning and cache poisoning via manipulated
HostorX-Forwarded-Host.
Versions and related
- HTTP/1.0, 1.1, 2, 3: same semantics (RFC 9110), different wire formats.
- TLS: turns HTTP into HTTPS.
- TCP carries HTTP/1.1 and /2; QUIC over UDP carries HTTP/3.
- WebSocket: starts as an HTTP Upgrade (101), then frames in both directions.
References
- RFC 9110: HTTP semantics
- RFC 9112: HTTP/1.1
- RFC 9113: HTTP/2
- RFC 9114: HTTP/3
- PortSwigger Web Security Academy: request smuggling