Lesson plan: Memory and Path 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
1 class period (45 min)
Pacing
Second of three sets for Topic 5.1. The CED gives Topic 5.1 five class periods; this plan suggests 2 for Injection Attacks, 1 for this set 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.7 to 5.1.B.10: buffers, buffer overflow, GET requests and directory traversal.
Before this set
🔒 Teacher notes: sign in as a teacher to see this🔒 Teacher notes: open the full plan to see this
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: Both attacks push a program past an edge it never checks. A buffer overflow writes input past the end of the memory set aside for it, over whatever is stored next; a directory traversal adds .. to a request's path until the path climbs out of the folder the server hands out.

Day by day

Day 1 · Past the end of the buffer, above the served folder45 min

Differentiation

If students are struggling
Before Problem 6 🔒, students copy the lesson's climb figure layout: the served folder on the first line, then one piece of the request's path per line, working each piece the way the figure does. They use the same layout on Problem 4 🔒, one request at a time. Give them a two-row card to keep beside them, one row for buffer overflow and one for directory traversal, which they fill in from the lesson in their own words.
Extension
Students write a four-line server log like the one in Problem 6 🔒 with one traversal request, name the folder the server hands out, and give four candidate files, each wrong one off by a different count of ... A partner works out which file the request opens. Then ask why GET /photos/../photos/u10-green.jpg is harmless.
Vocabulary support
buffer, memory, adjacent memory, overflow, crash, hypertext transfer protocol (HTTP), GET request, URL, file system, directory, path, .. (the folder one level up), root, served directory, directory traversal, virtual private network (VPN), multifactor sign-in.

From the course framework

LO 5.1.B Explain how application attacks exploit vulnerabilities.

  • 5.1.B.7 When applications take user input, that input is written to a buffer. A buffer is a designated section of computer memory with a fixed size. If the amount of data the user enters exceeds the size of the buffer, it can overflow into adjacent memory locations and overwrite other parts of the computer's memory.
  • 5.1.B.8 A buffer overflow attack feeds more data into memory than was allotted, which can cause a system to crash or to execute code outside the scope of a program's security policy, effectively allowing the adversary to perform unauthorized actions on a computer, such as accessing, modifying, or deleting files.
  • 5.1.B.9 The files that run web applications are stored in directories on servers. When users access web applications, their browsers send GET requests using hypertext transfer protocol (HTTP). A GET request accesses a file somewhere in the filesystem of the server.
  • 5.1.B.10 In a directory traversal attack, adversaries modify URLs and GET requests to attempt to access sensitive data (e.g., usernames and passwords) on a server's file system.

Framework example: A web server stores a site's images in /var/www/images/. An adversary changes an image request to ../../../etc/passwd. Each .. goes up one directory, so three of them return to the root, and from there the adversary asks for the passwd file, which lists the device's authorized usernames.