WEB-230 · Lesson 2 of 12 · 24 min

The OWASP Top 10 for developers

▶ Video coming soon A video version of this lesson is on the way.

On Thursday, January 18, Theo brings a printout to the second session. It is the OWASP Top 10, a list published by the Open Worldwide Application Security Project, a non-profit community that writes free guides, tools and standards for building secure software. The Top 10 is OWASP's best-known document: a ranking of the most important kinds of risk to web applications, built from data contributed by organizations that test thousands of applications, plus a survey of practitioners for problems that testing data underestimates. It is updated every few years. The 2025 edition, published at the end of 2025, is the current one, and it is the list the review will use.

Theo is careful about what the list is and is not. It is an awareness document: a shared vocabulary and a reminder of where problems cluster. It is not a complete standard, and an application can avoid every item on it and still be insecure. For a full checklist, OWASP publishes the Application Security Verification Standard (ASVS). For the Food Hub, the Top 10 is the right size: ten headings under which to organize what the team finds.

The 2025 list

OWASP Top 10, 2025 edition
RankCategoryIn one sentence
A01Broken Access ControlUsers can see or do things they should not, such as another agency's orders.
A02Security MisconfigurationUnsafe settings: debug pages on, default accounts, missing headers, open storage.
A03Software Supply Chain FailuresWeak or compromised dependencies, build tools, registries or update channels.
A04Cryptographic FailuresSensitive data not protected, or protected with weak or misused cryptography.
A05InjectionUntrusted data is interpreted as code or commands: SQL, shell, or script in a page.
A06Insecure DesignThe design itself is unsafe, so no amount of careful coding can fix it.
A07Authentication FailuresWeak sign-in, guessable passwords, sessions that are not protected or ended.
A08Software or Data Integrity FailuresTrusting code or data that has not been checked, such as unsigned updates.
A09Security Logging and Alerting FailuresAttacks are not recorded, or nobody is told when they happen.
A10Mishandling of Exceptional ConditionsErrors, timeouts and unexpected input handled in unsafe ways.
Ten horizontal bars labeled A01 to A10 with the 2025 category names. Arrows show that 2021's Vulnerable and Outdated Components grew into A03 Software Supply Chain Failures and that A10 Mishandling of Exceptional Conditions is new.
The 2025 list, with what changed since 2021

Two changes from the 2021 edition matter for the Food Hub. The old category for vulnerable and outdated components has grown into Software Supply Chain Failures, which now covers the whole path code takes to reach production: dependencies, build systems, package registries and distribution. JS-260's pipeline work and lesson 8 of this course both live there. And there is a new final category, Mishandling of Exceptional Conditions, for what happens when things go wrong: errors that leak details, code that carries on after a failure, and resources that are exhausted by unexpected input. Security misconfiguration has also moved up to second place, a reminder that many real breaches start with a setting rather than a clever bug.

A01 Broken Access Control

Broken access control has been first since 2021, and Theo starts with it because it is the Food Hub's highest risk. Authentication answers the question "who are you?"; authorization, or access control, answers "are you allowed to do this?". The commonest failure is to check the first and forget the second. A signed-in agency coordinator asks for order 418, and the server returns it because the request had a valid session, without asking whether order 418 belongs to that coordinator's agency.

This pattern has its own name: an insecure direct object reference, or IDOR. The API in JS-240 used order numbers in its addresses, which is normal; the defense is not to hide the numbers but to check, on every request, that the object belongs to someone the user may act for. OWASP's API guidance calls this object-level authorization, and the 2025 CWE Top 25 ranks missing authorization fourth among all software weaknesses.

JavaScript Example · Checking access to each object
// Object-level authorization: a valid session is not enough.
const orders = {
  418: { agency: 'northside', trays: 6 },
  419: { agency: 'westview', trays: 4 },
};

function canView(user, order) {
  if (!order) return false;
  if (user.roles.includes('kitchen-staff')) return true;          // Rosa's team sees every order
  return user.roles.includes('partner-staff') && user.agency === order.agency;
}

const priya = { name: 'Priya', agency: 'westview', roles: ['partner-staff'] };
const rosa = { name: 'Rosa', agency: null, roles: ['kitchen-staff'] };

for (const id of [418, 419, 500]) {
  console.log(`order ${id}: Priya ${canView(priya, orders[id]) ? 'allowed' : 'denied'}, Rosa ${canView(rosa, orders[id]) ? 'allowed' : 'denied'}`);
}
Output
order 418: Priya denied, Rosa allowed
order 419: Priya allowed, Rosa allowed
order 500: Priya denied, Rosa denied

