PERSONAL - Security Engineering

Security Requirements

Security Principles

Security, Usability, Psychology

Social Engineering

Principles (Cialdini)

Taxonomy

Attack Vectors

Examples

Threat Modeling

ISG Terminology

Attacker Models

Attack Trees

Risk Analysis

STRIDE

ATT&CK

Web App Security

System-Level Security

Obfuscation

Static Obfuscation

Intellectual Property (Code, Algorithms)

Example: Control Flow Flattening

/* before */
int gcd(int a, int b) {
    while (a != b) {   // B0
        if (a > b) {   // B1
            a = a - b; // B3
        } else {
            b = b - a; // B4
        }
    }
    return a;          // B2
}

/* layout */
B0: while (a != b) goto B1; goto B4;
B1: if (a > b) goto B2; goto B3;
B2: a = a - b; goto B0;
B3: b = b - a; goto B0;
B4: return a;

/* after */
int gcd(int a, int b) {
    int next = 0;
    while (true) {
        switch (next) {
            case 0:  if (a != b) next = 1; else next = 2; break;
            case 1:  if (a > b)  next = 3; else next = 4; break;
            case 2:  return a;
            case 3:  a = a - b;  next = 0; break;
            case 4:  b = b - a;  next = 0; break;
            default: break;
        }
    }
}
/* before */
int gcd(int a, int b) {
    while (a != b) {   // B0
        if (a > b) {   // B1
            a = a - b; // B3
        } else {
            b = b - a; // B4
        }
    }
    return a;          // B2
}

/* layout */
B0: while (a != b) goto B1; goto B4;
B1: if (a > b) goto B2; goto B3;
B2: a = a - b; goto B0;
B3: b = b - a; goto B0;
B4: return a;

/* after */
int gcd(int a, int b) {
    int next = 0;
    while (true) {
        switch (next) {
            case 0:  if (a != b) next = 1; else next = 2; break;
            case 1:  if (a > b)  next = 3; else next = 4; break;
            case 2:  return a;
            case 3:  a = a - b;  next = 0; break;
            case 4:  b = b - a;  next = 0; break;
            default: break;
        }
    }
}

Example: Virtualization Obfuscation

/* before */
void foo(int x) {
    int y = 10;        // B0, integer assignment
    y++; y++;          // B0, integer increment
    if (x > 0) {       // B0, branch if > 0
        y++;           // B2, integer increment
    }                  //
    else {}            // B1
    printf("%d\n", y); // B3, call to printf with integer argument
}

/* step 1.1: ISA  */
/* integer assignment */  52, LHop, RHop   ;
/* integer increment  */  03, op           ;
/* branch if > 0      */  08, op  , offset ;
/* call to printf     */  18, op           ;
/* halt               */  00               ;

/* step 1.2: data */
int data[] = {
    00, // x
    00, // y
    10, // const. 10
    05  // jump offset (in bytes)
};

/* step 2: translate */
int code[] = {
    52, 01, 02, // y = 10;
    03, 01,     // y++;
    03, 01,     // y++;
    08, 00, 03, // x > 0...
    03, 01,     // y++;
    18, 01, 00  // printf(...);
};

/* step 3: emulator */
/* see virtualization techniques */
/* before */
void foo(int x) {
    int y = 10;        // B0, integer assignment
    y++; y++;          // B0, integer increment
    if (x > 0) {       // B0, branch if > 0
        y++;           // B2, integer increment
    }                  //
    else {}            // B1
    printf("%d\n", y); // B3, call to printf with integer argument
}

/* step 1.1: ISA  */
/* integer assignment */  52, LHop, RHop   ;
/* integer increment  */  03, op           ;
/* branch if > 0      */  08, op  , offset ;
/* call to printf     */  18, op           ;
/* halt               */  00               ;

/* step 1.2: data */
int data[] = {
    00, // x
    00, // y
    10, // const. 10
    05  // jump offset (in bytes)
};

