Security testing C and C++ applications

CYDCpTst3d
3 days
C
C++

Platform

Linux, Windows

Preparedness

General C/C++ development

Audience

C/C++ developers and testers

Group size

12 participants

Labs

Hands-on

Outline

  • Cybersecurity basics
  • Buffer overflow
  • Using vulnerable components
  • Security testing
  • Common software security weaknesses
  • Wrap up

Objective list

  • Understanding security testing methodology and approaches
  • Getting familiar with common security testing techniques and tools
  • Handling security challenges in your C and C++ code
  • Identify vulnerabilities and their consequences
  • Learn the security best practices in C and C++

Description

Your application written in C and C++ works as intended, so you are done, right? But did you consider feeding in incorrect values? 16Gbs of data? A null? An apostrophe? Negative numbers, or specifically -232? Because that’s what the bad guys will do – and the list is far from complete.

Handling security needs a healthy level of paranoia, and this is what this course provides: a strong emotional engagement by lots of hand on labs and stories from real life, all to substantially improve code hygiene. Mistakes, consequences and best practices are our blood, sweat and tears.

All this is put in the context of C and C++, and extended by core programming issues, discussing security pitfalls of code written in these languages.

So that you are prepared for the forces of the dark side.

So that nothing unexpected happens.

Nothing.