What this code does

The check looks at the object as well as the user: a partner-staff account may view an order only when the order's agency matches the user's agency. Kitchen staff are allowed every order because their job needs it. A missing order is denied rather than causing an error, which is the safe default.

Theo's rule for the partner service is that every handler that reads or changes an order calls one function like this, and that the tests include a request for another agency's order that must be refused. Access checks scattered through templates or front-end code are how one gets forgotten. Two other forms of broken access control are worth naming: function-level failures, where a partner-staff account can reach an admin action simply by knowing its address, and default allow, where a new route is open until someone remembers to protect it. The safe design is the opposite: deny by default, and open each route deliberately.

A02 Security Misconfiguration

Misconfiguration is any setting that weakens the system: a framework's debug mode left on so that error pages show source code and settings, an administration page reachable from the internet, a storage bucket that anyone can list, default passwords, directory listing, or missing security headers. It is common because every layer has settings and the defaults are chosen for convenience, not safety. The defenses are boring and effective: start from a hardened baseline, keep configuration in code and review it like code, turn off what is not used, and check production settings automatically, which is what the start-up checks of JS-260 began.

A05 Injection and A04 Cryptographic Failures

Injection happens whenever data is combined with code as text and the result is interpreted. The studio has its own example: the 2014 newsletter script that Theo found in November 2026, which built an SQL statement by joining strings. It was never known to have been attacked, but any name containing a quote mark would have broken it, and a crafted value could have changed the query's meaning. Cross-site scripting is injection into a web page; lesson 3 deals with SQL and other interpreters, and lesson 4 with pages.

Cryptographic failures cover data that should be protected and is not: personal details sent without HTTPS, passwords stored with a fast hash or none, keys kept in the repository, or home-made encryption. The Food Hub's managed database encrypts its storage and every connection uses TLS, and the JS-240 work stored passwords with scrypt. The review's job here is mostly to confirm that nothing has been missed, such as a backup copied somewhere without encryption.

A06 Insecure Design and A07 Authentication Failures

Some problems cannot be fixed by careful coding because the design itself is unsafe. If the partner service let an agency set its own tray limit in the request, no validation would help: the design trusts the wrong party. JS-240's fair-share rule, which caps any agency at 16 of the day's 40 trays on the server, is the opposite, a design decision that removes a whole class of abuse. Threat modeling, as in lesson 1, is the main defense against insecure design. Authentication failures, which include weak password rules, unlimited guessing and sessions that never end, are the subject of lesson 6.

A08 to A10: integrity, logging and exceptional conditions

Software or data integrity failures happen when code or data is trusted without being checked: a script loaded from someone else's server without an integrity hash, an update downloaded without a signature, or serialized data from a user turned back into objects. Lesson 8 returns to this. Logging and alerting failures are what made the September 2028 board outage last forty minutes: something went wrong and nobody was told. JS-260's structured logs and alerts were the fix there, and the same tools record security events, such as repeated failed sign-ins.

The new tenth category deserves a closer look because it is about the code developers write every day. What does a service do when a dependency throws an error, a request times out or an input is far larger than expected? Code that fails open carries on as if the check had passed. Code that fails closed refuses. For security checks, failing closed is almost always right.

JavaScript Example · Failing closed
// Fail open versus fail closed when the permission lookup throws.
function lookupRoles(user) {
  if (user === 'board-tablet') throw new Error('directory timeout');
  return user === 'rosa' ? ['kitchen-staff'] : ['partner-staff'];
}

function failOpen(user) {
  try { return lookupRoles(user).includes('kitchen-staff'); }
  catch { return true; }                 // "something went wrong, let them in"
}

function failClosed(user) {
  try { return lookupRoles(user).includes('kitchen-staff'); }
  catch (err) { console.log(`  denied: ${err.message}`); return false; }
}

for (const user of ['rosa', 'priya', 'board-tablet']) {
  console.log(user, 'open:', failOpen(user));
  console.log(user, 'closed:', failClosed(user));
}
Output
rosa open: true
rosa closed: true
priya open: false
priya closed: false
board-tablet open: true
  denied: directory timeout
board-tablet closed: false

What this code does

