Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 38 Β· Web, Network and Cloud Testing

Web Application Testing and the OWASP Top 10

Learn how web application penetration tests are structured around the OWASP Top 10, see injection and cross-site scripting on a safe toy example, and learn the fixes.

Web applications are the most common penetration-testing target because they are exposed to the internet, handle valuable data and are built from custom code. A web test looks at the application the way an attacker would: through its pages, forms, APIs, cookies and file uploads, and it asks what a user could do that the developers never intended.

The community reference for what to look for is the OWASP Top 10, a ranked list of the most critical web application risk categories. The list is updated every few years, so check the current edition, but the categories change slowly. This lesson maps them to test ideas and shows two classic flaws, SQL injection and cross-site scripting, on a tiny in-memory toy app with invented data, together with the fixes. Run such tests only against applications you are authorized to test, ideally a copy in a lab or staging environment.

The OWASP Top 10 as a test checklist

Category (recent edition) What to test Typical fix
Broken access control Change IDs in URLs, call admin endpoints as a normal user, skip steps in a workflow Server-side authorization on every request; deny by default
Cryptographic failures Plain HTTP, weak TLS, sensitive data in URLs or logs, weak password hashing Strong TLS, encrypt sensitive data, modern password hashes
Injection SQL, NoSQL, OS command, template and LDAP injection; XSS Parameterized queries, output encoding, input validation
Insecure design Missing limits on abusive flows, trust of client-side checks Threat modeling, business-rule limits
Security misconfiguration Default accounts, verbose errors, open cloud storage, missing headers Hardened baselines, automated config checks
Vulnerable and outdated components Old frameworks and libraries with known CVEs Dependency inventory and patching
Identification and authentication failures Weak passwords, no lockout or MFA, session fixation MFA, secure session management
Software and data integrity failures Unsigned updates, insecure deserialization, untrusted CI pipelines Signing, integrity checks, locked-down pipelines
Security logging and monitoring failures No alerts for attacks, logs missing key events Central logging, alerting, incident drills
Server-side request forgery (SSRF) Features that fetch a URL on the user's behalf Allowlists, network egress controls, metadata protection

A systematic test walks through the application: map it (pages, roles, APIs), test authentication and sessions, test each input for injection, test authorization with at least two accounts, test business logic, then review configuration and components.

A web test in five passes

Map Pages, roles, APIs
Auth Login, sessions, MFA
Inputs Injection and XSS
Access Two accounts, swap IDs

Then business logic and configuration.

1 / 2

SQL injection on a toy app

SQL injection happens when user input is pasted into a SQL query as text, so data can change the query's meaning. The classic cause is string concatenation. The toy login below uses Python's built-in SQLite with made-up users. It is a deliberately weak function next to a fixed one.

Python SQL injection and the parameterized fix

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

With the probe input the vulnerable query becomes ... WHERE name = 'alice' --' AND password = 'anything': everything after -- is a comment, so the password check disappears and the attacker is "logged in" as alice without knowing her password. The safe version sends the input as data in a parameter, so the quote is just a character in a name that does not exist. In a real test you would use harmless probes like this (a single quote, a boolean test) to show the flaw exists, and stop. Extracting whole tables is rarely needed and risks real personal data.

The fix hierarchy: parameterized queries or an ORM first, then least-privilege database accounts, then input validation as a second layer, never as the only protection.

Cross-site scripting (XSS)

XSS happens when an application includes untrusted input in a page without encoding it, so the browser treats the data as code. If the injected script runs in a victim's browser, it can act as that user. The three flavours are reflected (input echoed in the response), stored (saved, then shown to others) and DOM-based (client-side code writes input into the page).

The defense is context-aware output encoding: turn characters that are special in the current context (HTML, attribute, JavaScript, URL) into harmless forms. A Content Security Policy and HttpOnly cookies reduce the damage if one is missed.

Python Output encoding for a comment field

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

In the unsafe output the script tag would execute; in the safe output it becomes <script>... which the browser displays as plain text. Testers confirm XSS with a harmless marker such as alert(document.domain) or a unique string, never with code that steals real sessions.

Broken access control (the most common serious finding)

Test with two ordinary accounts and one admin if available. Log in as user A, record a request (for example GET /orders/1042), then replay it as user B. If B sees A's order, that is an insecure direct object reference (IDOR). Also check that:

  • Removing the UI button is not the only thing preventing an action; call the API directly.
  • Changing the HTTP method or adding parameters such as role=admin does not change permissions.
  • Steps in a multi-step process (checkout, password reset) cannot be skipped or repeated.

Fixes are always server-side: check that the logged-in user owns or may access the object on every request, and use unpredictable identifiers as a supplement, not a substitute.

What a good web finding contains

A finding needs the URL and parameter, the exact request that shows it, the response evidence, the impact in plain words, the CVSS or rating, and a specific fix. See risk rating and evidence and writing the report.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. What is the correct primary defense against SQL injection?

    Parameters keep user input as data. Other measures help but do not remove the root cause.
  2. 2. In the probe alice' --, why does the vulnerable login accept it?

    Concatenation lets the input change the structure of the query.
  3. 3. What is an insecure direct object reference (IDOR)?

    It is a broken access control flaw: the server trusts the identifier without checking who is asking.
  4. 4. Which pair best reduces the impact of an XSS flaw you may have missed?

    CSP limits what injected script can do, and HttpOnly stops scripts reading session cookies. Output encoding remains the real fix.

Summary

  • The OWASP Top 10 is a practical checklist: access control, crypto, injection, design, configuration, components, authentication, integrity, logging and SSRF.
  • Injection happens when input becomes code; parameterized queries and output encoding are the fixes.
  • Test authorization with two accounts and always enforce it on the server.
  • Use harmless probes as proof and avoid pulling real data.
  • A good finding has a precise request, evidence, impact, rating and fix.

Next: Web testing workflow, proxies and security headers