HTTP Deep Dive
HTTP is underneath almost everything we test as web pentesters. Burp Suite, browser DevTools, and curl let us inspect the conversation between client and server. Many web vulnerabilities begin when a server trusts something in an HTTP message that it should check.
You will learn to read requests and responses, trace authentication, and distinguish a suspicious response from a confirmed vulnerability. Start with browser DevTools or Burp Suite and a terminal with curl.
URL structure
Section titled “URL structure”A URL breaks into the following parts.
| Part | Purpose |
|---|---|
| Scheme | How to fetch the resource (https, ftp, ws). https is encrypted HTTP. |
| User info | Optional user:pass@ embedded in the URL. Rarely used, and insecure when it is. |
| Host | The domain or IP of the server. This is what DNS resolves. |
| Port | 80 for HTTP, 443 for HTTPS by default. May be written explicitly; otherwise the scheme supplies the default. |
| Path | The route to the resource, like a file path (/about). |
| Query string | key=value pairs after a ?, joined with &. |
| Fragment | A section anchor after #. Stays in the browser and is never sent to the server. |
Take this URL apart:
https://shop.bytemart.example:8443/products/search?category=shoes&size=10#reviews| Part | Value |
|---|---|
| Scheme | https |
| Host | shop.bytemart.example |
| Port | 8443 (non-standard, so it shows up) |
| Path | /products/search |
| Query string | category=shoes&size=10 |
| Fragment | reviews |
Remember: The fragment is excluded from the HTTP request target. JavaScript can still read it and send its value in a later request, so placing a token after # does not make it private from the application.
Percent-encoding
Section titled “Percent-encoding”Percent-encoding represents a byte as %XX in hexadecimal. Which characters need encoding depends on their position in the URL: reserved characters can act as separators. For example, %26 can represent an ampersand inside a query value without starting a new parameter.
GET /search?query=black%20friday%21 HTTP/1.1That’s black friday!. The space became %20, the ! became %21.
Encoding binary data in a URL can nearly triple its size. A 100KB image has 100,000 raw bytes, most outside the safe character set. Each unsafe byte becomes three characters, %XX.
The client-server model
Section titled “The client-server model”HTTP runs on a simple loop: the client sends a request, the server processes it, the server sends back a response.
Walk through the request and response
- Client sends a request. The request identifies a method and resource. Headers can carry preferences and credentials. A URL fragment stays in the browser.
- Server handles the request. The application chooses a route, identifies the caller where needed, checks permissions, and prepares a response. TLS protects the connection; application checks determine access.
- Server returns a response. Read the status with the headers and body. A 200 response might be a login page, and a 302 response might redirect an unauthenticated user.
- Client applies browser rules. The browser interprets the response and applies applicable cookie, CORS, caching, and content security rules. A later request may carry the stored session cookie.
Two properties of that loop matter for testing:
- HTTP is stateless. Applications add session handling on top of it. A cookie can identify server-side session state; a token can carry claims the server validates. The server may still store application data between requests.
- Proxies sit in the middle. Burp Proxy intercepts traffic; Repeater lets us edit and resend individual messages. Inspecting HTTPS requires TLS interception and a certificate authority trusted by the test browser.
curl shows the exchange without rendering the page. Use -v to inspect connection details and headers alongside the response body.
curl -v https://bytemart.example> GET / HTTP/1.1> Host: bytemart.example> User-Agent: curl/8.4.0> Accept: */*>< HTTP/1.1 200 OK< Content-Type: text/html; charset=UTF-8< Content-Length: 1256<<!doctype html>...The > lines are what curl sent. The < lines are what came back. Everything below the blank line in each block is the body.
| Flag | Purpose |
|---|---|
-O |
Save the response using the filename from the URL; -o selects a filename. |
-s |
Silent mode |
-v / -vvv |
Verbose: view the full request/response |
-I |
Send a HEAD request, headers only |
-i |
Show headers and body |
-A |
Set a custom User-Agent |
-H |
Set a custom header |
-X |
Set the request method (-X PUT, -X DELETE) |
-d |
Send data in the request body |
-k |
Skip TLS certificate validation |
Plain HTTP exposes messages to anyone able to observe the traffic path. HTTPS uses TLS to authenticate the server and protect messages in transit. In a typical certificate-based TLS 1.3 handshake, asymmetric cryptography authenticates the server and establishes shared secrets. Symmetric traffic keys then protect the HTTP data.
A typical TLS 1.3 connection follows these steps:
- The client connects to the HTTPS endpoint and sends a ClientHello with supported parameters and a key share.
- The server selects parameters and sends its key share. Both sides derive handshake keys.
- The server sends its certificate and proof that it holds the corresponding private key. The client validates the certificate chain and hostname.
- The peers exchange Finished messages to verify the handshake, then use traffic keys to protect application data.
An HTTP-to-HTTPS redirect is a separate HTTP exchange, not part of this handshake. Opening an HTTPS URL directly does not require a visit to port 80. See the TLS 1.3 specification for the protocol details.
You can watch this happen with curl too:
curl -v https://bytemart.example 2>&1 | grep -i "SSL\|TLS"* TLSv1.3 (OUT), TLS handshake, Client hello* TLSv1.3 (IN), TLS handshake, Server hello* TLSv1.3 (IN), TLS handshake, Certificate* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384Anatomy of a request
Section titled “Anatomy of a request”A request contains a request line, headers, and sometimes a body.
GET /cart?promo=SAVE20 HTTP/1.1Host: bytemart.exampleUser-Agent: curl/8.4.0Cookie: session=5f3c8a91e6b74c2d9a10f7e3b8d4c112
[body, if any]The request line contains the method, path with an optional query string, and HTTP version. Headers follow, then a blank line. Methods such as POST and PUT can include a body after it.
HTTP/1.1 uses a textual message format with CRLF line endings. HTTPS encrypts that format in transit. HTTP/2 uses binary frames and HPACK header compression; tools can present a readable version of those messages. Differences between front-end and back-end parsing can lead to request smuggling, covered below.
HTTP/1.1, HTTP/2, and HTTP/3
Section titled “HTTP/1.1, HTTP/2, and HTTP/3”| Version | Message transport | What to inspect |
|---|---|---|
| HTTP/1.1 | Textual messages, usually over TCP | Request line, headers, and body framing |
| HTTP/2 | Binary frames with multiple streams on a connection | Pseudo-headers such as :method, :authority, and :path |
| HTTP/3 | HTTP over QUIC, which uses UDP | The negotiated protocol and any translation at the gateway |
The methods and status codes keep their HTTP meaning across versions. A proxy’s readable request view may be reconstructed from frames rather than copied from raw text on the wire. HTTP/3 includes TLS protection through QUIC. See the IETF specifications for HTTP/2 and HTTP/3.
Headers give us several things to test.
| Header | Why it matters |
|---|---|
Host |
Confirms scope. Also useful for enumerating virtual hosts on shared infrastructure. |
User-Agent |
Identifies the client. If logged and displayed unsanitized in an admin panel, a crafted value can cause stored XSS. |
Cookie |
The session identifier. Stealing it enables session hijacking. |
Referer |
Where the request came from. Spoofable, so never trust it server-side. |
Accept |
Media types the client will take (*/* means anything). |
Authorization |
Auth credentials or a token, e.g. Basic ... or Bearer .... |
Cookie is often the only thing telling the server “this is still the same user.” In Burp Repeater, we capture a request, change a header or verb, resend it, and inspect what changes.
Anatomy of a response
Section titled “Anatomy of a response”HTTP/1.1 200 OKServer: Apache/2.4.41Content-Type: text/htmlSet-Cookie: session=5f3c8a91e6b74c2d9a10f7e3b8d4c112; HttpOnly; Secure
<html>...</html>This HTTP/1.1 response has a status line and headers, followed by a blank line and an HTML body. Some responses, including responses to HEAD requests, have no body.
Status codes fall into five ranges. For testing, knowing what each range means is more useful than memorizing all 60-odd codes.
| Range | Meaning |
|---|---|
| 1xx | Interim information before a final response; 101 switches protocols. |
| 2xx | The request succeeded at the HTTP level. Inspect the body and the user’s permissions to assess access control. |
| 3xx | Redirection or cache validation. Check Location and the resulting session; a redirect alone does not prove a successful login. |
| 4xx | The request cannot be fulfilled as sent. 403 means refusal; 404 may also conceal a resource the caller cannot access. |
| 5xx | Server-side failure. An input-dependent error warrants investigation, but does not establish SQL injection. |
curl -s -o /dev/null -w "%{http_code}\n" https://bytemart.example/adminThis prints only the status code, which is useful when scripting checks across a list of paths.
Specific codes worth knowing by name: 200 OK, 302 Found, 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 500 Internal Server Error.
Redirects and authentication failures
Section titled “Redirects and authentication failures”301 and 308 indicate permanent redirects; 302 and 307 are temporary. 307 and 308 preserve the request method and body. A client may change POST to GET for 301 or 302; 303 directs it to retrieve the other resource, usually with GET. Inspect each Location before following a redirect that carries credentials.
401 challenges the client to authenticate and normally includes WWW-Authenticate. 403 means the server refuses the request; repeating it with the same credentials may still fail. These distinctions come from HTTP Semantics, RFC 9110.
Headers in full
Section titled “Headers in full”Group headers by what they control when reviewing a request. These are practical categories, not separate wire formats.
General headers apply to both requests and responses: Date (when the message originated) and Connection (close ends the connection after this exchange, keep-alive leaves it open).
Entity headers describe the body: Content-Type (with charset for encoding), Content-Length (body size), Content-Encoding (compression, e.g. gzip), and the boundary parameter of Content-Type (the separator in a multipart upload). Transfer-Encoding: chunked sends the body as a series of chunks instead of a fixed Content-Length. Mismatches in how Content-Length and Transfer-Encoding get handled across a chain of proxies are a classic root cause of request smuggling.
Request headers also include X-Forwarded-For, which proxies use to record the original client IP. If the app is reachable directly, a caller can spoof it. Test whether the app trusts it for access control or rate limiting.
Response headers include Server (leaks the web server and version), Set-Cookie (issues a session token), WWW-Authenticate (states the required auth type), and Location (the redirect target on a 3xx).
Security headers tell the browser to enforce extra protections: Content-Security-Policy restricts where scripts and other resources can load from, Strict-Transport-Security forces HTTPS-only (HSTS), Referrer-Policy controls what leaks via Referer, X-Frame-Options blocks framing by another site (clickjacking), and X-Content-Type-Options: nosniff stops the browser from guessing a different content type than the one declared.
curl -sI https://bytemart.exampleWe can use this to check which security headers are present in the response.
Cookies
Section titled “Cookies”Cookies let applications keep track of sessions across otherwise stateless requests.
Set-Cookie: session=5f3c8a91e6b74c2d9a10f7e3b8d4c112; Secure; HttpOnly; SameSite=Strict; Max-Age=3600| Attribute | Effect |
|---|---|
Secure |
Cookie only sent over HTTPS. Without it, the cookie travels in plaintext if the user ever hits an HTTP page. |
HttpOnly |
JavaScript can’t read the cookie. Blocks a basic XSS-to-cookie-theft chain. |
SameSite=Strict |
Sent only on same-site requests; withheld on cross-site top-level navigation. |
SameSite=Lax |
Generally permits cross-site top-level navigation with safe methods. Many browsers default to Lax-like behavior when omitted, with implementation-specific exceptions. |
SameSite=None |
Permits cross-site use and requires Secure; cookie scope and browser privacy restrictions still apply. |
Max-Age / Expires |
How long the cookie lives before the browser drops it. |
SameSite helps limit cross-site cookie use. Choose it for the application’s navigation and sign-in flows, and keep server-side CSRF defenses for state-changing requests. Cookie settings apply to the cookie, not to an individual sensitive action.
HttpOnly prevents script from reading the cookie through document.cookie; an XSS payload can still make authenticated requests from the affected page. Omit Domain when a session cookie should belong only to its issuing host. A __Host- cookie requires Secure, Path=/, and no Domain attribute in supporting browsers. See the Set-Cookie reference.
An origin is the combination of scheme, host, and port. https://app.example and https://api.example have different origins even when both belong to the same site for cookie rules. Treat origin checks and SameSite checks separately. See MDN’s same-origin policy.
Cross-Origin Resource Sharing controls which other origins a browser will let JavaScript read responses from. It exists because the browser’s same-origin policy would otherwise block any legitimate cross-origin API call too.
curl -s -H "Origin: https://attacker.example" -I https://api.bytemart.example/user/profileHTTP/1.1 200 OKAccess-Control-Allow-Origin: https://attacker.exampleAccess-Control-Allow-Credentials: trueThis is a lead for a credentialed CORS issue. Confirm in a browser that an untrusted origin can read sensitive data while the victim’s credentials are actually sent. SameSite settings and third-party cookie restrictions can affect the result; curl does not enforce browser CORS rules. Use an explicit origin allowlist and return Vary: Origin when the allowed origin changes between responses. See MDN’s CORS guide.
| Header | Meaning |
|---|---|
Origin |
Sent by the browser, states where the request came from. |
Access-Control-Allow-Origin |
Server’s response: which origin(s) may read this response. * means anyone, but * can’t be combined with credentials. |
Access-Control-Allow-Credentials |
Allows the browser to expose a response to a request made with credentials; it does not itself cause credentials to be sent. |
Access-Control-Allow-Methods |
Which HTTP methods the cross-origin caller may use. |
A PUT or DELETE request, or one with a custom header, triggers a preflight: the browser sends an OPTIONS request first to check permissions before sending the real one.
Cross-origin requests meeting CORS’s safelisted method, header, and content-type rules can be sent without preflight. A blocked response therefore does not prove the server never processed the request. CORS controls browser access to responses; authentication, authorization, and CSRF controls still belong on the server. The browser may also reuse a cached preflight result.
curl -X OPTIONS -H "Origin: https://app.bytemart.example" \ -H "Access-Control-Request-Method: DELETE" \ -i https://api.bytemart.example/user/123Caching
Section titled “Caching”Caching headers decide whether a browser, CDN, or intermediate proxy can store and reuse a response instead of asking the origin server again.
Cache-Control: public, max-age=3600ETag: "33a64df551"| Header | Meaning |
|---|---|
Cache-Control: no-store |
Never cache this response anywhere. |
Cache-Control: no-cache |
A cache may store it, but must validate before reuse. |
Cache-Control: private |
Only the browser may cache it, not a shared proxy or CDN. |
Cache-Control: public, max-age=N |
Anyone may cache it for N seconds. |
ETag |
An opaque representation validator. For a conditional GET or HEAD, a matching If-None-Match can result in 304 Not Modified. |
no-cache and no-store serve different purposes. With a matching validator, a 304 lets the client reuse its stored representation and carries no new response content. Vary identifies request fields that affect representation selection, such as Accept-Encoding. Review it when a response changes by origin or language. RFC 9111 defines these cache rules. For sensitive user data, ensure shared caches cannot reuse one user’s response for another.
Cache poisoning tricks a shared cache into storing a malicious response under a legitimate-looking URL, which it then serves to later visitors. A common route is a header the cache ignores but the origin uses to build its response. For example, a crafted X-Forwarded-Host may appear in a redirect or script tag. If the CDN ignores that header when choosing its cache key, it can store the poisoned response under the clean URL.
curl -s -H "X-Forwarded-Host: attacker.example" -I https://bytemart.example/product/1042If the response reflects attacker.example anywhere and the page is cacheable, that’s worth digging into further.
Request smuggling
Section titled “Request smuggling”Request smuggling relies on servers disagreeing about request boundaries.
RFC 9112’s framing rules treat a message carrying both Transfer-Encoding and Content-Length as suspicious. Servers can reject such requests; intermediaries that forward them must remove the received Content-Length before forwarding. The payload below illustrates a parser disagreement in a vulnerable chain. A compliant chain should not process it that way. HTTP/2-to-HTTP/1 translation also needs consistent framing at the gateway.
A front-end proxy and a back-end server sometimes disagree about where one request ends and the next begins, especially when a request carries both a Content-Length and a Transfer-Encoding: chunked header. One server might honor Content-Length, the other might honor Transfer-Encoding. Send a request that both headers describe differently, and the two servers split the byte stream at different points.
POST / HTTP/1.1Host: bytemart.exampleContent-Length: 13Transfer-Encoding: chunked
0
SMUGGLEDIn this illustration, the body bytes are 0\r\n\r\nSMUGGLED: 13 bytes with no trailing newline. A front end using Content-Length forwards all 13 as the body of one request. A back end using chunked framing stops after the five-byte 0\r\n\r\n terminator. The remaining eight bytes are then interpreted as the start of another request. This disagreement can affect later traffic on a reused connection. SMUGGLED is only a marker here, not a complete HTTP request.
Modern web architecture
Section titled “Modern web architecture”The application’s architecture determines which services we need to test.
A monolith packages major application functions together, although its database and other dependencies may run separately. A microservices architecture separates functions into services. In either design, map the trust boundaries and credentials each component uses. Compromising one component does not automatically grant access to every other component.
With Single Page Applications, the server sends an HTML/JS shell once, and later interactions use background API calls through JavaScript without reloading the page. Burp captures those calls even when there’s no visible reload. Each is worth testing for IDOR or broken access control: the front end may appear secure while the API skips the same checks.
Reverse proxies (Nginx, Cloudflare) and API gateways sit in front of all this: browser → gateway/proxy → the right microservice → response back up the chain. More moving parts means more places to check. Slow down and enumerate every service rather than assuming a single front door covers the whole app.
HTTP methods
Section titled “HTTP methods”| Method | Description |
|---|---|
GET |
Requests a resource. Extra data travels via a query string. |
POST |
Sends data in the body. Handles text, files, and binary data for forms, logins, and uploads. |
HEAD |
Like GET but headers only, no body. Useful for checking size before downloading. |
PUT |
Creates or fully replaces a resource. Loose controls here allow malicious uploads. |
DELETE |
Removes a resource. Loose controls here enable denial-of-service. |
OPTIONS |
Returns which methods a server accepts for a resource. |
PATCH |
Partial update, as opposed to PUT’s full replace. |
TRACE |
Echoes the request back. Historically enabled Cross-Site Tracing (XST), reading HttpOnly cookies that JavaScript can’t touch directly. Should be disabled in production. |
CONNECT |
Establishes a tunnel through a proxy, typically for HTTPS. A misconfigured one can become an open relay. |
Two properties matter for testing. A safe method requests no state-changing action; logging and other incidental side effects can still occur. GET, HEAD, OPTIONS, and TRACE are defined as safe. An idempotent method has the same intended effect when repeated: safe methods, PUT, and DELETE have this property. POST and PATCH do not guarantee it. See HTTP method semantics. A GET that deletes a record just by being visited (/delete-account?confirm=1) breaks the safe expectation, and CSRF-via-GET is a real bug class to watch for.
curl -X OPTIONS -i https://bytemart.example/api/users/42HTTP/1.1 200 OKAllow: GET, POST, PUT, DELETEThe Allow header lists the methods the endpoint accepts.
Avoid putting secrets in URLs: URLs can appear in history and logs. Request bodies can also be logged by applications and proxies. POST does not add encryption; HTTPS protects both the URL path and body in transit. URL and body-size limits depend on the clients, servers, and intermediaries involved.
curl -X PUT https://bytemart.example/api/users/42 \ -H "Content-Type: application/json" \ -d '{"name": "Jane Doe"}'HTTP Basic authentication sends a Base64-encoded username and password in the Authorization header. A server, proxy, or application can implement it. Base64 is reversible encoding, so transport protection is essential.
CRUD operations, mapped onto HTTP
Section titled “CRUD operations, mapped onto HTTP”Most REST APIs map onto the four classic database operations.
| Operation | HTTP method | Description |
|---|---|---|
| Create | POST |
Adds new data to a table |
| Read | GET |
Reads an existing entity |
| Update | PUT |
Replaces an entity’s data |
| Delete | DELETE |
Removes an entity |
# Readcurl -s https://bytemart.example/api/products/1042
# Createcurl -X POST https://bytemart.example/api/products \ -H "Content-Type: application/json" \ -d '{"name": "Wireless Mouse", "price": 24.99}'
# Updatecurl -X PUT https://bytemart.example/api/products/1042 \ -H "Content-Type: application/json" \ -d '{"name": "Wireless Mouse (V2)", "price": 29.99}'
# Deletecurl -X DELETE https://bytemart.example/api/products/1042We can test two things here. PATCH is used for partial updates, while PUT implies replacement; an OPTIONS request can show which methods the endpoint accepts. Some APIs also “upsert” on PUT, creating a record if it does not exist. Check this directly, since behavior depends on the implementation.
Access control sits on top of all this. Not every user can perform every operation, and read access is usually broader than write (create, update, delete). APIs commonly use session cookies or an Authorization header. Bearer tokens may be opaque values or structured tokens such as JWTs. Check authorization on each object and action after authentication succeeds.
Summary
Section titled “Summary”Read the method, resource, headers, body, and response together. HTTPS protects the connection; the application still has to authenticate users and check their access to each object and action.
Cookies carry session state, CORS controls which origins can read responses in a browser, and caching controls when stored responses can be reused. HTTP versions change the framing and transport, so record the negotiated protocol and any proxy translation when investigating parsing problems.
For a reproducible finding, save a baseline request, the changed request, the relevant response, the expected access rule, and the observed impact. A status code or reflected header alone rarely establishes that impact.