Both functions ask the same question, but they differ in what happens when the lookup throws. The fail-open version grants access whenever anything goes wrong, so a timeout becomes a way in. The fail-closed version records the reason and refuses, which costs one user a retry instead of exposing every order.

Error messages are part of the same category. A sign-in page that says "no account with that e-mail" for one mistake and "wrong password" for another tells anyone which addresses are registered. An error page that prints a stack trace tells an attacker which framework, version and file paths are in use. The rule is to log the details on the server, with a request id, and show the user a short, honest message that includes the id so staff can find the log entry.

JavaScript Example · Safe error responses
// Log the detail, show the user a safe message with a reference.
let counter = 4100;
const log = [];

function handleError(err, requestPath) {
  const ref = `ERR-${++counter}`;
  log.push({ ref, path: requestPath, message: err.message, stack: err.stack.split('\n')[0] });
  return { status: 500, body: `Something went wrong on our side. Please try again, or quote ${ref} if you contact us.` };
}

const res = handleError(new Error('relation "agency_quota" does not exist'), '/api/v1/orders');
console.log(res.status, res.body);
console.log('server log:', JSON.stringify(log[0]));
Output
500 Something went wrong on our side. Please try again, or quote ERR-4101 if you contact us.
server log: {"ref":"ERR-4101","path":"/api/v1/orders","message":"relation \"agency_quota\" does not exist","stack":"Error: relation \"agency_quota\" does not exist"}

What this code does

The user's message says something failed and gives a reference, but reveals nothing about tables, code or versions. The full detail goes to the server log under the same reference so staff can find it. Keeping the two apart is how an application stays helpful without handing out a map of its internals.

Mapping findings to the list

As the review goes on, each finding will be filed under a Top 10 category. That does two things for Paul's report. It shows the board which kinds of problem the Food Hub has, in terms an auditor or insurer will recognize. And it shows patterns: three findings under A01 would suggest a missing design habit, not three separate slips. Mira sets up the findings file with a category field, and Theo adds the first entries from what he already knows.

JavaScript Example · Filing findings by category
// Group the first findings by OWASP 2025 category.
const findings = [
  { id: 'F1', cat: 'A01', title: 'Portal shift export lists other volunteers\' phone numbers' },
  { id: 'F2', cat: 'A02', title: 'Staging PHP app shows detailed error pages' },
  { id: 'F3', cat: 'A05', title: 'Old newsletter script still in the repository' },
  { id: 'F4', cat: 'A01', title: 'Board refresh endpoint does not check the device role' },
  { id: 'F5', cat: 'A09', title: 'No alert on repeated failed partner sign-ins' },
];

const byCat = new Map();
for (const f of findings) {
  if (!byCat.has(f.cat)) byCat.set(f.cat, []);
  byCat.get(f.cat).push(f.id);
}
for (const cat of [...byCat.keys()].sort()) {
  console.log(cat, byCat.get(cat).join(' '));
}
Output
A01 F1 F4
A02 F2
A05 F3
A09 F5

What this code does

Each finding carries its category, and a Map collects the finding ids under each one. Sorting the keys prints the categories in list order. Two findings under A01 already suggest that access checks need a shared function and a standard test.

The other list Theo keeps nearby is the CWE Top 25, published by MITRE with the United States Cybersecurity and Infrastructure Security Agency. CWE, the Common Weakness Enumeration, is a catalog of specific software weaknesses, each with a number. Where the OWASP Top 10 names broad categories of risk, CWE names the precise mistakes, and the Top 25 ranks them by how often and how seriously they appear in published vulnerabilities. In the 2025 list, the first four places are cross-site scripting (CWE-79), SQL injection (CWE-89), cross-site request forgery (CWE-352) and missing authorization (CWE-862), which is almost exactly the agenda for lessons 3 to 5.

Web weaknesses in the 2025 CWE Top 25
2025 CWE rankWeaknessLesson
1CWE-79 Cross-site scripting4
2CWE-89 SQL injection3
3CWE-352 Cross-site request forgery5
4CWE-862 Missing authorization2
6CWE-22 Path traversal3
12CWE-434 Unrestricted upload of dangerous file types3

Many of the other weaknesses on the CWE list, such as out-of-bounds writes and use after free, belong to languages like C that manage memory by hand. JavaScript and PHP prevent those by design, which is one reason web developers can concentrate on the categories above.

Worked problem

Choosing what to fix first

