Live lesson · progress saved to your account

Web Application Fundamentals

HTTP in depth, cookies, sessions and JWTs, how web apps and APIs are built, the same-origin policy and CORS, and an intercepting proxy. Then send raw requests to a food-delivery API and map its attack surface.

intermediate100 minwalkthrough

Anyone can read this lesson. To submit answers and earn XP, create a free account.

TASK 01Mission briefing: KhaanaNow goes live

ENGAGEMENT · KhaanaNow (fictional), Indore A food-delivery start-up launches in two weeks: an Android app, a website and a public API. The founders have a signed authorisation letter ready and ask for a security review before launch. Your first job isn't hacking. It's understanding how their app talks to its servers.

You can't test (or defend) what you don't understand. Web apps are the most attacked surface on the internet, and every attack in Room 15 (SQL injection, XSS, broken access control) is just a crafted HTTP request.

A modern web app is a stack of layers, and user input can enter at many of them. Click each input type:

Where user input enters a web app pick an input

/menu?city=indore&sort=price

Front end

React / HTML / JS in the browser

CDN + load balancer

Cloudflare, Nginx, TLS ends here

Back end / API

Node, Django, Spring, Laravel

Database + cache

PostgreSQL, MongoDB, Redis

Every highlighted layer must treat this input as untrusted. Attackers don't use your front end: they send raw requests with whatever values they like.

The golden rule of web security, which you'll see proven in this room: the client is in the attacker's hands. Anything the browser or app sends (prices, IDs, roles, hidden fields) can be changed, so the server must check everything again.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

TASK 02HTTP in depth

HTTP (HyperText Transfer Protocol) is a simple text conversation: the client sends a request, the server sends back a response. Click any line:

Anatomy of an HTTP request and response click any line
Browser
Web server / app
Database

Request

Response

POST /api/v1/cart?city=indore HTTP/1.1: Request line: METHOD, path + query string, protocol version.

A request has a request line (method, path, version), headers (Name: value), a blank line, and an optional body. A response has a status line, headers and a body.

Methods and status codes are the vocabulary:

HTTP methods and status codes filter by family
MethodPurposeSafeIdempotentBody
GETRead a resource–
POSTCreate / submit––
PUTReplace entirely–
PATCHPartial update––
DELETERemove––
OPTIONSWhich methods are allowed? (CORS preflight)–

200

OK

201

Created

204

No Content

301

Moved Permanently

302

Found (redirect)

304

Not Modified

400

Bad Request

401

Unauthorized (not logged in)

403

Forbidden (logged in, not allowed)

404

Not Found

405

Method Not Allowed

429

Too Many Requests

500

Internal Server Error

502

Bad Gateway

503

Service Unavailable

  • Safe methods shouldn't change anything; idempotent ones give the same result if repeated.
  • 401 vs 403: 401 means "who are you?" (log in); 403 means "I know who you are, and no."
  • HTTPS is just HTTP inside TLS (Room 09). Without it, everything above, including cookies and passwords, travels in cleartext.
  • HTTP/2 sends many requests at once over one connection, in binary frames. HTTP/3 runs over QUIC on UDP for faster connections on mobile networks. The methods, headers and status codes stay the same.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 03State: cookies, sessions and JWTs

HTTP is stateless: each request stands alone, so the server needs a way to remember that you logged in. Enter the cookie. Step through a session and then try to steal it:

The session cookie lifecycle step 1/5
  1. POST /login with phone + OTP
  2. Server creates session 7f3a9c in its store → Set-Cookie: session=7f3a9c
  3. GET /orders · Cookie: session=7f3a9c → server looks it up: user u-77
  4. GET /profile · Cookie: session=7f3a9c (sent automatically, every request)
  5. POST /logout → server deletes 7f3a9c; cookie is now worthless

Cookie flags

Set-Cookie: session=7f3a9c; Path=/

Try to steal or ride the session

Cookie flags you must recognise:

FlagProtects against
HttpOnlyJavaScript (and so XSS) can't read the cookie
SecureOnly sent over HTTPS, never leaked on plain HTTP
SameSite=Lax / StrictNot sent on cross-site requests, which blocks most CSRF
Expires / Max-AgeLimits how long a stolen cookie is useful

Many APIs use tokens instead, usually JWTs sent in an Authorization: Bearer … header:

Server sessions vs JWTs session
Stored where?
Random ID in a cookie; data lives on the server
Logout
Delete it server-side: instant
Scaling
Every server needs the session store (e.g. Redis)
If stolen
Valid until logout or expiry

Remember from Room 12 that a JWT is encoded, not encrypted. Anyone can read it; the signature only stops changes:

Inside a JWT access token valid

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImstMjAyNi0xMSJ9.eyJpc3MiOiJodHRwczovL2xvZ2luLm1lZGlzZXR1LmV4YW1wbGUiLCJzdWIiOiJ1LTEwNDIiLCJuYW1lIjoiUmF2aSIsInJvbGUiOiJudXJzZSIsImF1ZCI6ImVoci1hcGkiLCJleHAiOjE3OTg3NjE2MDB9.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk

