bbc:03_how_internet_works
Differences
This shows you the differences between two versions of the page.
| bbc:03_how_internet_works [2026/05/14 10:05] – bbc article from bug bounty bootcamp drew | bbc:03_how_internet_works [2026/05/14 10:11] (current) – bbc article -- updated with full content drew | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ===== Client-Server Model ===== | ===== Client-Server Model ===== | ||
| - | Web apps operate on a **client-server** model: | + | Web apps operate on a client-server model. The client |
| - | * **Client** | + | |
| - | * **Server** | + | |
| - | * Everything in between (DNS, CDNs, load balancers, proxies) is part of the network path | + | |
| - | ===== DNS ===== | + | ===== DNS Record Types ===== |
| - | * DNS maps domain names to IP addresses | + | | Record | Purpose | Attack Relevance | |
| - | * **A record** | + | |---|---|---| |
| - | * **AAAA record** | + | | A | domain |
| - | * **CNAME** -- alias to another domain | + | | AAAA | domain |
| - | * **MX** -- mail server | + | | CNAME | alias to another domain |
| - | * **TXT** -- arbitrary text (SPF, DMARC, verification | + | | MX | mail server |
| - | * **NS** -- name server | + | | TXT | arbitrary text (SPF, DMARC) | verification |
| + | | NS | name server | ||
| - | ===== HTTP Basics | + | ===== HTTP ===== |
| - | **Request | + | **Request: |
| < | < | ||
| METHOD /path HTTP/1.1 | METHOD /path HTTP/1.1 | ||
| Host: example.com | Host: example.com | ||
| - | Header-Name: value | + | Cookie: session=abc123 |
| - | [optional | + | [body for POST/PUT] |
| </ | </ | ||
| - | **Common methods:** | + | **Common methods:** GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD |
| - | | + | |
| - | * POST -- submit data | + | |
| - | * PUT -- replace resource | + | |
| - | * PATCH -- partial update | + | |
| - | * DELETE | + | |
| - | * OPTIONS | + | |
| - | * HEAD -- like GET but no body | + | |
| - | **Response structure:** | + | **Status codes:** |
| - | < | + | |
| - | HTTP/1.1 200 OK | + | |
| - | Content-Type: | + | |
| - | Set-Cookie: session=abc123 | + | |
| - | + | ||
| - | [body] | + | |
| - | </ | + | |
| - | + | ||
| - | ===== Status Codes ===== | + | |
| | Code | Meaning | | | Code | Meaning | | ||
| |---|---| | |---|---| | ||
| | 200 | OK | | | 200 | OK | | ||
| - | | 301/302 | Redirect | + | | 301/302 | Redirect | |
| - | | 400 | Bad request | + | | 401 | Need auth | |
| - | | 401 | Unauthorized (need auth) | | + | | 403 | Auth present but no permission | |
| - | | 403 | Forbidden (have auth, no permission) | | + | |
| | 404 | Not found | | | 404 | Not found | | ||
| | 500 | Server error | | | 500 | Server error | | ||
| - | ===== Ports ===== | + | ===== Cookies |
| - | * HTTP: 80 | + | Cookies are key-value pairs sent automatically with each request to the matching domain. Security attributes: |
| - | * HTTPS: 443 | + | |
| - | * SSH: 22 | + | |
| - | * FTP: 21 | + | |
| - | * Common non-standard: 8080, 8443, 3000, 8888 | + | |
| - | Always scan for open ports during recon -- admin panels and dev services often run on alternate ports. | + | * **HttpOnly** |
| + | * **Secure** -- only sent over HTTPS | ||
| + | * **SameSite** (Strict/ | ||
| + | * **Domain / Path** -- scope | ||
| - | ===== Content Encoding ===== | + | Missing HttpOnly or Secure on session cookie |
| - | Servers declare content type with **Content-Type** header. Common types: | + | ===== Session vs Token Auth ===== |
| - | * `text/html` -- HTML pages | + | |
| - | * `application/ | + | |
| - | * `application/ | + | |
| - | * `multipart/ | + | |
| - | * `application/ | + | |
| - | ===== Cookies ===== | + | * **Session-based: |
| + | * **Token-based: | ||
| - | Cookies are key-value pairs stored in the browser and sent automatically with every request to the matching domain. | + | ===== JSON Web Tokens (JWT) ===== |
| - | Security attributes: | + | Three base64url-encoded parts separated by dots: `header.payload.signature` |
| - | * **HttpOnly** -- JS cannot read the cookie (prevents XSS cookie theft) | + | |
| - | * **Secure** -- only sent over HTTPS | + | |
| - | * **SameSite** -- controls cross-site sending (Strict/ | + | |
| - | * **Domain** -- which domain receives the cookie | + | |
| - | * **Path** -- which path receives the cookie | + | |
| - | Missing HttpOnly | + | * **Header:** `{" |
| + | * **Payload: | ||
| + | * **Signature: | ||
| - | ===== Security Controls ===== | + | **Attack vectors:** |
| - | * **Same-Origin Policy (SOP)** -- browser blocks cross-origin reads of responses | + | === alg:none === |
| - | * **CORS** -- server opts certain origins into cross-origin access via headers | + | |
| - | * **HTTPS/ | + | |
| - | * **Content Security Policy (CSP)** -- restricts which scripts/ | + | |
| - | * **HSTS** -- forces HTTPS for a domain for a specified duration | + | |
| - | ===== Sessions ===== | + | Set `" |
| - | HTTP is stateless. Sessions layer stateful identity on top: | + | < |
| - | * Server issues a **session token** after login | + | {" |
| - | * Token stored in cookie or localStorage | + | </ |
| - | * Sent with each request to identify the user | + | |
| - | * Server-side: | + | |
| - | Attack surface: weak tokens, | + | === HMAC-RSA Confusion === |
| + | |||
| + | If the app signs with RSA (private key) but an attacker changes `alg` to HMAC, the server may verify using the RSA public key -- which is public. The attacker can sign forged | ||
| + | |||
| + | === Brute-Force the Key === | ||
| + | |||
| + | If the HMAC key is weak, brute-force offline with hashcat or jwt_tool using the known header, payload, and signature. | ||
| + | |||
| + | === Reading the Payload === | ||
| + | |||
| + | JWTs are base64url-encoded, | ||
| + | |||
| + | ===== Same-Origin Policy (SOP) ===== | ||
| + | |||
| + | Scripts can only read responses from the same origin (protocol + hostname + port). | ||
| + | |||
| + | Relative to `https:// | ||
| + | * `https:// | ||
| + | * `http:// | ||
| + | * `https:// | ||
| + | * `https:// | ||
| + | |||
| + | SOP prevents a malicious script on attacker.com from reading your bank's response even if your browser includes your session cookie automatically. CORS is the mechanism by which servers loosen this restriction for trusted origins. | ||
| + | |||
| + | ===== Security Controls Summary ===== | ||
| + | |||
| + | | Control | What it does | | ||
| + | |---|---| | ||
| + | | SOP | Browser blocks cross-origin reads | | ||
| + | | CORS | Server opts origins into cross-origin access | | ||
| + | | HTTPS/TLS | Encrypts traffic in transit | | ||
| + | | CSP | Restricts which scripts/ | ||
| + | | HSTS | Forces HTTPS for domain for a set duration | | ||
bbc/03_how_internet_works.txt · Last modified: by drew