The review has five early findings with risk scores from lesson 1's matrix: F1 (A01) 6, F2 (A02) 4, F3 (A05) 2, F4 (A01) 6, F5 (A09) 3. Theo wants to fix all high findings in the first week and to know what share of the total risk score that removes. What is the total, and what share do the high findings represent?

Show solution
  1. High findings (6 or more): F1 and F4, 6 + 6 = 12.
  2. Total score: 6 + 4 + 2 + 6 + 3 = 21.
  3. Share removed: 12 ÷ 21 ≈ 0.571, or about 57 in 100.

Answer: Fixing the two access control findings removes 12 of the 21 points, about 57 in 100 of the scored risk, and both fall under A01.

Common mistakes

  • MistakeChecking that a user is signed in and assuming that is enough.

    InsteadCheck authorization for every object and action: is this user allowed this order?

  • MistakeHiding object numbers to protect them.

    InsteadUse normal ids and check ownership on the server for every request.

  • MistakeCatching an error in a security check and carrying on.

    InsteadFail closed: refuse the action when a check cannot be completed.

  • MistakeShowing stack traces or database errors to users.

    InsteadLog the detail with a reference and show a short, safe message with the reference.

  • MistakeTreating the Top 10 as a complete checklist.

    InsteadUse it to organize findings and awareness; use ASVS or a fuller standard for verification.

Summary and key terms

  • The OWASP Top 10 ranks the most important kinds of web application risk, and the 2025 edition is current.
  • Broken access control remains first: authorization must be checked for every object and action, not just whether a user is signed in.
  • Security misconfiguration is second, and software supply chain failures, third, now cover the whole path from dependency to production.
  • Injection, cryptographic failures, insecure design, authentication failures, integrity failures and logging failures complete the familiar list, with Mishandling of Exceptional Conditions new at tenth.
  • Security checks should fail closed, and error responses should log details while showing users a safe message with a reference.
  • The CWE Top 25 names precise weaknesses; in 2025 its top four were XSS, SQL injection, CSRF and missing authorization.
OWASP
The Open Worldwide Application Security Project, a non-profit community that publishes free application security guides and tools.
Authorization
Deciding whether an identified user may perform an action on a particular object.
Insecure direct object reference (IDOR)
Access to an object by its id without checking that the user may access that object.
Deny by default
A design in which every route or action is refused unless access has been granted deliberately.
Fail closed
Refusing an action when a check cannot be completed, rather than allowing it.
CWE
The Common Weakness Enumeration, a numbered catalog of software weaknesses.
ASVS
OWASP's Application Security Verification Standard, a detailed list of security requirements to test against.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Why did OWASP rename Vulnerable and Outdated Components?

    Show answer

    The 2025 category, Software Supply Chain Failures, covers the whole path code takes to production, including builds, registries and distribution.

  2. What question does authorization answer that authentication does not?

    Show answer

    Whether this user may do this action on this particular object.

  3. What is wrong with a sign-in error that says no account uses that e-mail?

    Show answer

    It tells anyone which addresses are registered.

  4. Which four weaknesses led the 2025 CWE Top 25?

    Show answer

    Cross-site scripting, SQL injection, cross-site request forgery and missing authorization.

Try it yourself

Can this user change the order?

Complete canEdit(user, order, now). Kitchen staff may always edit. Partner staff may edit only their own agency's orders, and only while now is before the order's cutoff (both are numbers of hours).

Return false if the order is missing.

function canEdit(user, order, now) {
  return true;
}

const kitchen = { agency: null, roles: ['kitchen-staff'] };
const priya = { agency: 'westview', roles: ['partner-staff'] };
const order = { agency: 'westview', cutoff: 12 };
console.log(canEdit(priya, order, 10), canEdit(priya, order, 13), canEdit(priya, { agency: 'northside', cutoff: 12 }, 10));
console.log(canEdit(kitchen, order, 13), canEdit(priya, undefined, 10));

Try it yourself

Fail closed

checkQuota(agency) sometimes throws. Complete mayOrder(agency) so that it returns the result of checkQuota when that works, and returns false when it throws.

Print what happens for three agencies.

function checkQuota(agency) {
  if (agency === 'elm-seniors') throw new Error('quota service unavailable');
  return agency === 'westview';
}

function mayOrder(agency) {
  return checkQuota(agency);
}

for (const a of ['westview', 'northside', 'elm-seniors']) {
  let result;
  try { result = mayOrder(a); } catch { result = 'crashed'; }
  console.log(a, result);
}

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz