Objective. Students will execute and document SQL injection and cross-site scripting attacks against a deliberately vulnerable web application in an isolated lab environment, explaining the mechanism of each.
This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.
VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.
Application-layer attacks target the software logic of a web application rather than the network or operating system beneath it. Because modern organizations expose web applications directly to users, these vulnerabilities are among the most exploited in real-world breaches. The OWASP Top 10 consistently lists injection flaws and cross-site scripting (XSS) near the top of the most critical risks. Understanding how these attacks work is essential for both offensive testing (penetration testing) and defensive analysis (security operations).
Before any hands-on activity, network isolation is a hard requirement — not a suggestion. You must confirm that your virtual machine (VM) has no internet connectivity and no host-only bridge to a production network. Running attack tools or injecting payloads against any system you do not own, or any system connected to the internet, is illegal under the Computer Fraud and Abuse Act (CFAA) and similar state laws. Your instructor will verify isolation with a checklist before lab work begins. This is the cybersecurity equivalent of a lockout/tagout procedure: you verify the environment is safe before applying any potentially destructive action. Always work inside DVWA on your isolated, local VM only.
SQL injection occurs when user-supplied input is inserted directly into a database query without proper sanitization or parameterization. The attacker adds SQL syntax to the input field, causing the database engine to interpret the attacker's commands as legitimate query logic.
How it works: Suppose an application builds a query like this:
```
SELECT * FROM users WHERE id = '[user input]';
```
If an attacker enters `1' OR '1'='1`, the query becomes:
```
SELECT * FROM users WHERE id = '1' OR '1'='1';
```
Because `'1'='1'` is always true, the database returns every row in the users table. More advanced payloads can retrieve password hashes, enumerate table names using `UNION SELECT` statements, or even write files to the server in some configurations.
Common payloads to try in DVWA (low security):
Record each payload, the exact response, and any data returned in your lab log. Note whether the application reveals database error messages — that itself is a finding (verbose error disclosure).
XSS occurs when an attacker injects malicious JavaScript (or other client-side script) into a web page that is then rendered and executed by another user's browser. The server trusts the stored or reflected content and passes it to the victim without sanitization.
There are three main types:
In DVWA's stored XSS module, entering a payload such as `<script>alert('XSS')</script>` into a comment field causes the browser to execute that script every time the page loads. A real attacker would replace the `alert()` call with code that steals session cookies, redirects users to phishing sites, or logs keystrokes.
CSRF tricks an authenticated user's browser into sending an unwanted request to a web application. Because the browser automatically includes session cookies, the application cannot distinguish the forged request from a legitimate one. CSRF does not steal data directly; it performs unauthorized actions on behalf of the logged-in victim — such as changing an email address or transferring funds. Defenses include anti-CSRF tokens and the `SameSite` cookie attribute.
A buffer overflow happens when a program writes more data to a fixed-size memory buffer than it can hold. The excess data overwrites adjacent memory, potentially overwriting the return address of a function and redirecting execution to attacker-controlled code (shellcode). Buffer overflows are more common in compiled languages like C and C++. Modern defenses include stack canaries, Address Space Layout Randomization (ASLR), and Data Execution Prevention (DEP/NX). Though less common in modern web applications, they remain relevant in embedded systems and legacy software.
The CompTIA Security+ (SY0-701) exam covers application attacks as part of its threat analysis objectives. CompTIA CySA+ expects analysts to identify attack indicators and recommend mitigations. ISC2 CC covers fundamental security concepts including common attack categories. This lab directly supports all three credential study areas by giving you hands-on exposure to the mechanics behind the theory.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.