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
- Open (3 min)Read the lesson's first line aloud ("but most of all, samy is my hero") and say it appeared on more than a million profiles whose owners never typed it. Ask how that could happen. Take a few guesses and leave them on the board until Day 2.
- Mini-lesson (13 min)Teach Injection Attacks, from Applications and their input through The TalkTalk breach. Stop at the question in The team finder ("Which players' teams will the database send back?") and take answers before reading the next paragraph.
- Do together (4 min)Problem 1 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- On their own (8 min)Problem 2 🔒 what data validation is · Problem 3 🔒 what SQL is for · Problem 5 🔒 what an SQL injection does and the harm it causes.
- Do together (7 min)Problem 9 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- In pairs (6 min)Problem 7 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- Exit check (4 min)🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
Day 2 · Typed input inside a page45 min
- Open (4 min)Go back to Day 1's guesses about the MySpace line. Tell the class that today's attack sends the typed characters to a different place than yesterday's, and ask them to watch for where.
- Mini-lesson (13 min)Teach Injection Attacks: its opening two paragraphs (the MySpace story), then Cross site scripting to the end. Stop at the question about the two routes ("Of the two routes, which one reaches more parents?") and take answers before reading the next paragraph.
- Do together (5 min)Problem 6 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- On their own (6 min)Problem 4 🔒 where page JavaScript runs and what it can reach.
- In pairs (10 min)Problem 8 🔒 Problem 10 🔒: one student finds whether the script was saved on the site, the other finds which computer ran it. Then they agree on the attack.
- Discuss (5 min)Problem 10 🔒 🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
- Wrap (2 min)Students write one line for each attack: what the adversary types, where the program copies it, and which computer runs it.
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).
🔒 Answer keyEvery problem's answer, the concept and essential knowledge it checks, and the trap it targets.Sign in as a teacher to see this🔒 Traps this set testsWhat each common wrong answer looks like, and one line to say when you see it.Sign in as a teacher to see this🔒 What to emphasizeThe points that decide the set's problems.Sign in as a teacher to see this🔒 Questions to ask aloudQuestions for the class discussion, with what to listen for.Sign in as a teacher to see this🔒 On the examHow the set's ideas appear on the AP exam, from the course framework.Sign in as a teacher to see this🔒 Your class so farLive results for your section: the problems a third or more missed on the first try, the most common wrong answer, and what it usually means.Sign in as a teacher to see this
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).