KHAGAN AYDIN

The OWASP Top 10 for 2013, Explained

The list changed. The bugs did not.

· 6 min read

OWASP published the 2013 edition of its Top 10 on June 12. If you build or test web applications for a living, this list is the document your auditors, your customers and your next security questionnaire will quote at you for the next three years. So it is worth reading properly, not just the headings.

Below is how I read it: what each item means, what it looks like in a real application, and the single defense I would put in place first if I could only pick one.

What changed since 2010

Three things changed.

Insecure Cryptographic Storage and Insufficient Transport Layer Protection were merged into one item, Sensitive Data Exposure. The split never made sense to developers; they protect data in one place or they do not.

Failure to Restrict URL Access was renamed Missing Function Level Access Control, which is a better name because the problem was never about URLs. It is about functions a user can call without being allowed to.

And there is one new entry: Using Components with Known Vulnerabilities, at number nine. This is the one I would pay attention to. It is new because the way we build applications changed. A typical web application today is a thin layer of your own code on top of a thick stack of libraries and frameworks you did not write and rarely update. When one of those has a public bug, so does your application, and you may not even know the library is in there.

Here is the full list, in order.

A1. Injection

SQL, LDAP, OS command, XPath: any place where user input is glued into a command that another system interprets. Still number one, as it was in 2010, because it is still common, still serious, and among the easiest bugs to exploit once found.

What it looks like:

$q = "SELECT * FROM users WHERE email = '" . $_POST['email'] . "'";

The fix is not escaping. The fix is never building the command out of strings in the first place:

$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$_POST['email']]);

Parameterized queries, every time, with no exceptions for “internal” tools. The internal tool is the one that gets reached through the public one.

A2. Broken Authentication and Session Management

Session IDs in URLs, sessions that never expire, password reset flows that leak whether an account exists, passwords stored without proper hashing. This item covers a lot of ground, and in practice most of the findings are in the parts developers wrote themselves instead of using the framework’s session handling.

First defense: use your framework’s session and authentication features and do not write your own. If you must write your own, the session token goes in a cookie marked HttpOnly and Secure, it is rotated at login, and it is destroyed at logout on the server, not just in the browser.

A3. Cross-Site Scripting

The application takes input and later writes it into a page without encoding it for the place it lands. The attacker’s script runs in the victim’s browser with the victim’s session.

echo "Welcome back, " . $_GET['name'];

First defense: encode output for its context, every time. In PHP that is htmlspecialchars($name, ENT_QUOTES, 'UTF-8') for HTML; in a modern template engine, auto-escaping on by default. Content Security Policy is a second layer worth adding, but it is not a substitute for encoding.

A4. Insecure Direct Object References

The application exposes an internal identifier (an account number, a file name, a database key) and does not check that the current user may access that object.

GET /invoice?id=10234

Change the number, get someone else’s invoice. It turns up most often in the “view” and “download” paths that nobody thought of as sensitive.

First defense: every data access checks ownership on the server, against the logged-in user, not against anything the request says.

A5. Security Misconfiguration

Default accounts, directory listings, stack traces in error pages, debug modes left on, admin consoles on the public interface. Not a code bug; a deployment bug. It shows up when the people who wrote the application are not the people who run it, and nobody wrote down what “secure” looks like for the server.

First defense: a hardening checklist that is part of the deployment, not a document in a folder. If a human has to remember to turn off debug mode, debug mode will be on.

A6. Sensitive Data Exposure

Passwords hashed badly or not at all, card numbers stored when they did not need to be, backups unencrypted, login forms served over HTTP. The new merged item.

First defense: decide what you actually need to store. The safest card number is the one you never kept. For what remains: strong, slow password hashing (bcrypt or scrypt, with a per-user salt), TLS for everything that carries a session, and encryption at rest with keys that do not live next to the data.

A7. Missing Function Level Access Control

The user interface hides the admin button; the server does not check whether the user is an admin when the request arrives anyway.

POST /admin/deleteUser?id=42

If the only thing stopping a normal user from calling this is that the link is not shown to them, there is no control.

First defense: authorization on the server for every function, applied by default, with the list of who may call what written down and reviewed.

A8. Cross-Site Request Forgery

The victim is logged in to your site. The attacker’s page makes the victim’s browser send a request to your site. The browser attaches the session cookie, as it always does. Your site cannot tell the forged request from a real one.

First defense: a secret token in every state-changing form or request, generated per session, checked on the server. Most frameworks have this built in; the common finding is that it was turned off for one endpoint “temporarily.”

A9. Using Components with Known Vulnerabilities

New this year. An application running an old version of Struts, Spring, jQuery, a PHP CMS plugin, or OpenSSL with a published vulnerability is exploitable through that component regardless of how good the application’s own code is. Attackers do not need to find the bug; they read the advisory.

First defense: know what is in your application. An inventory of components and versions, checked against public vulnerability databases, on a schedule. There is tooling for this now (OWASP Dependency Check is one), but even a spreadsheet beats not knowing.

A10. Unvalidated Redirects and Forwards

GET /login?next=http://evil.example/phish

The user trusts your domain, clicks, and lands somewhere else. Low severity on its own, but it makes phishing against your users far more effective.

First defense: redirect only to a fixed list of destinations, or to relative paths on your own site. Never to a full URL from the request.

What the list is for

Two warnings about how people use this document.

It is not a checklist that makes you secure. It is the ten categories most likely to hurt you, chosen by frequency and impact. An application can pass all ten and still have a business logic flaw that lets one customer pay with another customer’s balance; that is not on the list because it is different in every application.

And it is not a scoring system. I see teams count how many of the ten they have “covered.” The right question for each item is not “did we think about it” but “where in our code could this happen, and what prevents it there.” Answer that for ten items and you have a threat model. Answer it for none and the list is wallpaper.

Every bug on this list except the components item was on the 2010 list, and most were on the 2007 list. The names change; the mistakes repeat because the same shortcuts are still faster than the right way. The job is to make the right way the default so nobody has to remember.