The Crowdstrike Incident - Practical Part: Difference between revisions

From Elvis Wiki
Line 31: Line 31:
Code-Example
Code-Example


#include <stdio.h>
#include <string.h>


// Definition der Struktur mit typedef
typedef struct {
    char data[10]; // Ein kleines Array, um Overflows zu demonstrieren
} Object;
void demonstrate_out_of_bounds_read(Object *obj) {
    printf("Out-of-Bounds Read:\n");
    for (int i = 0; i < 15; i++) { // Gezieltes Überschreiten der Grenze
        printf("data[%d] = %c (Adresse: %p)\n", i, obj->data[i], &obj->data[i]);
    }
}
void demonstrate_out_of_bounds_write(Object *obj) {
    printf("Out-of-Bounds Write:\n");
    for (int i = 0; i < 15; i++) { // Gezieltes Schreiben über die Grenze hinaus
        obj->data[i] = 'A' + i; // Zufällige Daten schreiben
        printf("data[%d] = %c (Adresse: %p)\n", i, obj->data[i], &obj->data[i]);
    }
}
int main() {
    Object obj;
    // Daten initialisieren
    strncpy(obj.data, "123456789", sizeof(obj.data) - 1);
    obj.data[sizeof(obj.data) - 1] = '\0'; // Null-Terminierung
    printf("Initialisiertes Objekt: %s\n\n", obj.data);
    // Demonstration
    demonstrate_out_of_bounds_read(&obj);
    printf("\n");
    demonstrate_out_of_bounds_write(&obj);
    return 0;
}


=== Race Condition ===
=== Race Condition ===

Revision as of 23:49, 18 December 2024

Summary

In this article, we show an experimental approach of what mechanism leads to the Crowdstrike Incident of July 2024. For the theoretical part, please consult: https://wiki.elvis.science/index.php?title=The_Crowdstrike_Incident

Preamble

The Falcon software itself is only distributed to corporate customers, as it is purely an enterprise product. Therefore, experimenting with the Falcon Sensor for private or student purposes is not possible. However, we will practically demonstrate the mechanisms that led to the system failure. We will address the following points:

  • Out-of-bounds memory access
  • Race condition
  • Channel-file internals

Requirements

For experimenting on a safe environment, we will setup a virtual machine.

  • Operating system: MacOS Sequoia 15.1.1
  • Virtualization: UTM; https://mac.getutm.app/
  • Virtualized system: Windows 11, ARM-version (compatible for Apple Silicon)
  • for coding in C: CLion as IDE
  • for coding in Java: IntelliJ as IDE

Description

Demonstrating Out-Of-Bound Memory Access

For the practical demonstration, a virtual environment is set up using Windows 11 via UTM on macOS as the host operating system, ARM variant. This allows for experimentation independent of the host system. CLion, an IDE for C, is installed on the virtual machine. The reason for using C as the programming language lies in its memory management - here, faulty memory access can be simulated very easily. We write a program that is supposed to store data passed into an array. An object is defined using TYPEDEF and later instantiated in the running program, which receives more data to write than memory space allocated. This subsequently leads to a malfunction in memory management. In the case of the incident in question, an out-of-bounds write error occurred.

Code-Example

  1. include <stdio.h>
  2. include <string.h>

// Definition der Struktur mit typedef typedef struct {

   char data[10]; // Ein kleines Array, um Overflows zu demonstrieren

} Object;

void demonstrate_out_of_bounds_read(Object *obj) {

   printf("Out-of-Bounds Read:\n");
   for (int i = 0; i < 15; i++) { // Gezieltes Überschreiten der Grenze
       printf("data[%d] = %c (Adresse: %p)\n", i, obj->data[i], &obj->data[i]);
   }

}

void demonstrate_out_of_bounds_write(Object *obj) {

   printf("Out-of-Bounds Write:\n");
   for (int i = 0; i < 15; i++) { // Gezieltes Schreiben über die Grenze hinaus
       obj->data[i] = 'A' + i; // Zufällige Daten schreiben
       printf("data[%d] = %c (Adresse: %p)\n", i, obj->data[i], &obj->data[i]);
   }

}

int main() {

   Object obj;
   // Daten initialisieren
   strncpy(obj.data, "123456789", sizeof(obj.data) - 1);
   obj.data[sizeof(obj.data) - 1] = '\0'; // Null-Terminierung
   printf("Initialisiertes Objekt: %s\n\n", obj.data);
   // Demonstration
   demonstrate_out_of_bounds_read(&obj);
   printf("\n");
   demonstrate_out_of_bounds_write(&obj);
   return 0;

}

Race Condition

References