Lesson plan: Injection Attacks

AP Cybersecurity · Unit 5 Securing Applications and Data · Topic 5.1 Application and Data Vulnerabilities and Attacks · Practice set

At a glance

Suggested time
2 class periods (45 min)
Pacing
First of three sets for Topic 5.1, and the unit's first set. The CED gives Topic 5.1 five class periods; this plan suggests 2 for this set, 1 for Memory and Path Attacks and 2 for Data Vulnerabilities and Risk. The CED does not divide the topic among sets, so that split is this plan's suggestion. This set covers 5.1.B.1 to 5.1.B.6: applications, data validation, SQL, SQL injection, JavaScript and cross site scripting. Memory and Path Attacks takes 5.1.B.7 to 5.1.B.10 (buffers, buffer overflow, GET requests, directory traversal).
Before this set
The lesson in Foundations: Web Applications, Databases, and Files, the set before this one. Its A request with input section shows a web application building its pages from what a visitor sends, and The database section covers tables of rows and a query that reads or changes them. From Classifying Security Controls in Securing Spaces (Unit 2): confidentiality and integrity, which 5.1.B.4 uses to name the harm of an SQL injection.
Skills
1.A Identify, with and without the support of AI, vulnerabilities, threats, and attack methods, and explain how they generate risk.
1.B Determine ways adversaries exploit vulnerabilities to compromise an asset.

The one idea: When a program copies what a user typed into something it hands on, a query for the database or a page for a browser, the typed characters can become instructions. In an SQL injection the database runs them; in cross site scripting the browser of whoever loads the page runs them.

Day by day

Day 1 · Typed input inside a query45 min

Day 2 · Typed input inside a page45 min

Differentiation

If students are struggling
Before the pairs work on Day 2, students make a three-column chart for SQL injection and cross site scripting: what the adversary types, where the program copies it, which computer runs it. They fill it from the lesson's figure and its Cross site scripting section, then add a row for each kind of cross site scripting the lesson names, with a note on whether the script is saved on the site, and keep the chart beside them for the Day 2 problems.
Extension
🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
Vocabulary support
application, executable data, local and web application, input field, data validation, database, query, structured query language (SQL), control characters, hypertext markup language (HTML), JavaScript, cookie, cross site scripting (XSS), reflected (Type I), stored (Type II).

From the course framework

LO 5.1.B Explain how application attacks exploit vulnerabilities.

  • 5.1.B.1 Applications are programs that run instructions on computers; they are executable data. Some applications run locally on a user's computer, while other applications, like web applications, run on a server and are accessed by users through a network.
  • 5.1.B.2 Many applications take user input through open-ended input fields where users can type characters (e.g., letters, numbers, punctuation). Developers should include user input checks in their application, such as numeric input when asked for a number of items, to ensure that the user input matches what is expected; the application should reject input outside of the expected parameters. This process of verifying that user input meets expected criteria before processing it is called data validation. Applications that fail to validate user input are vulnerable to injection-type attacks, where adversaries insert unexpected character strings in input fields to alter the behavior of a program.
  • 5.1.B.3 Structured query language (SQL) is a computer language used to request information from databases and make changes to databases or entries in databases. Applications that query a database using unvalidated or unsanitized input from users are vulnerable.
  • 5.1.B.4 An SQL-injection attack places SQL commands and control characters into a user-input field in an application, which can lead to a breach of confidentiality by causing the application to return more information than it should, or a breach of integrity by modifying or deleting data in the database.
  • 5.1.B.5 Websites are written using hypertext markup language (HTML), and many websites use Javascript to create dynamic content on websites or web applications. Because Javascript commands run in the browser of the user visiting the website, those commands can access sensitive data stored in the browser like usernames, passwords, and cryptographic keys.
  • 5.1.B.6 A cross site scripting (XSS) attack injects malicious code into a website that a user's browser then executes. The malicious code can be embedded in a link the user clicks (a Type I or Reflected XSS attack) or it can be inserted onto a website through a comment field, forum post, or visitor log, which would affect any user visiting that website (a Type II or Stored XSS attack).