Skip to content

Module Overview

Estimate Duration: 18 minutes


What Is This Module About?

A buffer overflow happens when a program writes more data into a memory area than that area can hold. When outside input controls the amount of data written, a simple storage mistake can become a security weakness.

In this module, you will examine how fixed-size storage in C++ can be exceeded, how that can corrupt memory, and how to design input handling that respects real capacity limits. You will also see how similar unchecked writes can occur inside shared software libraries, making a flaw reachable through applications that rely on them.

Key ideas to keep in mind include:

  • Check Before Writing: Establish that input fits the destination before copying or storing it in fixed-size memory.
  • Match the Requirement: Enforce the actual limits of the task, including boundary cases and any space needed for string terminators.
  • Verify Behavior: Test ordinary and overlong input, and use memory-safety tools as evidence while recognizing that unsafe behavior can vary across runs and systems.

Included Real Exploit

This module examines CVE-2024-2961 in glibc. A text converter in glibc could write past the end of its output buffer because some writes lacked a capacity check.

Writing beyond the allocation could corrupt adjacent memory or crash an application. Researchers demonstrated more serious consequences in some application environments.

Included Exercises

The hands-on lab connects fixed-size input handling to the broader memory-safety ideas in the module. You will test a C++ kiosk with normal and overlong input, investigate sanitizer evidence, and revise the program to enforce its stated limit.

  • Hands-on Practice: Trace input through a program, test behavior at and beyond a fixed buffer’s capacity, and modify the kiosk so it accepts valid routing codes and rejects longer ones.