Security & Identity
OWASP Top 10: The Ten Risk Categories and How to Fix Each One
Intermediate8 min readUpdated
The OWASP Top 10 is an awareness document that names the risk categories responsible for most web application compromise. This guide walks through each category with a realistic example of the flaw and the specific fix in a Java and web stack, then explains how to use the list as a starting point rather than a checklist and where the Application Security Verification Standard takes over.
What you will learn
- Recognise each OWASP Top 10 category in real application code
- Apply the concrete mitigation for broken access control, injection and cryptographic failures
- Distinguish insecure design from implementation bugs and respond to each appropriately
- Manage dependency and supply-chain risk with an SBOM and reproducible builds
- Use ASVS to turn awareness into testable security requirements
The OWASP Top 10 is the most widely cited document in application security, and also the most widely misused. It is a periodically revised, data-informed ranking of the weakness categories that show up most often in real applications — a way of directing attention, written for awareness rather than certification. Read that way it is genuinely valuable: the categories are broad enough to survive changes in framework fashion, and each one names a class of mistake that has cost organisations a great deal.
What follows is each category with a concrete flaw of the kind that appears in ordinary code, and the specific control that removes it. The framing throughout is defensive: enough about how the weakness is exercised to recognise it in review, paired with the fix. Where a topic deserves depth beyond a summary, it links onward — the architectural view is in application security architecture, and API-specific token handling in securing REST APIs with JWT.
Broken access control
The perennial number one: an authenticated user reaching data or operations that belong to someone else. The classic shape is an identifier taken straight from the request and used to fetch a record, with no check that the record belongs to the caller.
// Flawed: any authenticated user can read any invoice by changing the number
@GetMapping("/invoices/{id}")
public Invoice get(@PathVariable long id) {
return invoices.findById(id).orElseThrow(NotFoundException::new);
}
// Fixed: the query is scoped to the authenticated principal
@GetMapping("/invoices/{id}")
public Invoice get(@PathVariable long id, Authentication auth) {
return invoices.findByIdAndCustomer(id, auth.getName())
.orElseThrow(NotFoundException::new); // 404 rather than 403: reveal nothing
}
Related variants: privilege escalation through an unprotected admin route, a role or tenant identifier accepted from a request parameter, forced browsing to an endpoint the UI never links to, and directory traversal in a file download. The controls are structural — deny by default so a new route is protected until it is opened, scope every query by the principal, derive tenancy from the token rather than the payload, and write a test per endpoint asserting that another user's identifier returns 404. Method-level rules on the service, as shown in Spring Security basics, catch what URL patterns miss.
Cryptographic failures
This category is about sensitive data that is not protected as it should be: transmitted in clear, stored unencrypted, or protected with something that only looks like cryptography. Typical findings are an internal service still accepting plain HTTP, database backups written unencrypted to shared storage, card or health data retained long after it was needed, passwords stored with a fast hash, and home-grown "encryption" built from XOR or base64.
Fix it by classifying data first — you cannot protect what you have not identified — then requiring TLS 1.3 everywhere including inside the network, encrypting at rest with keys held in a managed key service, hashing passwords with a memory-hard function, and using authenticated encryption such as AES-GCM with a unique nonce per message rather than raw block ciphers. Delete what you no longer need; data you do not hold cannot leak. The primitives themselves are explained in information security fundamentals.
Injection
Injection happens whenever untrusted input is concatenated into something an interpreter parses — SQL, an OS command, LDAP filters, XPath, template expressions. The database case remains the most damaging.
// Flawed: the input becomes part of the statement
String sql = "SELECT * FROM users WHERE email = '" + email + "'";
// Fixed: the value can never change the statement's structure
String sql = "SELECT id, email, display_name FROM users WHERE email = ?";
jdbcTemplate.query(sql, ps -> ps.setString(1, email), USER_MAPPER);
Parameterised statements are the answer wherever the interpreter supports them; the practices around them are covered in SQL best practices. Where structure genuinely varies — a sort column, a table name — validate against an allow-list of known identifiers rather than escaping. For operating-system calls, pass an argument array instead of a shell string. Cross-site scripting belongs here too: the interpreter is the browser, and the fix is contextual output encoding done by the templating engine plus a Content Security Policy that forbids inline script as a second layer.
Insecure design
This category exists to separate flaws in the design from flaws in the code. A password reset that verifies identity with questions an attacker can research, a booking flow with no limit on how many seats one session may hold, a refund path with no second approval — all of these can be implemented flawlessly and still be exploitable, because the mechanism itself is inadequate.
Nothing found in code review fixes them. The response is threat modelling before implementation, abuse cases written next to user stories, reference architectures for recurring problems such as authentication and payment, and limits designed into flows rather than added after an incident. Treat "this is working as specified" as a finding when the specification is the problem.
Security misconfiguration
The most common real-world cause of exposure, and the easiest to fix: default administrative credentials still active, verbose error pages showing stack traces in production, directory listing enabled, an actuator or management endpoint reachable without authentication, an overly permissive CORS policy, cloud storage open to the internet, missing security headers.
# Production profile: expose the minimum, say nothing useful to an attacker
server:
error:
include-stacktrace: "never"
include-message: "never"
management:
endpoints:
web:
exposure:
include: "health,info"
endpoint:
health:
show-details: "when-authorized"
Harden by building environments from code so that configuration is reviewable and identical everywhere, removing sample applications and unused features, running a configuration scan in the pipeline, and setting the standard response headers — Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, a restrictive Referrer-Policy. Automate it: a checklist applied by hand drifts within a month.
Vulnerable and outdated components
Modern applications are mostly other people's code, and a known vulnerability in a widely deployed library is scanned for at internet scale within hours of disclosure. The risk is not exotic; it is a framework three major versions behind, a transitive dependency nobody knew was there, or a base image that has not been rebuilt in a year.
Generate a software bill of materials at build time, scan every commit against an advisory database, and automate routine upgrades so humans only handle the hard ones. Prefer libraries with an active maintenance record, remove dependencies you have stopped using, and rebuild container images regularly so operating-system packages stay current. Continuous integration is the right place for all of this — see continuous integration for how to keep such checks fast enough that nobody disables them.
Identification and authentication failures
Weaknesses in proving who someone is: credential stuffing against a login with no rate limiting, session identifiers that survive a privilege change, tokens that never expire, a password reset link valid for days and reusable, multi-factor authentication that can be skipped by calling a legacy endpoint.
The controls are well understood — screen passwords against breach lists instead of imposing composition rules, offer phishing-resistant multi-factor authentication, regenerate the session identifier on login, expire and invalidate sessions on logout and on password change, make reset tokens single-use and short-lived, apply escalating delays rather than permanent lockouts, and keep messages identical whether or not an account exists. The full picture is in identity and access management.
Software and data integrity failures
This category covers trusting code or data whose provenance you have not verified: a build pulling a plugin from an unpinned source, a pipeline with write access to production and no review on its own configuration, an auto-update mechanism without signature checking, and — the classic application-level case — deserialising attacker-controlled data into arbitrary types.
// Flawed: native deserialisation of untrusted bytes can instantiate whatever the classpath allows
Object payload = new ObjectInputStream(request.getInputStream()).readObject();
// Fixed: a data format with no type resolution, bound to a known shape
OrderRequest payload = jsonMapper.readValue(request.getInputStream(), OrderRequest.class);
Beyond that, pin dependency versions with checksums, sign artefacts and verify signatures before deployment, keep build systems under the same access control as production, and disable polymorphic type handling in JSON libraries unless a specific need justifies it and an allow-list constrains it.
Security logging and monitoring failures
Not a way in, but the reason a breach lasts months instead of hours. The symptoms are recognisable: failed logins not recorded, no alerting on authorization denials or unusual data volumes, logs held only on the machine that produced them, and no clock synchronisation to correlate across services.
Log authentication attempts, access-control denials, privilege changes, administrative actions and input validation failures at the boundary, with actor, action, target, outcome, timestamp and correlation identifier. Ship them off the host to a store the application cannot rewrite, retain them long enough to investigate, and alert on patterns rather than single events. Then rehearse: an alert nobody has ever responded to is not a control. And be careful what you write — passwords, tokens and personal data in logs create a second copy of the data with weaker protection.
Server-side request forgery
SSRF occurs when an application fetches a URL supplied by a user — a webhook target, an image importer, a document converter — and the attacker points it inward, at internal services or a cloud metadata endpoint that hands out credentials to anything that asks from the instance.
Mitigate in layers, because URL validation alone is famously leaky: validate against an allow-list of permitted hosts rather than a deny list, resolve the hostname and check the resulting address is public before connecting, disable redirect following or revalidate each hop, require the expected scheme, and give the fetching component network egress rules that permit only what it legitimately needs. On cloud instances, require the hardened metadata service that demands a session token. Return a generic result to the caller so response content and timing do not become an internal port scanner.
Using the list well
Three habits separate teams that benefit from the Top 10 from teams that merely quote it.
Treat it as a starting point, not a finish line. It is a ranking of common categories, not a specification of sufficiency. Absence of these ten weaknesses does not mean an application is secure; your business logic has risks no general list can name.
Turn awareness into requirements. The Application Security Verification Standard is the companion document for that: several hundred testable requirements organised by topic, with three levels of rigour so a team can pick the one matching its risk. Select a level, adopt the relevant requirements as acceptance criteria, and you have replaced "we considered OWASP" with statements a reviewer can verify. The API Security Top 10 does the same job for API-specific risks.
Automate the parts that can be automated, and review the parts that cannot. Dependency and configuration scanning belong in the pipeline alongside static analysis; access control and business-logic flaws need people who understand the domain. Above all, write a regression test for every security defect you fix, so the same weakness cannot return under a new feature.
Key takeaways
- The Top 10 is an awareness ranking of weakness categories, not a standard — use ASVS when you need testable requirements.
- Broken access control leads the list because it is domain-specific and invisible to scanners; deny by default, scope queries by principal and test with a second user.
- Injection is solved by keeping data out of the interpreter's grammar: parameterised statements, argument arrays and contextual output encoding.
- Insecure design cannot be coded around; threat modelling and abuse cases are the only fix.
- Misconfiguration and outdated components are the highest-yield categories to automate, through infrastructure as code, SBOMs and dependency scanning on every commit.
- Logging, monitoring and rehearsed response decide how long a breach lasts, and SSRF needs layered defence at both the URL and the network level.
Sources and further reading
Frequently asked questions
- Is the OWASP Top 10 a security standard?
- No, and OWASP says so explicitly. It is an awareness document derived from data about which weakness categories appear most often, intended to start conversations and set priorities. A team that fixes all ten still has work to do. When you need testable requirements — something a reviewer can pass or fail a build on — the Application Security Verification Standard is the document written for that purpose.
- Why is broken access control consistently first?
- Because it cannot be found by pattern matching. An automated scanner sees a request returning data and has no way to know whether that user was entitled to it; only someone who understands the domain can say. Access control is also spread across every endpoint, so a single new route added without the check reopens the risk regardless of how good the rest of the application is.
- How do I keep on top of vulnerable dependencies?
- Generate a software bill of materials at build time, run a dependency scanner on every commit against a maintained advisory database, and automate the routine upgrades so that only the difficult ones need human attention. Pin versions and verify checksums so a build is reproducible, remove libraries you no longer use, and track the transitive graph rather than only direct declarations.
- What is the difference between insecure design and a security bug?
- A bug is a correct design implemented wrongly — a missing check, a wrong comparison — and it is fixed in code. Insecure design is a design that is faithful to its specification but cannot be made safe, such as a password reset that relies on questions anyone can research. No amount of careful coding fixes it; you have to change the mechanism, which is why threat modelling belongs before implementation.