# HTTP for Security Work

> Know HTTP requests, responses, headers, cookies and sessions well enough to read raw traffic and spot where web attacks hide. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/cybersecurity/http
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/cybersecurity/internet-basics)

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](https://developer.mozilla.org/en-US/docs/Web/HTTP) (MDN)
- [OWASP HTTP Headers Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html) (OWASP)
- [PortSwigger Web Security Academy](https://portswigger.net/web-security) (PortSwigger)

Previous: [DNS and How It Gets Abused](https://www.internhack.in/roadmaps/tracks/cybersecurity/dns) · Next: [TLS and Encryption in Transit](https://www.internhack.in/roadmaps/tracks/cybersecurity/tls)

## More in Networking for Security

- [How the Internet and TCP/IP Work](https://www.internhack.in/roadmaps/tracks/cybersecurity/internet-basics)
- [Subnetting, Ports and Common Services](https://www.internhack.in/roadmaps/tracks/cybersecurity/subnetting-ports)
- [DNS and How It Gets Abused](https://www.internhack.in/roadmaps/tracks/cybersecurity/dns)
- [HTTP for Security Work](https://www.internhack.in/roadmaps/tracks/cybersecurity/http)
- [TLS and Encryption in Transit](https://www.internhack.in/roadmaps/tracks/cybersecurity/tls)
- [Packet Analysis with Wireshark](https://www.internhack.in/roadmaps/tracks/cybersecurity/wireshark)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cybersecurity Roadmap](https://www.internhack.in/roadmaps/tracks/cybersecurity)