{
 "alg": "RS256",
 "typ": "JWT",
 "kid": "k-2026-11"
}
{
 "iss": "https://login.medisetu.example",
 "sub": "u-1042",
 "name": "Ravi",
 "role": "nurse",
 "aud": "ehr-api",
 "exp": 1798761600
}
RSASHA256(header.payload, private key)

✓ verified with the issuer's public key

Base64url is encoding, not encryption: anyone can read a JWT. Only the signature stops edits.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 04APIs: talk to the server directly

KhaanaNow's Android app and website don't talk to the database. They call an API, a set of URLs that accept and return data, usually as JSON.

REST APIs use URLs for things (nouns) and methods for actions (verbs):

GET    /api/v1/orders          list my orders
POST   /api/v1/orders          place an order
GET    /api/v1/orders/50112    one order
DELETE /api/v1/orders/50112    cancel it

GraphQL instead uses one endpoint (/graphql) where the client asks for exactly the fields it wants. Powerful, and easy to over-expose if introspection is left on.

APIs authenticate with API keys (for apps), bearer tokens (for users) or both. Since attackers don't need the app, an API is only as safe as its server-side checks.

Time to be the client. This is a simulated repeater: edit a raw HTTP request, send it and read the response.

Lab · Repeater: talk to the KhaanaNow API 0/6 goals

Request (edit freely)api.khaananow.example:443

Response

Press Send.

Fetch the menu (GET /api/v1/menu)

Use a query string to show only restaurant 14

Read robots.txt

Log in with JSON and get a token

Fetch /api/v1/orders with the Bearer token

Ask which methods /api/v1/orders allows (OPTIONS)

History

Test account: phone 9876543210, OTP 4242

Hints

  • Add a query string: GET /api/v1/menu?restaurant=14 HTTP/1.1
  • robots.txt lives at the site root.
  • Login: POST /api/v1/login, add Content-Type: application/json, a blank line, then {"phone":"9876543210","otp":"4242"}
  • Paste the token into Authorization: Bearer <token>.
  • OPTIONS /api/v1/orders HTTP/1.1 asks what's allowed.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 05The browser security model

Your browser holds cookies for your bank, email and food app at the same time. What stops a random website from using them? The same-origin policy (SOP).

An origin is scheme + host + port. JavaScript from one origin can send requests to another, but it can't read the response unless the other side allows it.

Same-origin policy and the CORS decision page at https://khaananow.example

JavaScript running on https://khaananow.example calls fetch() to:

Cross-origin: Different host: subdomains are different origins. The browser sends a preflight OPTIONS and checks the server's answer.

Server replies with Access-Control-Allow-Origin

Blocked by CORS policy

CORS relaxes the same-origin policy, and only the server can grant it. It doesn't stop the request from being sent; it stops the page reading the answer.

CORS (Cross-Origin Resource Sharing) is how a server relaxes SOP: it answers with Access-Control-Allow-Origin. For "non-simple" requests (JSON bodies, custom headers) the browser first sends a preflight OPTIONS request to ask permission.

Common CORS mistakes:

  • Reflecting any Origin header back with Access-Control-Allow-Credentials: true: any site can read your users' data.
  • Trusting null or a sloppy regex like khaananow.example that also matches khaananow.example.evil.com.

The other big browser defence is Content Security Policy (CSP), a response header listing where scripts may load from:

Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.khaananow.example; object-src 'none'

If an attacker injects <script>, CSP can stop it running. More in Room 15.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

TASK 06Intercepting proxies and Burp Suite

An intercepting proxy sits between your browser (or phone) and the server, so you can pause, read and change every request. Burp Suite (PortSwigger) is the industry standard; OWASP ZAP is the free, open-source alternative.

Burp's core tools:

  • Proxy: intercept traffic; HTTP history keeps everything.
  • Repeater: resend one request with edits (what you did in task 4).
  • Intruder: automate many variations (rate-limited in the free edition).
  • Decoder / Comparer: base64, URL encoding, diffing responses.

The setup is always the same: browser → proxy on 127.0.0.1:8080 → install Burp's CA certificate so HTTPS can be decrypted → scope set to the authorised hosts only.

Try it on KhaanaNow's checkout. Place an order, then experiment with the intercepted request: change the price, the quantity, the delivery fee…

Lab · Intercept and modify a checkout request intercept ON

KhaanaNow app

Dal Bafla × 2

₹180 each

Delivery₹40

Tip₹10

Total₹410

Safe testing workflow: written authorisation, a defined scope, test accounts you own, no real customers' data, no denial of service, and stop and report as soon as you prove an issue.

Answer the questions

+10 XP

+10 XP

+10 XP

+10 XP

+10 XP

+30 XP

TASK 07Final mission: map the app

Put it together into the deliverable the KhaanaNow founders asked for: a map of every endpoint, how each is protected, and where input enters. Use the repeater from task 4 to check anything you're unsure of.

Mission · Map the KhaanaNow attack surface classify each endpoint
GET /api/v1/menu
POST /api/v1/login
GET /api/v1/orders
POST /api/v1/checkout
GET /api/v1/internal/debug
GET /admin

Which of these are places user input reaches the server?

This map becomes the test plan for Room 15, where you'll attack exactly these endpoints for the OWASP Top 10.

Complete the mission for the Request Runner badge and the room's XP.

Answer the questions

+10 XP

+10 XP

+10 XP

+30 XP