🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Cybersecurity › Cybersecurity Threats: Attack Types, Threat Actors, and Vulnerability Analysis › Lesson 5
TEC-CYBE44-02 · Lesson 5 · 15 clock hours · lab

Application-Layer Attacks: Injection, XSS, CSRF, and Buffer Overflow

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.

⚠ Pending professional review

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: Injection, XSS, CSRF, and Buffer Overflow

Why Application-Layer Attacks Matter

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).

Lab Safety and Isolation Requirements

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 (SQLi)

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).

Cross-Site Scripting (XSS)

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.

Cross-Site Request Forgery (CSRF)

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.

Buffer Overflow

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.

Connecting to Your Credentials

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.

Key terms8

SQL Injection (SQLi)An attack that inserts malicious SQL syntax into an application input field, causing the database to execute unintended commands and potentially expose or modify data.
Stored XSSA cross-site scripting variant in which the malicious script is saved on the server and delivered persistently to every user who loads the affected page.
Reflected XSSA cross-site scripting variant in which the malicious script is embedded in a URL and executed in the victim's browser only when the victim clicks that specific link.
CSRF (Cross-Site Request Forgery)An attack that tricks an authenticated user's browser into sending an unauthorized request to a web application, causing unintended actions using the victim's active session.
Buffer OverflowA vulnerability in which a program writes more data to a memory buffer than it can hold, overwriting adjacent memory and potentially allowing an attacker to redirect program execution.
DVWA (Damn Vulnerable Web Application)An open-source, intentionally insecure web application used in isolated lab environments to practice and study common web application vulnerabilities safely.
Input SanitizationThe process of validating and cleaning user-supplied data before it is processed or stored, preventing malicious characters from being interpreted as code or commands.
OWASP Top 10A regularly updated list published by the Open Worldwide Application Security Project identifying the ten most critical web application security risks, widely used as a reference in security testing and training.
In class: Students install and launch DVWA (Damn Vulnerable Web Application) on a local isolated VM; instructor walks through the lab setup checklist to confirm network isolation before any activity begins. · Students perform a guided SQL injection exercise on DVWA's SQL Injection module at low security level, recording each payload tried, the application response, and the data returned in a structured lab log. · Students perform a stored XSS injection on DVWA's XSS module, capture a screenshot of the alert box, and write a short explanation (minimum five sentences) of how the payload persists and what real-world impact it could have.
Materials: DVWA (open-source, installed on isolated VM — no internet connectivity), VirtualBox or VMware Workstation Player, lab log template, CompTIA Security+ SY0-701 and CySA+ study guides — application attacks sections, OWASP Top 10 reference (owasp.org)
Check: Completed lab log with at least three distinct SQL injection payloads documented with responses, plus XSS screenshot and written explanation; instructor confirms VM network isolation before grading. Pass requires all entries present, network isolation confirmed, and explanation meeting minimum length with accurate mechanism description — 80% rubric score.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

CompTIA Security+ — Threats, Attacks, and Vulnerabilities
1. A penetration tester enters `' OR '1'='1` into a login field and is granted access without valid credentials. Which vulnerability is being exploited?
CompTIA CySA+ — Vulnerability Management
2. A security analyst notices that a script tag entered in a web forum's comment box is executed in every visitor's browser each time they view that page. Which type of XSS is this?
CompTIA Security+ — Application Security
3. Which defense is MOST effective at preventing SQL injection attacks at the code level?
ISC2 CC — Security Concepts
4. An attacker crafts a malicious link that, when clicked by a logged-in bank user, submits a fund transfer request using the victim's active session without the victim's knowledge. Which attack type does this describe?
CompTIA Security+ — Governance, Risk, and Compliance
5. Before performing SQL injection exercises in DVWA, why must the student verify that the VM has no internet connectivity?
CompTIA Security+ — Threats, Attacks, and Vulnerabilities
6. A developer learns that her C application crashes when users submit very long input strings, and investigation shows that return addresses in memory are being overwritten. Which vulnerability class does this represent?
CompTIA CySA+ — Threat and Vulnerability Management
7. A CySA+ analyst reviewing web application logs sees repeated requests containing `UNION SELECT` statements directed at a product search field. Which attack is most likely underway?
CompTIA Security+ — Application Security
8. Which HTTP security mechanism is specifically designed to mitigate cross-site request forgery attacks by ensuring that requests originate from the same site that issued the form?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.