Module 11 · Web Application Security · Lesson 31 of 75
How web applications work, and where they break
Requests and responses, cookies and sessions, tokens, the same-origin policy and CORS, APIs, and the OWASP Top 10 risk areas.
In this lesson · about 40 minutes
- Follow a login from browser to server and back
- Explain cookies, sessions, JWTs and their security flags
- Name the OWASP Top 10 risk areas
A request and a response
POST /api/login HTTP/1.1
Host: shop.lab.test
Content-Type: application/json
Cookie: lang=en
{"email":"alice@lab.test","password":"Lab-Pass-1"}
HTTP/1.1 200 OK
Set-Cookie: session=7f3a9c...; HttpOnly; Secure; SameSite=Lax; Path=/
Content-Type: application/json
{"user":"alice","role":"customer"}
Sessions and tokens
- Session cookie: a long random ID; the server keeps the session data. Protect it with flags: HttpOnly (JavaScript cannot read it, which limits XSS damage), Secure (HTTPS only), SameSite (not sent on most cross-site requests, which limits CSRF).
- JWT (JSON Web Token):
header.payload.signature, Base64URL-encoded. The payload is readable by anyone (it is encoded, not encrypted); the signature stops tampering. Classic mistakes: accepting"alg":"none", weak signing secrets, and never expiring tokens. - Sessions must be regenerated at login (or an attacker who planted a session ID before login can ride it), expire after inactivity, and be invalidated at logout on the server.
Same-origin policy and CORS
The browser's same-origin policy stops a script from one origin (scheme + host + port) reading responses from another. That is what keeps a malicious site from reading your webmail. CORS headers let a server deliberately relax it. A server that reflects any Origin and also sends Access-Control-Allow-Credentials: true lets any website read users' private data.
APIs
Modern apps are a front end calling JSON APIs (REST or GraphQL). APIs often expose more than the screen shows: object IDs, admin functions, extra fields. The OWASP API Security Top 10 lists their specific risks, led by broken object-level authorisation.
The OWASP Top 10 risk areas
OWASP publishes a list of the most critical web application risks, updated every few years from real data. The areas that appear again and again:
- Broken access control: users acting outside their permissions (consistently the number-one risk).
- Security misconfiguration: default accounts, verbose errors, open cloud storage, missing headers.
- Cryptographic failures: data sent or stored without proper encryption.
- Injection: SQL, command and other injection, including cross-site scripting.
- Insecure design: missing security thinking at the design stage (no rate limit on password reset).
- Vulnerable and outdated components / supply chain: libraries and dependencies with known flaws.
- Identification and authentication failures: weak login, session and credential handling.
- Software and data integrity failures: unsigned updates, unsafe deserialisation, insecure pipelines.
- Logging and monitoring failures: attacks that nobody notices.
- Server-side request forgery and poor handling of errors and unexpected conditions.
Sorting drill
Which cookie flag helps?
Pick the flag that best addresses each worry.
- An XSS payload tries document.cookie to steal the session
- A user on café Wi-Fi visits the http:// version of the site
- A malicious site auto-submits a form to the bank's transfer page
0 of 3 sorted
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.