Skip to content
$ lynuxpro
← DevSecOps

LESSON 2 OF 22 · BEGINNER · 12 MIN

Threats and the OWASP Top 10

Free previewLesson 2 of the 2 free lessons in this Pro course.Unlock all 22

HOW IT WORKSThreat, weakness, harm

Attackerthe threatVulnerabilitya weaknessExploituses the weaknessYour appattack surfaceHarmdata leak, outageOWASP Top 10common weaknesses
1/5

A threat is something that can cause harm, like an attacker.

In simple words

  • Threat: something that could harm a system, such as an attacker stealing data.
  • Vulnerability: a weakness an attacker could use.
  • CIA triad: the three goals of security: confidentiality (secret), integrity (not changed) and availability (working).
  • OWASP Top 10: a widely used list of the ten most serious web application risks.
  • Injection: untrusted input being run as code or a query, such as SQL injection.

Big picture

Before you can defend something, you need to know how it gets attacked. The OWASP Top 10 is a list of the most common and serious web application risks, written by a community of security experts. It is the standard starting point for developers and testers.

Think of it as the "most common ways a burglar gets in": unlocked doors, weak locks, a spare key under the mat. Fixing those first stops most attacks.

Key words, in plain language

WordPlain meaning
ThreatSomething that could cause harm (an attacker, a mistake)
VulnerabilityA weakness that a threat can use
ExploitThe method or code that uses a vulnerability
RiskHow likely harm is, times how bad it would be
Attack surfaceEverything an attacker can reach: ports, APIs, forms, dependencies
CVEA public ID for a known vulnerability, like CVE-2021-44228
CVSSA score from 0 to 10 for how severe a vulnerability is

The CIA triad

Every security goal fits one of three ideas:

  • Confidentiality: only the right people can see the data.
  • Integrity: data is not changed in secret.
  • Availability: the system works when people need it.

The OWASP Top 10 (2021 edition)

OWASP updates the list every few years. Check owasp.org for the current version. The 2021 list is still the most widely used.

#RiskIn plain wordsExample
A01Broken access controlUsers can do or see what they should notChanging /orders/101 to /orders/102 shows someone else's order
A02Cryptographic failuresSensitive data is not protected wellPasswords stored in plain text, or HTTP instead of HTTPS
A03InjectionInput is run as a command' OR 1=1 -- in a login form
A04Insecure designThe design itself is unsafeNo limit on password guesses
A05Security misconfigurationUnsafe settings or defaultsAdmin console open to the internet, debug mode on
A06Vulnerable and outdated componentsOld libraries with known holesAn unpatched logging library
A07Identification and authentication failuresWeak login or sessionsNo MFA, guessable session ids
A08Software and data integrity failuresTrusting unsigned code or dataInstalling updates with no signature check
A09Logging and monitoring failuresAttacks go unseenNo alert on 500 failed logins
A10Server-side request forgery (SSRF)The server is tricked into fetching internal URLsReaching the cloud metadata address

Injection, step by step

This is the classic example. The code builds a query from user input:

query = "SELECT * FROM users WHERE name = '" + name + "'"
NORMALpythonutf-8 · 1L

If an attacker sends ' OR '1'='1, the query becomes:

SELECT * FROM users WHERE name = '' OR '1'='1'
OUTPUTterminalutf-8 · 1L

That returns every user. The fix is a parameterized query, where input is always treated as data and never as code:

cursor.execute("SELECT * FROM users WHERE name = %s", (name,))
NORMALpythonutf-8 · 1L

Broken access control, in a quick test

curl -s -H "Authorization: Bearer $ALICE_TOKEN" https://shop.example.com/api/orders/102
SHELLbashutf-8 · 1L
{"id":102,"owner":"bob","total":84.50}
OUTPUTterminalutf-8 · 1L

Alice asked for Bob's order and got it. The server checked that Alice is logged in, but not that she owns order 102. The fix is to check ownership on the server for every request.

How these map to the pipeline

RiskBest early check
Injection, XSSSAST (lesson 05), code review
Vulnerable componentsSCA (lesson 06)
MisconfigurationIaC scanning (08), policy as code (12)
Broken access controlTests, DAST (14), API tests (15)
Logging failuresRuntime monitoring (16)
Integrity failuresSigning and supply chain (13)

Common mistakes

  • Thinking the list is a checklist you finish. It is a guide to the most common risks.
  • Trusting the client. Never rely on checks done only in the browser.
  • Hiding things as the only defense ("nobody knows this URL").
  • Ignoring non-web risks. Cloud, containers and pipelines have their own lists.

Summary

  • A threat uses a vulnerability to cause a risk.
  • Protect confidentiality, integrity and availability.
  • The OWASP Top 10 lists the most common web risks, led by broken access control and injection.
  • Each risk has a best early check in the pipeline.

CHECK YOUR UNDERSTANDING

3 quick questions

  1. 1. Which OWASP Top 10 (2021) risk is first on the list?

  2. 2. What is the best fix for SQL injection?

  3. 3. Alice requests /orders/102, which belongs to Bob, and the server returns it. What is wrong?

You've finished the free preview of DevSecOps

Upgrade to Pro to unlock the remaining 20 lessons, every practice lab and a certificate when you finish.

See plans