Table of contents

  • Cybersecurity basics
    • What is security?
    • Threat and risk
    • Cybersecurity threat types
    • Consequences of insecure software
    • Constraints and the market
    • The dark side
  • Buffer overflow
    • Assembly basics and calling conventions
      • x64 assembly essentials
      • Registers and addressing
      • Most common instructions
      • Calling conventions on x64
        • Calling convention – what it is all about
        • The stack frame
        • Stacked function calls
    • Memory management vulnerabilities
      • Memory management and security
      • Vulnerabilities in the real world
    • Buffer security issues
      • Buffer overflow on the stack
        • Buffer overflow on the stack – stack smashing
        • Exploitation – Hijacking the control flow
        • Lab – Buffer overflow 101, code reuse
        • Exploitation – Injecting shellcode
        • Lab – Code injection, BoF exploitation with shellcode
      • Some typical mistakes leading to BoF
        • Off-by-one errors
        • Allocating nothing
        • String length calculation mistakes
        • String termination confusion
        • Other typical causes of BoF weaknesses
        • Testing for typical mistakes
    • BoF protection best practices
      • Safe and unsafe functions
      • base_string and std::string
      • Some less-known dangerous functions
      • Lab – Fixing buffer overflow
      • Securing the toolchain
        • Securing the toolchain in C and C++
      • Compiler options and instrumentation
        • Compiler warnings and security
        • Using FORTIFY_SOURCE
        • Lab – Effects of FORTIFY
        • Using AddressSanitizer (ASan)
        • Hijacking GOT and RELRO protection
        • Heap overflow best practices
      • Stack smashing protection
        • Detecting BoF with a stack canary
        • Argument cloning
        • Stack smashing protection on various platforms
        • SSP changes to the prologue and epilogue
        • Lab – Effects of stack smashing protection
        • Bypassing stack smashing protection
      • Runtime protection
        • Runtime instrumentation
      • Address Space Layout Randomization (ASLR)
        • ASLR on various platforms
        • Lab – Effects of ASLR
        • Circumventing ASLR – NOP sleds
        • Heap spraying
      • Non-executable memory areas
        • The NX bit
        • Write XOR Execute (W^X)
        • NX on various platforms
        • Lab – Effects of NX
        • NX circumvention – Code reuse attacks
          • Return-to-libc / arc injection
          • Chained return-to-libc
          • Return Oriented Programming (ROP)
          • Lab – ROP demonstration
          • Whatever Oriented Programming
          • Protection against ROP
  • Using vulnerable components
    • Untrusted functionality import
    • Case study – The Equifax data breach
    • Vulnerability management
      • Patch management
      • Vulnerability databases and scanning tools
      • Lab – Finding vulnerabilities in the used components
  • Security testing
    • Security testing methodology
      • Security testing – goals and methodologies
      • Overview of security testing processes
      • Identifying and rating assets
        • Preparation
        • Identifying assets
        • Identifying the attack surface
        • Assigning security requirements
        • Lab – Identifying and rating assets
      • Threat modeling
        • Attacker profiling
        • SDL threat modeling
        • Mapping STRIDE to DFD
        • DFD example
        • Attack trees
        • Attack tree example
        • Lab – Crafting an attack tree
        • Misuse cases
        • Misuse case examples
        • Risk analysis
        • Lab – Risk analysis
      • Security testing approaches
        • Reporting, recommendations, and review
  • Common software security weaknesses
    • Input validation
      • Input validation principles
        • Blacklists and whitelists
        • Data validation techniques
        • What to validate – the attack surface
        • When to validate – validation vs transformations
        • Where to validate – defense in depth
        • Output sanitization
        • Encoding challenges
        • Validation with regex
      • Injection
        • Injection principles
        • Injection attacks
        • Code injection
          • OS command injection
            • Lab – Command injection
            • OS command injection best practices
            • Command injection best practices
            • Lab – Command injection best practices
            • Case study – Shellshock
            • Lab – Shellshock
            • Testing for command injection
          • Process control – library injection
            • DLL hijacking
            • Lab – DLL hijacking
      • Integer handling problems
        • Representing signed numbers
        • Integer visualization
        • Integer overflow
        • Lab – Integer overflow
        • Signed / unsigned confusion
        • Lab – Signed / unsigned confusion
        • Integer truncation
        • Lab – Integer truncation
        • Case study – Wannacry
        • Best practices
          • Upcasting
          • Precondition testing
          • Postcondition testing
          • Using big integer libraries
          • Best practices in C
          • Best practices in C++
          • Lab – Integer handling best practices in C++
        • Testing for numeric problems
      • Files and streams
        • Path traversal
        • Path traversal-related examples
        • Lab – Path traversal
        • Link and shortcut following
        • Virtual resources
        • Path traversal best practices
        • Testing for path traversal
  • Security testing
    • Security testing vs functional testing
    • Manual and automated methods
    • Security testing techniques and tools
      • Code analysis
        • Security aspects of code review
        • Static Application Security Testing (SAST)
        • Using static analysis tools
      • Dynamic analysis
        • Security testing at runtime
        • Penetration testing
        • Stress testing
        • Dynamic analysis tools
        • Dynamic Application Security Testing (DAST)
        • Fuzzing
        • Fuzzing techniques
        • Fuzzing – Observing the process
  • Common software security weaknesses
    • Security features
      • Authentication
        • Authentication basics
        • Authentication weaknesses
        • Case study – PayPal 2FA bypass
      • Password management
        • Inbound password management
          • Storing account passwords
          • Password in transit
          • Lab – Why is just hashing passwords not enough?
          • Dictionary attacks and brute forcing
          • Salting
          • Adaptive hash functions for password storage
          • Password policy
            • NIST authenticator requirements for memorized secrets
          • The Ashley Madison data breach
            • The dictionary attack
            • The ultimate crack
            • Exploitation and the lessons learned
          • Password database migration
            • (Mis)handling NULL passwords
            • Lab – String termination confusion
            • Testing for password management issues
        • Outbound password management
          • Hard coded passwords
          • Best practices
          • Lab – Hardcoded password
          • Protecting sensitive information in memory
            • Challenges in protecting memory
            • Heap inspection
            • Compiler optimization challenges
            • Sensitive info in non-locked memory
    • Errors
      • Error and exception handling principles
      • Error handling
        • Returning a misleading status code
        • Error handling in C
        • Error handling in C++
        • Information exposure through error reporting
      • Exception handling
        • In the catch block. And now what?
        • Empty catch block
      • Testing for error and exception handling problems
    • Code quality
      • Type mismatch
      • Lab – Type mismatch
      • Function return values
        • Unchecked Return Value
        • Case study – #iamroot hash migration bug
        • Omitted return value
        • Returning unmodifiable pointer
        • Constructors and destructors
        • Initialization of static objects
        • Lab – Initialization cycles
        • Array disposal
        • Lab – Mixing delete and delete[]
      • Object oriented programming pitfalls
        • Inheritance and object slicing
        • Implementing the copy operator
        • Mutability
          • Mutable predicate function objects
          • Lab – Mutable predicate function object
        • Testing for OOP pitfalls
      • Memory and pointers
        • Memory and pointer issues
        • Pointer handling pitfalls
        • Null pointers
          • NULL dereference
          • Testing for null pointers
        • Pointer usage in C
          • Use after free
          • Lab – Use after free
          • Double free
          • Using smart pointers
          • Incorrect pointer arithmetics
          • Alignment
          • Testing for memory and pointer issues
        • Memory leak
          • Testing for memory leaks
  • Wrap up
    • Secure coding principles
      • Principles of robust programming by Matt Bishop
      • Secure design principles of Saltzer and Schröder
    • And now what?
      • Further sources and readings
      • C and C++ resources

Pricing

3 days Session Price

2250 EUR / person

  • Live, instructor led classroom training
  • Discussion and insight into the hacker’s mindset
  • Hands-on practice using case studies based on high-profile hacks and live lab exercises
Customized Course

Tailor a course to your preferences

  • Send us a brief description of your business’s training needs
  • Include your contact information
  • One of our colleagues will be in touch to schedule a free 45 minute pre-training consultation

Inquiry

Interested in the trainings but still have some questions? Curious about how you can customize a training for your team? Send us a message and a team member will be in touch within 24 hours.

This field is required

This field is required

Send us your phone number if you prefer to discuss further on a call

This field is required

This field is required

This field is required

This field is required