Pre-Security Course / Module 3
How the Web Works
A large share of the security work you will do is on web applications — and increasingly on the APIs behind them. This module teaches the plain conversation under every website (request, response, URLs, cookies, identity), and then the shape of modern apps: the three tiers behind a page, single-page apps, the frontend/backend split, and the shared API that a website and its mobile app both depend on. Know these and nothing on a real engagement will catch you by surprise.
3.1 · The request and the response
Every time you open a web page, your browser (the client, from Module 2) sends a request to a web server, and the server sends back a response. That is the entire model — everything else is detail. The language the two speak is HTTP, the HyperText Transfer Protocol. HTTPS is the same conversation wrapped in encryption, so nobody in between can read it.
The important realisation is that a request is just text:
GET /profile HTTP/1.1
Host: bank.example.com
Cookie: session=8f3a1b...
The first line says what the client wants (GET) and which resource (/profile). The lines below are headers — extra details. The server replies with a status line, its own headers, and usually a body. From this one fact grows the most important habit in web testing: the page you see is only the response. A tester works at the request/response level, because that is where you can change things the page never intended.
In short — the web is a client sending an HTTP request and a server sending a response. Both are plain text with a first line and headers. HTTPS is just encrypted HTTP. The page is only the response.
Quick check
-
What is the difference between HTTP and HTTPS?
Same conversation, wrapped in encryption — so it cannot be read in transit.
-
Why do testers look at the raw request/response rather than just the page?
The page is only the response. The request is the half you control — and where you can send what the page never intended.
-
A basic HTTP request is best described as…
A request is readable text: a line saying what is wanted, then headers carrying the detail.
3.2 · Anatomy of a URL
Every request in the last section began with a URL — the address in your browser bar. You have typed thousands of them without ever being shown how they are put together. That is worth fixing now, because a URL is not one thing: it is five or six separate parts, and a tester reads each of them differently.
Here is a full one, with every part present:
| Part | In the example | What it is, and what it tells you |
|---|---|---|
| Scheme | https:// | Which protocol to speak. https is encrypted, http is not — a finding in itself on a login page. |
| Host | shop.meridiantrust.in | Which server to reach. Reads right to left: .in is the top-level domain, meridiantrust the domain, shop a subdomain. An organisation usually has many subdomains, and finding the forgotten ones is an early testing job. |
| Port | :443 | Which service on that machine (Module 2). Nearly always hidden, because 443 for HTTPS and 80 for HTTP are assumed. A visible odd port such as :8080 is always worth a look. |
| Path | /accounts/statement | Which resource on the server. Paths are hierarchical, so they invite guessing: if /accounts/ exists, what about /admin/? |
| Query string | ?id=42&year=2026 | Parameters passed to that resource. It starts at the ?, each parameter is name=value, and & joins them. This is user input — the most attacked part of the whole URL. |
| Fragment | #summary | A position within the page. Uniquely, it is never sent to the server — the browser keeps it. So it cannot reach server-side code, and it will not appear in server logs. |
Reading a URL as a tester
Once the parts separate, a URL stops being an address and becomes a list of questions. Look again at ?id=42. Nothing stops you changing it to ?id=43 and pressing Enter — and if the server hands back somebody else's statement, you have found a real and very common flaw. You will meet it properly by name in the Beginner course; for now, simply notice that the number was sitting in plain sight, editable, and the application trusted it.
The fragment deserves its own note for the same reason in reverse. Because #summary never leaves the browser, anything built from it can only ever be attacked in the browser — which is why one family of web flaws is described as living purely on the client side.
Finally, a loop back to Module 1. A URL may only contain a restricted set of characters, so anything else is URL-encoded into a % and two hex digits — a space becomes %20 and a slash becomes %2F. When a URL in a report is full of percent signs, that is all it is: ordinary characters wearing a travel disguise.
⌨ Try it yourself — take a URL apart
- Open any shopping or news site and search for something. Look hard at the address bar: you will almost always see a
?followed by your own search words. - Name each part out loud — scheme, host, path, query string.
- Edit one value in the query string and press Enter. Watch the page change. You have just sent the server input it did not expect from a button.
In short — a URL is scheme, host, optional port, path, query string and fragment. The query string carries user input and is the most attacked part; the path can be guessed at; the host hides forgotten subdomains; and the fragment never reaches the server at all.
Quick check
-
In
https://bank.example.in/pay?to=55, which part is the query string?The query string begins at the
?and carriesname=valueparameters./payis the path; the rest is the host. -
Which part of a URL is never sent to the server?
Everything after the
#stays in the browser, so it never reaches server-side code or server logs. -
Why does the query string interest a tester more than the scheme?
Parameters are user-supplied values the application acts on — the classic place to try something the developer never planned for.
-
A URL contains
%20. What is that?Characters a URL cannot carry directly are written as
%plus two hex digits — Module 1's URL-encoding.
3.3 · Methods, status codes and headers
The first word of a request is its method — the kind of action. Two cover most traffic: GET (fetch something) and POST (send data, e.g. submit a form). You will also meet PUT and DELETE, which typically update and remove data. Rough rule: reading is usually a GET; sending or changing is usually a POST.
Status codes
The reply begins with a three-digit status code. Learn what each opening digit means, plus a few specifics:
| Range | Meaning | Ones you'll see |
|---|---|---|
2xx | Success | 200 OK |
3xx | Redirect — go elsewhere | 301, 302 |
4xx | You (the client) got it wrong | 401 unauthorised, 403 forbidden, 404 not found |
5xx | The server broke | 500 server error |
These are signals to a tester. A 403 where you expected a page hints something exists but you are not allowed to see it. A 500 after you sent an odd value hints your input broke something server-side — often the first sign of a deeper flaw.
Headers
Headers are the name-value lines carrying extra detail on both requests and responses. Host names the site; User-Agent describes your browser; Content-Type says whether a body is HTML, JSON, and so on; Cookie and Authorization carry your identity. Much security-relevant behaviour hides in headers, so testers read them closely.
In short — the method is the action (GET fetches, POST sends); the status code grades the result (2xx good, 3xx redirect, 4xx your fault, 5xx server's fault); headers carry the extra detail.
Quick check
-
A response comes back
403 Forbidden. What does that tell you?4xx means the request was your responsibility; 403 specifically means understood but not permitted.
-
You submit a login form. Which method is most likely?
POST sends data to the server in the request body, which is where credentials belong.
-
After you send an unusual value the server returns
500. Why is that interesting?A 5xx is the server's own fault, and your input triggered it — often the first hint of a deeper flaw.
3.4 · Cookies and sessions
HTTP has a quirk that shapes a huge amount of web security: it is stateless. Each request stands alone; the server does not automatically remember the one before. So how does a site remember you are logged in as you click around? With cookies.
When you log in, the server creates a session — a record on its side saying "this visitor is Priya, logged in" — and hands your browser a small session cookie that works like a cloakroom ticket. Your browser attaches that cookie to every later request, and the server matches the ticket to its record.
That cookie is your identity for the visit. If someone steals it, they can present your ticket and the server treats them as you — no password needed. This is why so much web security protects cookies, and why you will hear flags like HttpOnly (stops page scripts reading the cookie) and Secure (only send over HTTPS). Hold the core idea: a session lives on the server, and a cookie is the ticket that points to it — so a stolen cookie is a stolen identity. (APIs, later in this module, often carry identity as a token instead of a cookie — same idea, different wrapper.)
⌨ Try it yourself — see a cookie
On a site you are logged in to, open DevTools (F12) → Application tab (Chrome/Edge) or Storage (Firefox) → Cookies. You will see name-value pairs — often one named session. That string is your cloakroom ticket. (Don't share it.)
In short — HTTP forgets you between requests, so a login creates a server-side session and hands your browser a cookie, re-sent on every request. It is your identity for the visit — stealing it means impersonating you.
Quick check
-
Why does a website need cookies to keep you logged in?
HTTP is stateless. The cookie is the ticket that re-identifies you on every single request.
-
An attacker steals your valid session cookie. What can they do?
The cookie is the proof of identity. Whoever holds a valid one is that user, password or not.
-
Where does the session itself actually live?
The server keeps the session record. The cookie holds only an identifier that points to it.
3.5 · Authentication vs Authorization
These two words sound alike and are constantly confused, but they name two different checks — and the difference is central to web (and API) security.
- Authentication (authn) answers "who are you?" — proving identity, usually with a password, one-time code, or fingerprint. Logging in is authentication.
- Authorization (authz) answers "what are you allowed to do?" — deciding, once you are known, which pages and actions you may reach. A normal user blocked from the admin panel is authorization.
Many real, high-impact findings are authorization failures. Picture a logged-in customer (authenticated correctly) who changes a number in the URL — account?id=1007 to id=1008 — and suddenly sees another customer's statement. The system knew who they were; it failed to check what they were allowed to see. When you later study "access control" and the bug called IDOR, this is the exact gap — and as you will see next, it is often the API that fails to check. Keep the two questions apart: who are you versus what may you do.
In short — authentication proves who you are (login); authorization decides what you may do (access). Passport versus boarding pass. Many serious bugs are authorization failures, not login failures.
Quick check
-
A logged-in customer changes an ID in the URL and sees someone else's statement. Which control failed?
They were correctly identified, so authentication worked. Nobody checked whether that record was theirs — that is authorization.
-
Entering your password to prove identity is…
Proving who you are is authentication; deciding what you may do is authorization.
-
Which analogy matches?
The passport proves identity (authentication); the boarding pass says which flight you may board (authorization).
3.6 · Two shapes of web app — traditional and single-page
Not all web apps are built the same way, and you will meet both shapes on real engagements. Knowing which one you are looking at tells you where the interesting requests are.
Traditional (server-rendered) apps
The older, still-common style: every click asks the server for a whole new HTML page. You click a link, the browser sends a request, the server builds a complete page and sends it back, and the browser throws away the old page and shows the new one. You see a full reload — a flash, a fresh page — on each action. Here the interesting requests are page loads and form submissions.
Single-page applications (SPAs)
The modern style. A single-page application loads once — the browser downloads a bundle of JavaScript, and after that the JavaScript running in your browser updates the page in place, with no full reloads. It feels like a desktop app. When it needs fresh data, it does not fetch a whole new page; it quietly calls the server's API in the background and receives just the data (usually JSON, from Module 4), then redraws the relevant part of the page. Apps built with React, Angular or Vue are SPAs.
Why this matters to a tester: in a traditional app, the action is in page loads and form posts. In a SPA, the page you see is almost empty of logic — the real work happens in the background API calls. If you only look at the visible page, you miss where the security actually lives. The tell, in the DevTools Network tab, is a stream of small background calls to paths like /api/... returning JSON. That API is the subject of the next two sections.
In short — traditional apps fetch a whole new HTML page on every click; single-page apps (SPAs) load once and then quietly fetch just data from a backend API. In a SPA the real logic lives in those background API calls, not the visible page.
Quick check
-
What most distinguishes a single-page application (SPA)?
An SPA loads its shell once and then updates in place, pulling just data from a backend API.
-
In a SPA, where does the interesting security activity mostly happen?
The visible page is a shell. The decisions — and the flaws — are in the API calls behind it.
-
In a traditional (server-rendered) app, what happens on each click?
A server-rendered app builds a complete HTML page for every click. Fetching just JSON is the SPA pattern.
3.7 · APIs — the frontend/backend split
Modern apps are split in two. The frontend is what runs where you can see it — the SPA in your browser, or a mobile app. The backend is the server that actually holds the data and makes the decisions (can this user transfer money? does this account exist?). The two talk through an API.
The three tiers behind a page
Stand back from a single request and almost every web application has the same three-part shape. Take one ordinary action — a customer taps Check balance:
Follow the tap through. The frontend sends an API call such as GET /api/accounts/42/balance, carrying whatever proves who you are. The backend checks that the session is valid, checks that this customer is allowed to see that account, and only then asks the database for the number. The database knows nothing about customers or permissions; it answers whatever it is asked. The backend formats the reply, and the frontend draws it on screen.
Notice where the judgement happens. Only the middle tier decides anything. The frontend is a display, the database is a filing cabinet, and every question of "may this person do this?" is answered in between. That is why the middle tier gets the attention — and why, if it forgets to ask, nothing else in the picture will catch the mistake.
What an API is
API stands for Application Programming Interface — a defined set of requests the backend agrees to accept. For the web it is usually a REST API: a list of URLs called endpoints, each doing one job, exchanging JSON (Module 4). For example:
GET /api/accounts/42 // fetch account 42 → returns JSON
POST /api/transfer // send money (JSON body)
DELETE /api/users/5 // delete user 5
The frontend is, in a sense, just a pretty shell around these calls. Every button you press turns into an API request behind the scenes.
Types of API you will meet
REST is the common case, not the only one. You do not need to work with these yet — you need to recognise the names when a client says which one they run, because the testing approach changes with the shape.
| Type | What it looks like | Where you meet it |
|---|---|---|
| REST | Plain URLs plus a method, exchanging JSON: GET /api/accounts/42. | The default for modern web and mobile apps. Most of what you test. |
| SOAP | Older and strict: every message is an XML envelope posted to one endpoint, described by a WSDL file. | Banking and insurance back-office systems that have run for years. Very much alive in Indian BFSI. |
| GraphQL | A single endpoint where the client writes a query saying exactly which fields it wants back. | Newer apps. Its flexibility is also its risk — clients can ask for more than intended. |
| gRPC | Compact binary messages rather than readable text, built for speed. | Between a company's own internal services, rarely facing the public. |
| WebSocket | A connection held open so both sides can send at any time. | Live chat, trading screens, notifications. |
Two of those carry a practical warning. A SOAP service takes XML, and XML brings its own family of flaws that JSON simply does not have. GraphQL lets the caller compose the request, so an endpoint that looks like one harmless query can often be persuaded to return far more. Both are taught properly later — here, the point is only that "it is an API" does not mean "it is a REST API".
Why the API is the real attack surface
Here is the point that reshapes how you test. Because the backend does the real work, an attacker can call the API directly and ignore your frontend entirely. The pretty page might hide the "delete user" button from a normal user — but if the endpoint DELETE /api/users/5 does not itself check authorization (Module 3.5), anyone who knows the URL can call it and it will work. The frontend's hiding was never a real control. This is why so much modern testing is API testing: the security must live in the backend, because the frontend can always be bypassed.
One more practical note on identity: APIs often carry it as a token — a long string sent in an Authorization: Bearer … header (frequently a JWT) — rather than a cookie. Same idea as the session ticket from 3.4, delivered in a header instead.
In short — modern apps run in three tiers: a frontend that displays, a backend that decides, and a database that remembers. Frontend and backend talk through an API — usually REST exchanging JSON, but also SOAP, GraphQL, gRPC or WebSocket. The backend is the real attack surface: an attacker can call the API directly, so hiding a button on the frontend is not a security control.
Quick check
-
What is an API, in web terms?
An API is the agreed interface to the backend — endpoints like
GET /api/accounts/42, usually exchanging JSON. -
In the three-tier picture, which tier decides whether you may see an account?
The database answers what it is asked and the frontend only displays. Every "may this person do this?" belongs in the middle tier.
-
A client says their service is SOAP rather than REST. What changes for you?
SOAP posts XML envelopes to a single endpoint, and XML carries a family of weaknesses that JSON does not.
-
A page hides the "delete" button from normal users, but
DELETE /api/users/5works when called directly. What went wrong?The frontend can always be bypassed. The backend API must enforce authorization itself.
-
Why is the backend API considered the real attack surface?
The frontend is just a shell; anyone can craft API requests directly, so the backend must enforce the rules.
-
Besides cookies, how do APIs often carry a user's identity?
APIs commonly use a token in an
Authorization: Bearer …header, often a JWT — the same idea as a session ticket.
3.8 · One backend, many clients — and the API gateway
Now the piece that surprises freshers most. The same backend API usually serves several clients at once. Your bank's website (a SPA) and your bank's mobile app (on iOS and Android) are not two separate systems — they are two frontends talking to the same backend API. Partner integrations may use it too.
The consequence is important: a flaw in the API affects every client. It also means a mobile app is not a separate mystery — it usually just calls the same endpoints your web SPA does, so testing the API covers the shared surface behind both.
The API gateway
As backends grow, they are often split into many small services (accounts, payments, login…). Rather than expose each one, organisations put an API gateway in front — a single "front door" that every API call passes through. The gateway routes each request to the right service behind it, and commonly handles the cross-cutting jobs in one place: authentication, rate limiting (blocking floods of requests), TLS/HTTPS, and logging. You will hear product names like AWS API Gateway, Apigee or Kong. For a consultant, the gateway is frequently the main entry point you are pointed at — so recognise the term and what sits behind it.
In short — one backend API usually serves many clients — the web SPA and the mobile app share it — so a flaw affects all of them. An API gateway is the single front door in front of the backend services, handling routing plus auth, rate limiting and TLS.
Quick check
-
A bank's website and its mobile app — how do they usually relate to the backend?
Web and mobile are different frontends over a shared backend API — so one API flaw affects both.
-
What is an API gateway?
The gateway sits in front of the backend services, routing requests and handling auth, rate limiting and TLS in one place.
-
Why does testing the API matter so much on modern apps?
Web and mobile are both frontends over the same API, so a single backend flaw reaches every one of them.
3.9 · Browser DevTools
Every modern browser ships with Developer Tools ("DevTools"), opened with F12 or right-click → Inspect. It is free, already installed, and the first window into how a site really behaves — including the API calls you just learned about.
Three tabs matter early:
- The Elements tab shows the live HTML of the page — the DOM (Module 4).
- The Network tab records every request and response — page loads and, on a SPA, the background API calls (often filtered as "Fetch/XHR"). This is where you catch the JSON traffic behind a modern app.
- The Console tab shows JavaScript messages and lets you run snippets — where you ran
atob()in Module 1.
You will eventually add a dedicated tool such as Burp Suite, which sits between browser and server so you can pause and edit requests — including API requests — before they are sent. But DevTools is where the habit starts.
⌨ Try it yourself — catch an API call
- Open a modern web app (a bank, a social site), then DevTools (
F12) → Network tab, and click the Fetch/XHR filter. - Click around the app and watch small requests appear — many to paths containing
/api/. - Click one and look at its response: often JSON. You are watching the frontend talk to its backend API, live.
In short — DevTools (F12) is your first, free window: Elements shows the HTML, Network shows requests and responses — including a SPA's background API calls (Fetch/XHR) — and Console runs JavaScript. Later you add Burp Suite.
Quick check
-
Which DevTools tab lets you watch a SPA's background API calls?
Network shows every request the page makes; filter it to Fetch/XHR to isolate a SPA's background API calls.
-
How do you usually open browser DevTools?
DevTools is built in and free. Burp Suite is a separate, later tool.
-
What does Burp Suite add beyond DevTools?
Burp is an intercepting proxy: requests stop at your desk so you can change them — including API calls — before they are sent.
Module 3 glossary
- HTTP / HTTPS
- The web's request/response protocol; HTTPS is the encrypted version.
- Request / Response
- The client's ask and the server's answer — both plain text with headers.
- Method
- The action: GET (fetch), POST (send), PUT/DELETE (update/remove).
- Status code
- 2xx success, 3xx redirect, 4xx your fault, 5xx server's fault.
- Header
- A name-value line carrying extra detail (Host, Cookie, Authorization, Content-Type).
- URL
- Scheme, host, optional port, path, query string and fragment — e.g.
https://host/path?id=42#top. - Query string
- Everything after the
?—name=valuepairs joined by&. User-editable input. - Fragment
- Everything after the
#. Stays in the browser and is never sent to the server. - Session / Cookie
- A server-side "logged-in" record, and the ticket the browser sends to point to it.
- Authentication / Authorization
- Who you are (login) / what you may do (access).
- Traditional app
- Server-rendered — each click loads a whole new HTML page.
- SPA (single-page app)
- Loads once, then updates in place by fetching data from an API (React/Angular/Vue).
- Frontend / Backend
- What runs where you see it (browser/mobile) / the server holding data and logic.
- API / REST / endpoint
- The interface to the backend; REST endpoints (URLs) exchanging JSON.
- Three tiers
- Frontend displays, backend decides, database stores. All authorisation belongs in the middle tier.
- SOAP / GraphQL / gRPC
- Other API shapes: XML envelopes (older BFSI systems) / one endpoint the client queries by field / compact binary between internal services.
- Token / Bearer / JWT
- Identity carried in an Authorization header, common for APIs (instead of a cookie).
- API gateway
- The single front door in front of backend services — routing, auth, rate limiting, TLS.
- DevTools
- The browser's built-in inspector (F12): Elements, Network (incl. Fetch/XHR), Console.
Recap — what you can now do
- Describe the request/response conversation, methods, status codes and headers.
- Break a URL into scheme, host, port, path, query string and fragment, and say which part carries user input.
- Explain sessions and cookies (and that APIs often use tokens instead).
- Tell authentication from authorization, and why authz failures are serious.
- Recognise traditional apps vs SPAs, and know a SPA's logic lives in its background API calls.
- Explain the three tiers and the frontend/backend split, name the common API shapes (REST, SOAP, GraphQL, gRPC), say why the API is the real attack surface, and describe how one API behind a gateway serves both web and mobile.
End-of-module quiz
-
You open an app, and the DevTools Network tab fills with small
/api/calls returning JSON, with no full page reloads. What kind of app is this?Small JSON calls with no full reloads is the signature of an SPA talking to a backend API.
-
The web app hides a delete button from normal users, but
DELETE /api/users/5succeeds when called directly. The lesson?Hiding something on the frontend is not a control. The endpoint itself has to check whether the caller is allowed.
-
Why does one API flaw often affect both a company's website and its mobile app?
One backend serves many frontends, so a flaw in it is inherited by every client at once.
-
An API gateway mainly does what?
The gateway routes traffic to the right service and centralises auth, rate limiting and TLS.