Secure Coding in C and C++

Secure Coding in C and C++ is a two day training course that provides a detailed explanation of common programming errors in C and C++ and describes how these errors can lead to code that is vulnerable to exploitation.

  • Oct 18
    Magazinet Kongsberg
    2 days
    07:00 - 15:00 UTC
    Robert Seacord
    11 500 NOK

This course concentrates on security issues intrinsic to the C and C++ programming languages and associated libraries. You will learn to identify common security flaws including:

  • Memory safety
  • Insecure Integer operations
  • Undefined behaviors

For each of these security flaws, we demonstrate specific remediation techniques as well as general secure coding practices that help prevent the introduction of vulnerabilities.

Material in this presentation was derived from the Addison-Wesley books Secure Coding in C and C++ and The CERT C Secure Coding Standard.

Agenda

Day 1: Strings

  1. Introduction
    1. Standards
    2. Conformance
    3. Behaviors
    4. Errors
  2. Common errors using NTBS
    1. improperly bounded string copies
    2. null-termination errors
    3. truncation
    4. write outside array bounds
    5. off-by-one errors
    6. improper data sanitization
  3. Common errors using basic_string
  4. String Vulnerabilities
    1. Program Stack
    2. Buffer Overflow
    3. Code Injection
    4. Arc Injection
  5. Exercise: Identify String Problems
  6. Mitigation Strategies
    1. Prevention Strategies
    2. Detection Strategies
  7. Summary

Day 2: Integers

  1. Integer Types
    1. Integer Data Types
      1. Unsigned integer types
      2. Wraparound
      3. Signed integer types
      4. Signed integer ranges
      5. Overflow
      6. Character types
      7. Other integer types
    2. Integer Conversions
      1. Integer conversion rank
      2. Integer promotions
      3. Usual arithmetic conversions
      4. Conversions to unsigned integer types
      5. Conversions to signed integer types
      6. Conversion implications
    3. Integer Operations
      1. Addition
      2. Multiplication
      3. Division/remainder
      4. Right shift
    4. Exercise: Reviewing Code for Integer Defects
      1. Integer Vulnerabilities
      2. Wrap around
      3. Conversion error
      4. Truncation
      5. Non-exceptional
    5. Mitigation Strategies
      1. Integer type selection
      2. Safe integer operations
      3. Compiler Strategies
      4. Testing and reviews
    6. Summary
  2. Dangerous Optimizations
    1. Compiler Optimizations
    2. Constant Folding
    3. Adding a Pointer and an Integer
    4. Integer Overflow
    5. GCC Options
    6. Volatile
    7. Strict Aliasing
    8. Optimization Suggestions
    9. Null pointer
    10. Uninitialized Reads
    11. C11 Analyzability Annex
    12. Summary and Recommendations

Who should attend

Secure Coding in C and C++ should be useful to anyone involved in the development or maintenance of software in C and C++.

  • If you are a C or C++ programmer, this book will teach you how to identify common programming errors that result in software vulnerabilities, understand how these errors are exploited, and implement a solution in a secure fashion.
  • If you are a software project manager, this book identifies the risks and consequences of software vulnerabilities to guide investments in developing secure software.
  • If you are a computer science student, this book will teach you programming practices that will help you to avoid developing bad habits and enable you to develop secure programs during your professional career.
  • If you are a security analyst, this book provides a detailed description of common vulnerabilities, identifies ways to detect these vulnerabilities, and offers practical avoidance strategies.

Pre-requisites

The course assumes basic C and C++ programming skills, but does not assume an in-depth knowledge of software security. The ideas presented apply to various development environments, but the examples are specific to Microsoft Visual Studio and Linux/GCC and the Intel Architecture.

Software to install

Students are also encouraged to bring their own C and C++ programming language development environments (compiler, editor, etc.), such as Microsoft Visual Studio, Xcode, GCC, or Clang.

Robert Seacord
Technical Director at NCC Group

Robert Seacord is a Technical Director at NCC Group, where he develops and delivers secure coding training in C, C++, and other languages. Robert is an expert on ISO/IEC JTC1/SC22/WG14, the international standardization working group for the C programming language. He is the author of seven books, including Effective C (No Starch, 2020), The CERT C Coding Standard, Second Edition (Addison-Wesley, 2014),
Secure Coding in C and C++, Second Edition (Addison-Wesley, 2013), and Java Coding Guidelines: 75 Recommendations for Reliable and Secure Programs (Addison-Wesley, 2014). He has also published more than 50 papers on software security, component-based software engineering, web-based system design, legacy-system modernization, component repositories and search engines, and user interface design and development.

    NDC Conferences uses cookies to see how you use our website. We also have embeds from YouTube and Vimeo. How do you feel about that?