Table of Contents

Ch 3: How the Internet Works

Source: Bug Bounty Bootcamp by Vickie Li (No Starch Press, 2021)

Client-Server Model

Web apps operate on a client-server model. The client (browser) sends HTTP requests; the server processes them and returns responses.

DNS Record Types

Record Purpose Attack Relevance
A domain → IPv4 -
AAAA domain → IPv6 -
CNAME alias to another domain subdomain takeover
MX mail server -
TXT arbitrary text (SPF, DMARC) verification bypass
NS name server dangling NS = takeover

HTTP

Request:

METHOD /path HTTP/1.1
Host: example.com
Cookie: session=abc123

[body for POST/PUT]

Common methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD

Status codes:

Code Meaning
200 OK
301/302 Redirect
401 Need auth
403 Auth present but no permission
404 Not found
500 Server error

Cookies

Cookies are key-value pairs sent automatically with each request to the matching domain. Security attributes:

Missing HttpOnly or Secure on session cookie = reportable finding.

Session vs Token Auth

JSON Web Tokens (JWT)

Three base64url-encoded parts separated by dots: `header.payload.signature`

Attack vectors:

alg:none

Set `“alg”:“none”` in the header. If the server doesn't validate signatures, an empty signature is accepted. Any token with an arbitrary payload becomes valid.

{"alg":"none","typ":"JWT"} . {"user":"admin"} . [empty]

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 tokens with the public key.

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, not encrypted. Decode the payload with `base64 -d` or jwt.io to check for sensitive data (PII, privilege flags, internal IDs).

Same-Origin Policy (SOP)

Scripts can only read responses from the same origin (protocol + hostname + port).

Relative to `https://medium.com/@user`:

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/resources can load
HSTS Forces HTTPS for domain for a set duration