01. How the Web Works

You can't break what you don't understand. Every web bug comes down to a request the developer didn't expect.

Client & Server

A web application is a conversation between two sides:

Client
Your browser. Runs HTML, CSS and JavaScript. You fully control it.
Server
Their machine. Runs the app logic and talks to the database. You only control what you send it.
The golden rule Anything that comes from the client can be changed by the client. Form fields, hidden inputs, cookies, headers, JavaScript checks: all of it. If the server trusts it, that's a bug.

HTTP Requests

Every click, form submit, and page load sends an HTTP request. It's just text:

POST /login HTTP/1.1
Host: shop.example.com
Cookie: session=a8f3c91e
Content-Type: application/x-www-form-urlencoded

username=alice&password=hunter2
PartWhat it isWhy hackers care
POSTMethod (GET, POST, PUT, DELETE...)Sometimes a different method skips a check
/loginPath, plus an optional ?query=stringParameters in the URL are trivial to change
HeadersMetadata: Host, Cookie, User-Agent...Cookies hold your identity
BodyData being sentMain place to inject input

HTTP Responses

HTTP/1.1 200 OK
Content-Type: text/html
Set-Cookie: session=7d21bb04; HttpOnly

<html>Welcome back, alice!</html>
StatusMeaning
200OK
301 / 302Redirect
401 / 403Not logged in / not allowed. Interesting!
404Not found
500Server error. You probably broke something. Very interesting!

Cookies & Sessions

HTTP is stateless: each request stands alone. So how does a site remember you're logged in?

  1. You log in successfully.
  2. Server responds with Set-Cookie: session=7d21bb04.
  3. Your browser automatically sends Cookie: session=7d21bb04 with every later request.
  4. Server looks up who owns that session.
Think like an attacker What if the cookie isn't a random ID, but something readable like role=user? What if you could steal someone else's cookie? You'll try both later.

Where Input Goes

Most vulnerabilities happen when your input lands somewhere it gets interpreted instead of treated as plain data:

Your input ends up in...Bug class
A SQL querySQL Injection
A shell commandCommand Injection
An HTML pageCross-Site Scripting (XSS)
An ID used to look up dataIDOR / Broken Access Control
02-tooling →