/* step 2: translate */
int code[] = {
    52, 01, 02, // y = 10;
    03, 01,     // y++;
    03, 01,     // y++;
    08, 00, 03, // x > 0...
    03, 01,     // y++;
    18, 01, 00  // printf(...);
};

/* step 3: emulator */
/* see virtualization techniques */

Secret Data

Example: Array Aliasing

/* every third cell starting from 0 has a value 3 mod 7  (*) */
/* every third cell starting from 1 has a value 5 mod 11 (!) */
/* every other cell contains some fixed value            (X) */
int g[] = {10, 5, 13, 3, 27, 5, 24, 38, 0, 73, 115, 3, 66, 60, 17, 31};
//         *   !  X   *  !   X  *   !   X  *   !    X  *   !   X   *
//         0   1  2   3  4   5  6   7   8  9   10   11 12  13  14  15

int gcd(int a, int b) {
    ...
    next = g[3] % g[11] - g[8];           // 3 % 3 - 0            = 0 - 0             = 0
    next = 3 * g[11] - 4 * (g[4] % g[5]); // 3 * 3 - 4 * (27 % 5) = 9 - 4 * 2 = 9 - 8 = 1
    next = g[5] - g[3];                   // 5 - 3                                    = 2
    next = g[2] % g[1];                   // 13 % 5                                   = 3
    next = g[15] - g[4];                  // 31 - 27                                  = 4 
    ...
}
/* every third cell starting from 0 has a value 3 mod 7  (*) */
/* every third cell starting from 1 has a value 5 mod 11 (!) */
/* every other cell contains some fixed value            (X) */
int g[] = {10, 5, 13, 3, 27, 5, 24, 38, 0, 73, 115, 3, 66, 60, 17, 31};
//         *   !  X   *  !   X  *   !   X  *   !    X  *   !   X   *
//         0   1  2   3  4   5  6   7   8  9   10   11 12  13  14  15

int gcd(int a, int b) {
    ...
    next = g[3] % g[11] - g[8];           // 3 % 3 - 0            = 0 - 0             = 0
    next = 3 * g[11] - 4 * (g[4] % g[5]); // 3 * 3 - 4 * (27 % 5) = 9 - 4 * 2 = 9 - 8 = 1
    next = g[5] - g[3];                   // 5 - 3                                    = 2
    next = g[2] % g[1];                   // 13 % 5                                   = 3
    next = g[15] - g[4];                  // 31 - 27                                  = 4 
    ...
}

Dynamic Obfuscation

Example: Dynamic Code Merging

f_1f1f_1
0 1 2 3 4
b7 48 a0 53 fa
f_2f2f_2
0 1 2 3
e9 48 a0 33
TTT
0 1 2 3 4
? 48 a0 ? ?

e_1 = \{0 \to \texttt{b7}, 3 \to \texttt{53}, 4 \to \texttt{fa}\}e1={0b7,353,4fa}e_1 = \{0 \to \texttt{b7}, 3 \to \texttt{53}, 4 \to \texttt{fa}\}
e_2 = \{0 \to \texttt{e9}, 3 \to \texttt{33}\}e2={0e9,333}e_2 = \{0 \to \texttt{e9}, 3 \to \texttt{33}\}

Collberg's Taxonomy

Software-Based Integrity Checking

Code Integrity

State Integrity

Hardware-Based Software Protection

Static Security

Dynamic Security

Side-Channel Attacks

Privacy-Enhancing Technologies

Anonymization

Example: 4-anonymous table, 3 equivalence classes

# Zip Age Sex Condition
1 130** < 30 * Hepatitis
2 130** < 30 * Hepatitis
3 130** < 30 * Flu
4 130** < 30 * Flu
5 148** >= 40 * Cancer
6 148** >= 40 * Hepatitis
7 148** >= 40 * Flu
8 148** >= 40 * Flu
9 130** 3* * Cancer
10 130** 3* * Cancer
11 130** 3* * Cancer
12 130** 3* * Cancer

Inverse Transparency

Passwords

Alternatives

Malware

Misconfiguration

Problems