Web Application Security

Objectives: By the end of this topic, you will be able to…

  • Recognize and exploit common vulnerabilities in web applications
  • Intercept and modify HTTP traffic
  • Use automated analysis tools
  • Understand the most common OWASP risks and how to mitigate them

Client-server model and components of a web app

A web application is based on the client-server model:

  • The client (browser) sends requests (HTTP/S) to the server
  • The server processes the request, accesses databases if necessary, and responds with content

Typical components:

ComponentDescription
FrontendUser interface (HTML, CSS, JavaScript)
BackendBusiness logic (PHP, Python, Node.js)
DatabasePersistent storage (MySQL, MongoDB, PostgreSQL)
Web serverIntermediary between client and backend (Apache, Nginx)
Sessions/cookiesMechanisms to maintain state between requests

OWASP Top 10: key vulnerabilities

XSS (Cross-Site Scripting)

Injecting scripts into web pages that execute in other users’ browsers.

  • Types: Reflected, Stored, DOM-based
  • Consequences: cookie theft, redirects, keylogging

SQL Injection (SQLi)

Manipulating SQL queries through user input.

  • Consequences: data access/modification, authentication bypass

LFI (Local File Inclusion)

Inclusion of local server files via manipulable parameters.

  • May allow reading sensitive files (e.g., /etc/passwd) or code execution

CSRF (Cross-Site Request Forgery)

Exploiting the user’s browser to send malicious requests to an application where they are authenticated.

  • Consequences: password changes, unauthorized transactions

Analysis of HTTP requests and sessions

Understanding HTTP traffic is key to finding and exploiting vulnerabilities:

  • HTTP Methods: GET, POST, PUT, DELETE
  • HTTP Headers: User-Agent, Cookie, Referer, Authorization
  • Request body and parameters
  • Session management: session cookies, CSRF tokens, persistent authentication mechanisms

Controlled exploitation techniques

Using safe environments (DVWA, OWASP Juice Shop):

  • Code injection in forms
  • Manipulating cookies or headers
  • Automating basic attacks with scripts or tools
  • Exploiting hidden parameters

Always perform these practices in controlled environments and with authorization.


Interceptors and automated scanners

ToolDescription
Burp SuiteProxy/interceptor for HTTP modification, attack automation, app mapping
OWASP ZAPFree alternative to Burp with automated scanning
NiktoVulnerability scanner for web servers
sqlmapAutomates detection and exploitation of SQLi
wfuzz / ffufFuzzing of routes and parameters
WhatWeb / WappalyzerTechnology fingerprinting

Hands-on lab

Requirements: Kali Linux, DVWA

Lab setup: Installing DVWA

sudo bash -c "$(curl --fail --show-error --silent --location https://raw.githubusercontent.com/IamCarron/DVWA-Script/main/Install-DVWA.sh)"

DVWA will be available at http://localhost/DVWA. Login with admin:password, click “Create / Reset Database”, then set difficulty to medium in DVWA Security settings.

Instructions

Complete all of the following vulnerabilities in MEDIUM difficulty:

  • CSRF — forge a request to change the admin password
  • File Inclusion — include local/remote files through URL parameters
  • File Upload — upload a malicious file bypassing filters
  • SQL Injection — extract data from the database
  • SQL Injection (Blind) — infer data through true/false responses
  • XSS (DOM) — inject script through DOM manipulation
  • XSS (Reflected) — inject script via URL parameter
  • XSS (Stored) — store malicious script in the application

Submission

Report showing the process of exploiting each vulnerability:

  • Steps followed
  • Tools and commands used
  • Screenshots of successful exploitation
  • Explanation of why the vulnerability exists
  • Mitigation recommendation for each

Key concepts

TermDefinition
XSSInjection of malicious scripts into web pages
SQLiInjection of malicious SQL code into input fields
CSRFAttack that exploits the browser to send malicious requests
LFIInclusion of local server files via manipulable parameters
Burp SuiteHTTP proxy for web security testing
WAFSpecialized firewall for protecting web applications
OWASP Top 10List of the ten most critical web vulnerabilities

Test yourself

  1. XSS: What is the difference between reflected, stored, and DOM-based XSS? Which is more dangerous and why?

  2. SQLi: Explain how an attacker can use SQL injection to bypass login authentication. What SQL query would result?

  3. Mitigation: For each OWASP Top 10 vulnerability you practiced in the lab, propose a specific technical control that prevents it.


Navigation:Previous | Home | Next