Smashing the Stack Protector for Fun and Profit 1 1996: Smashing - - PowerPoint PPT Presentation

smashing the stack protector for fun and profit
SMART_READER_LITE
LIVE PREVIEW

Smashing the Stack Protector for Fun and Profit 1 1996: Smashing - - PowerPoint PPT Presentation

Smashing the Stack Protector for Fun and Profit 1 1996: Smashing The Stack for Fun and Profit ... overflow direction / higher addresses int main(int argc, char **argv) buf { stack growth char buf[0x10]; gets(buf); saved return address


slide-1
SLIDE 1

Smashing the Stack Protector for Fun and Profit

1

slide-2
SLIDE 2

1996: Smashing The Stack for Fun and Profit

int main(int argc, char **argv) { char buf[0x10]; gets(buf); return 0; }

2

saved return address argc argv buf stack growth

  • verflow direction / higher addresses

... ...

slide-3
SLIDE 3

1998: StackGuard

int main(int argc, char **argv) { char buf[0x10]; gets(buf); return 0; }

3

saved return address argc argv buf stack growth

  • verflow direction / higher addresses

... ... stack canary

Function Prologue: Place canary on stack Function Epilogue: Check canary integrity

slide-4
SLIDE 4

Our Work: (Systematic) Evaluation of Implementations

  • Integrity check is implemented as a comparison with some reference value
  • Central question:

Where is the reference value stored?

4

slide-5
SLIDE 5

Background: Memory Types

  • Stack based variable - local variable

int a(void) { char loc[0x10];

  • Thread Local Storage - storage specific to one thread

char __thread tls[0x10];

  • Static - global variable

static char sta[0x10];

  • Dynamic - allocated with malloc

char *dyn = malloc(0x10);

5

slide-6
SLIDE 6

Sample Address Space Layout

6

... (kernel) ... ... ... stack reference canary tls heap ... Code / Static Data

  • Measurement:

○ Distances ○ Gaps / Permissions

  • Classification:

○ OK ✓ ○ Weak ✗ ○ Vulnerable ✗

slide-7
SLIDE 7

7

... (kernel) (Guard page) ---p (Guard page) ---p ... stack reference canary tls heap ... Code / Static Data ... (kernel) ฀ (Guard page) ---p ... stack reference canary tls heap ... Code / Static Data ... (kernel) ฀ ... ... stack reference canary tls heap ... Code / Static Data

OK ✓ Weak ✗ Vulnerable ✗

slide-8
SLIDE 8

8

slide-9
SLIDE 9

Conclusion: libcs with Thread Local Storage & Threading Are completely broken!

9

slide-10
SLIDE 10

=========================================================================== ASIACCS’17 Review #386A

  • Paper #386: CookieCrumbl0r: Smashing the Stack Protector for Fun and Profit
  • Overall merit: 2. Weak reject

Reviewer expertise: 4. Expert (...) ===== Weaknesses of paper ===== With the rise of CFI mechanisms that will protect the backward edge through some form of stack integrity, defenses that rely on stack cookies are on their way out, therefore this paper has low novelty and impact.

10

⇒ Fallacy!

slide-11
SLIDE 11

11

int auth(char * valid) { char password[32]; gets(password); return strcmp(valid, crypt(password, valid)) == 0; } void main(void) { char admin_hash[] = "$6$..."; // long hash value if (auth(admin_hash)) { puts("Welcome to the Admin Area"); } }

Why we need stack canaries, even with CFI:

slide-12
SLIDE 12

12

SafeStack: Canaries: SafeStack + Canaries:

slide-13
SLIDE 13

Conclusion: Stack Canaries are still a strong protection mechanism and should be used together with newer techniques like CFI.

13