C/C++ Implementation Vulnerabilities

HYBRID 4 DAYS TRAINING: AUGUST 2023

Xeno Kovah

Abstract

Dual-purpose class: This class teaches developers how to avoid writing implementation flaws, or detect ones that are already in their code...but it also teaches vulnerability-hunters how to find the flaws as well! So it's an epic battle between contentious developers and devious vulnerability hunters! Who will win?! Whoever most takes the lessons of this class to heart!

This class features 73 detailed explanations of real CVEs from the past few years, to teach you to hone your “sploity sense” with real vulnerabilities, not fake ones!

Prerequisite Knowledge

Complexity: Introductory

This class has minimal prerequisites. It just requires that you are comfortable with reading small (< 100 line) C programs.

Key Learning Objectives

  • Learn to recognize the common programming errors that lead to the most frequent causes of exploitable vulnerabilities:
    • (Linear) stack buffer overflows
    • (Linear) heap buffer overflows
    • (Non-linear) out-of-bound writes
    • Integer overflows/underflows
    • Other integer issues (e.g. bypassing sanity checks due to signed comparisons, integer truncation/extension errors, sign extension errors.)
    • Uninitialized data access
    • Race conditions (double fetch, TOCTOU)
    • Use-after-free
    • Type confusion
    • Information disclosure
  • Learn what options developers have in terms of prevention, detection, and mitigation for each vulnerability type.
  • Showing examples of exploitation of a subset of the example vulnerabilities, that might otherwise seem unexploitable.
  • An explicit non-goal is to teach the student how to exploit the vulnerabilities themselves. That will be covered in a future class. (Therefore this class's applicability stops at “secure development” or “vulnerability auditor”, and doesn't extend to “exploitation engineer”.)

One-of-a-kind Class Format!

This class is run a little different from most classes. We provide you purpose-built recorded lectures instead of trapping you in realtime with live-lectures. But fear not, the instructor is always right there eagerly waiting to mingle with the students and answer any questions you have. (The instructor really likes being asked questions. It shows you're paying attention ;)). One of many benefits is that you can watch lectures at 2x speed and zoom ahead of the other students and get to the hands on labs quicker. Or if there's bits of material you already know, you can just skip them and move on to the bits you don't know! Another big benefit is that you get to take the full lectures and labs with you! That means if you forget stuff and then need it in 6 months, you can quickly re-bootstrap yourself! Or you can watch the class twice, to really grow those neural connections and cement it in your brain! And unlike live lectures, our lectures are always getting more factually accurate, by having any accidental errors edited out.

Because we give you all the lecture and lab materials and videos after class, what you're really paying for is support from the instructor! So you'll be entitled to keep asking up to 20 questions after class, with 1-2 hour turnaround answers (after accounting for time-zone differences.) This lets you keep productively working through the material if you run out of time at the conference. If you'd like to learn more about the benefits of this style of class delivery, please read this blog post.

Course Agenda

  • Class Introduction
    • Attacker motivations & capabilities
  • Stack Buffer Overflows
    (Key: 🌚 = 0day in the wild, 🪡 = includes exploit explanation)
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2021-21574🪡 “BIOS Disconnect”
      • CVE-2022-0435
      • CVE-2018-9312
      • CVE-2018-9318
      • CVE-2020-10005
      • CVE-2021-20294
      • CVE-2021-43579
      • 2021-CVE-None-BaseBand#1
      • CVE-2022-0435
    • Prevention
      • Writing good sanity checks, by example
      • Safer C runtime API options
      • FORTIFY_SOURCE
      • Piecemeal type-safe language usage
    • Detection
      • FORTIFY_SOURCE
      • Manual code auditing guidance
      • Commercial static analysis tools
      • Fuzzing
      • Address Sanitizer
    • Mitigation
      • Stack Canaries
      • Address Space Layout Randomization (ASLR)
      • Non-Executable Memory
      • Control Flow Integrity (CFI)
      • Tagged Memory
  • Heap Buffer Overflows
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2020-0917🪡
      • CVE-2019-7287🌚
      • CVE-2020-11901 (Part of “Ripple20")
      • CVE-2020-25111 (Part of “Amnesia:33")
      • CVE-2020-27009 (Part of “NAME:WRECK”)
      • CVE-2021-21555
      • CVE-2021-42739
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Non-linear Out-of-bounds Writes (OOB-W)
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2019-10540🪡
      • CVE-2020-0938🌚
      • CVE-2020-1020🌚
      • CVE-2020-13995
      • CVE-2020-27930🌚
      • CVE-2021-26675 “T-BONE”
      • CVE-2021-28216
      • CVE-2022-25636
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Integer Overflows/Underflows
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2020-0796🪡 “SMBGhost”
      • CVE-2019-5105
      • CVE-2019-3568🌚
      • CVE-2019-14192
      • CVE-2020-11901 (Part of “Ripple20")
      • CVE-2020-16225
      • CVE-2020-17443 (Part of “Amnesia:33")
      • CVE-2021-30860🌚
      • CVE-2021-22636
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Other Integer Issues
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2019-15948🪡
      • CVE-2019-14196
      • CVE-2019-20561
      • CVE-2020-15999🌚
      • CVE-2020-17087🌚
      • CVE-2021-33909 “Sequoia”
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Conclusion for Part 1
  • Uninitialized Data Access
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2019-1458🌚🪡
      • CVE-2022-26721
      • CVE-2022-1809
      • CVE-2021-3608
      • CVE-2022-29968
      • CVE-2021-27080
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Race Conditions
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2019-11098🪡
      • CVE-2021-4207
      • CVE-2021-34514
      • 2022-CVE-None-MSMu
      • CVE-2020-7460
      • 2019-CVE-None-QualcommWiFiSB
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Use-After-Free (UAF)
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2020-29661🪡
      • CVE-2021-28460
      • CVE-2020-2674
      • CVE-2020-2758
      • CVE-2021-36955
      • CVE-2020-9715
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Type Confusion
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2021-1732🌚🪡 & CVE-2022-21882🌚
      • CVE-2020-3853
      • CVE-2021-30857
      • CVE-2020-27932🌚 & CVE-2021-30869🌚
      • CVE-2021-41073
      • CVE-2022-1786
    • Prevention, Detection, Mitigation (a mix of approaches that apply equivalently to past sections, as well as any new topic-specific mechanisms.)
  • Information Disclosure
    • Overview
    • Choose-your-own-adventure. Select the examples you're most interested in from:
      • CVE-2022-22252
      • CVE-2022-29181
      • CVE-2020-9833
      • CVE-2021-3947
      • CVE-2020-25624
      • CVE-2019-8921
      • CVE-2021-22898
      • CVE-2021-22925
    • Prevention, Detection, Mitigation (it's doing all the things to PDM the root-cause bug classes that lead to info disclosure!)
  • Conclusion for Part 2

Hardware Requirements

  • Any computer capable of watching online videos.
  • Headphones for watching videos, (preferably over-ear so you're not disturbed as the instructor is walking around the class answering individuals' questions).

Software Requirements

  • Git and Subversion to check out vulnerable code.
  • Your favorite code-reading software / IDE. If you don't have a favorite, Eclipse is recommended because it works the same on all OSes, and a usage guide will be given.
  • A link to a software setup guide will be sent before class, and the student should install them before class to maximize time available for interaction with the instructor.