Web application security

Lesson 01 · 13 min

OWASP Top 10, the attacker mindset and access control

Where the OWASP list comes from, how to model threats and why IDOR is still number one.

13 minLesson 1 of 5Practice includedAsk AI on any point

OWASP (Open Worldwide Application Security Project) is an open community that publishes free security guides. The best known of them, the OWASP Top 10, is a list of the most common and most dangerous categories of web application vulnerabilities. It is built from data on hundreds of thousands of real applications and surveys of practitioners. This course follows the 2021 edition, which is still the one most often cited in requirements and in interviews.

This course continues the "Authorization and security" course, which covers the basics of cookies, sessions, JWT, CORS and a first look at XSS and SQL injection. Here we go deeper: what these attacks look like in real code, where exactly popular frameworks break, and how to close a hole properly rather than cosmetically.

AI

You can ask about this point«Lesson summary»

OWASP Top 10:2021

  • A01 Broken Access Control: a user sees or changes someone else's data. This lesson.
  • A02 Cryptographic Failures: unencrypted data, weak algorithms, plaintext passwords. Lesson 4.
  • A03 Injection: SQL, OS commands, and also XSS, which was merged into this category in 2021. Lessons 2 and 3.
  • A04 Insecure Design: the flaw is in the logic itself, not in the code. The cure is threat modeling, covered below.
  • A05 Security Misconfiguration: default passwords, debug mode left on, open buckets, missing headers. Lesson 5.
  • A06 Vulnerable and Outdated Components: old dependencies with known CVEs. Lesson 5.
  • A07 Identification and Authentication Failures: password guessing, weak sessions, no MFA. Lesson 4.
  • A08 Software and Data Integrity Failures: unverified updates, CI/CD and packages trusted blindly. Lesson 5.
  • A09 Security Logging and Monitoring Failures: an attack runs for weeks and nobody notices. Lesson 4.
  • A10 Server-Side Request Forgery (SSRF): the server fetches a URL supplied by the user. Lesson 5.
AI

You can ask about this rule«The list gets updated»

AI

You can ask about this point«OWASP Top 10:2021»

Course plan

  • Lesson 1. The Top 10, threat modeling, access control and IDOR.
  • Lesson 2. Injection: SQL, OS commands, ORM and NoSQL pitfalls.
  • Lesson 3. XSS and CSRF: three kinds of XSS, output encoding, CSP, SameSite, CSRF tokens.
  • Lesson 4. Authentication and secrets: password hashing, rate limiting, MFA, secrets out of git, key rotation, logging and monitoring.
  • Lesson 5. SSRF, file uploads, security headers, CORS, dependencies and the supply chain.
AI

You can ask about this point«Course plan»

The attacker mindset

A developer thinks: "how do I make this work". An attacker thinks: "what happens if I send something unexpected". Everything that comes from the client is fully under their control: the URL, parameters, request body, headers, cookies, file name, even a role field in the JSON that the form does not have. The frontend is not a defense: a browser side check is bypassed with a single curl request.

AI

You can ask about this rule«Never trust the client»

AI

You can ask about this point«The attacker mindset»

Threat modeling

Threat modeling is the habit of asking four questions before writing code: what are we building, what can go wrong, what are we going to do about it, and did we do a good job. It is enough to draw a data flow diagram (browser, API, database, third party services) and walk through every arrow. For "what can go wrong" the STRIDE acronym is handy:

  • Spoofing: pretending to be someone else. Defense: authentication.
  • Tampering: changing data in transit or in the database. Defense: signatures, integrity checks, permissions.
  • Repudiation: "it wasn't me". Defense: an audit log.
  • Information disclosure: a data leak. Defense: encryption, access control.
  • Denial of service: taking the service down. Defense: limits, timeouts, queues.
  • Elevation of privilege: a regular user becomes an admin. Defense: permission checks on every request.
AI

You can ask about this point«Threat modeling»

Broken Access Control and IDOR

IDOR (Insecure Direct Object Reference): the server takes an identifier from the request and returns the object without checking whether it belongs to the current user. The user sees /api/invoices/1042, changes it to 1043 and reads someone else's invoice. Authentication works perfectly here: the user is real, the object just is not theirs.

Vulnerable and fixed

Even more reliable: build the owner right into the database query. Then forgetting the check is impossible, because someone else's row simply will not be found.

Owner in WHERE
AI

You can ask about this rule«UUIDs do not replace the check»

AI

You can ask about this point«Broken Access Control and IDOR»

Other forms of broken access

  • Privilege escalation through the request body (mass assignment): PATCH /me with a field role: admin, and the server saves the whole object. Fixed with an allowlist of fields.
  • Admin routes without a role check: there is no button in the UI, but DELETE /api/users/7 works for everyone.
  • Trusting hidden fields: price or userId from the form instead of values from the session and the database.
  • Resources open by default: a new page or endpoint without middleware is automatically available to everyone.
An allowlist of fields instead of the whole body
AI

You can ask about this rule«Deny by default»

AI

You can ask about this point«Other forms of broken access»

Check

Lock it in before you move on

  1. 1. A user changes /api/orders/15 to /api/orders/16 and sees someone else's order. What is this called?

  2. 2. Does switching from numeric ids to UUIDs fix IDOR?

  3. 3. The delete button was hidden from regular users. What is missing?

  4. 4. Which letter of STRIDE covers "a regular user got admin rights"?

PracticeSolve the lesson tasksA few short tasks in the editor. Check your code right away and see where it goes wrong.Start practice