20 years of pax
play

20 Years of PaX PaX Team SSTIC 2012.06.06 20 Years of PaX About - PowerPoint PPT Presentation

About Past Present Future 20 Years of PaX PaX Team SSTIC 2012.06.06 20 Years of PaX About Past Present Future About Introduction Design Concepts Past Userland Present Kernel Self-Protection Toolchain Support Future Userland


  1. About Past Present Future 20 Years of PaX PaX Team SSTIC 2012.06.06 20 Years of PaX

  2. About Past Present Future About Introduction Design Concepts Past Userland Present Kernel Self-Protection Toolchain Support Future Userland Kernel 20 Years of PaX

  3. About Past Present Future Introduction What is PaX? ◮ Host Intrusion Prevention System (HIPS) ◮ Focus: exploits for memory corruption bugs ◮ Bugs vs. exploits vs. exploit techniques ◮ Threat model: arbitrary read/write access to memory ◮ Local/remote and userland/kernel ◮ Linux 2.2.x-2.4.x-2.6.x-3.x (2000-2012) ◮ Developed by the PaX Team :) ◮ grsecurity by Brad Spengler (spender) 20 Years of PaX

  4. About Past Present Future Introduction PaX Features ◮ Runtime code generation control (non-executable pages) ◮ Address Space Layout Randomization (ASLR) ◮ Kernel self-protection ◮ Various infrastructure changes for supporting all the above 20 Years of PaX

  5. About Past Present Future Design Concepts Vulnerability Roadmap Where Things Can Go Wrong ◮ Idea/Design ◮ Education, talent, modeling, art vs. science ◮ Development ◮ Deployment/Configuration/Operation/Maintenance ◮ Procedures (manuals, standards, etc) ◮ Logging/monitoring/analysis 20 Years of PaX

  6. About Past Present Future Design Concepts How to Improve: Development ◮ Education ◮ Tools/Toolchain (analysis, runtime checks) ◮ Testing/Exploiting (fuzzing) ◮ Exploit-resistant runtime environment (PaX :) ◮ Instead of finding the exploitable bugs, make them non-exploitable 20 Years of PaX

  7. About Past Present Future Design Concepts Exploit Techniques ◮ Focus: exploits against memory corruption bugs ◮ Execute injected code (shellcode) ◮ Execute existing code out-of-(intended)-order (return-to-libc, ROP/JOP) ◮ Execute existing code in-(intended)-order (data-only attacks) 20 Years of PaX

  8. About Past Present Future About Introduction Design Concepts Past Userland Present Kernel Self-Protection Toolchain Support Future Userland Kernel 20 Years of PaX

  9. About Past Present Future Userland Overview ◮ Non-executable page support on i386 (PAGEEXEC/SEGMEXEC) ◮ Runtime code generation control (MPROTECT) ◮ Address Space Layout Randomization (ASLR, RANDEXEC) ◮ Compatibility (per-binary feature control, text relocations, trampoline emulation) 20 Years of PaX

  10. About Past Present Future Userland PAGEEXEC/SEGMEXEC/MPROTECT ◮ PAGEEXEC: paging based simulation of non-executable pages on i386 (in 2000, pre-NX days) ◮ SEGMEXEC: segmentation based simulation of non-executable pages on i386 (in 2002) ◮ MPROTECT: runtime code generation control (in 2000) ◮ NX-bit is in wide use nowadays (BSDs, iOS, Linux, Windows/DEP, etc) 20 Years of PaX

  11. About Past Present Future Userland ASLR ◮ Introduced in July 2001 as a stopgap measure (not how it turned out :) ◮ Idea: artificially inflated entropy in memory addresses (both code and data) ◮ Reduced exploit reliability ◮ In wide use nowadays (BSDs, iOS, Linux, Windows, etc) 20 Years of PaX

  12. About Past Present Future About Introduction Design Concepts Past Userland Present Kernel Self-Protection Toolchain Support Future Userland Kernel 20 Years of PaX

  13. About Past Present Future Kernel Self-Protection Overview ◮ Non-executable kernel pages (KERNEXEC) ◮ Read-only kernel data (KERNEXEC, CONSTIFY) ◮ Userland/kernel address space separation (UDEREF) ◮ Restricted userland-kernel copying (USERCOPY) ◮ Userland/kernel copying race reduction ◮ Instant free memory sanitization (SANITIZE) 20 Years of PaX

  14. About Past Present Future Kernel Self-Protection KERNEXEC ◮ Non-executable pages for the kernel’s address space ◮ Executable userland pages must not be executable from kernel mode ◮ i386: code segment excludes the entire userland address space ◮ amd64: compiler plugin or UDEREF ◮ Supervisory Mode Execution Protection ( CR4.SMEP ) since Ivy Bridge (in mainline linux already) ◮ Page table cleanup: read-write vs. read-execute regions (kmaps) ◮ Special cases: boot/BIOS, ACPI, EFI, PNP, v8086 mode memory, vsyscall (amd64) 20 Years of PaX

  15. About Past Present Future Kernel Self-Protection Constification ◮ Creates read-only data mappings ◮ Moves data into read-only mappings ( .rodata , .data..read_only ) ◮ Patches (descriptor tables, top level page tables, etc) ◮ Compiler plugin (ops structures) 20 Years of PaX

  16. About Past Present Future Kernel Self-Protection UDEREF ◮ Prevents unintended userland access by kernel code ◮ Disadvantage of the shared user/kernel address space ◮ i386: based on segmentation ◮ data segment excludes the entire userland address space ◮ amd64: based on paging ◮ remaps userland page tables as non-executable while in kernel mode ◮ needs per-cpu page global directory (PGD) 20 Years of PaX

  17. About Past Present Future Kernel Self-Protection USERCOPY ◮ Bounds checking for copying from kernel memory to userland (info leak) or vice versa (buffer overflow) ◮ spender’s idea: ksize can determine the object’s size from the object’s address ◮ Originally heap (slab) buffers only ◮ Limited stack buffer support (see Future section) ◮ Disables SLUB merging 20 Years of PaX

  18. About Past Present Future Kernel Self-Protection Userland/Kernel Copying Races ◮ Userland/kernel copying can (be made to) sleep ◮ During that sleep userland memory can change ◮ Time-Of-Check-To-Time-Of-Use race (TOCTTOU) ◮ Unbounded userland/kernel copying based exploits become controllable ◮ Basically prefaults the userland range ◮ Reduces but does not eliminate race window ◮ Detects controlled unbounded copies before the actual copy 20 Years of PaX

  19. About Past Present Future Kernel Self-Protection SANITIZE ◮ Reduces potential info leaks from kernel memory to userland ◮ Freed memory is cleared immediately ◮ Low-level page allocator, not slab layer ◮ Works on whole pages, not individual heap objects ◮ Kernel stacks on task death ◮ Anonymous userland mappings on munmap ◮ Anti-forensics vs. privacy 20 Years of PaX

  20. About Past Present Future Toolchain Support Overview ◮ gcc plugins (gcc 4.5-4.7) ◮ Kernel stack leak reduction (STACKLEAK) ◮ Function pointer structure constification (CONSTIFY) ◮ User/kernel address space separation for code only (KERNEXEC) ◮ Size parameter overflow detection&prevention (SIZE_OVERFLOW) 20 Years of PaX

  21. About Past Present Future Toolchain Support GCC plugins ◮ Loadable module system introduced in gcc 4.5 ◮ Loaded early right after command line parsing ◮ No well defined API, all public symbols available for plugin use ◮ Typical (intended :) use: new IPA/GIMPLE/RTL passes 20 Years of PaX

  22. About Past Present Future Toolchain Support STACKLEAK plugin ◮ First plugin :) ◮ Reduces kernel stack information leaks ◮ Before a kernel/userland transition the used kernel stack part is cleared ◮ Stack depth is recorded in functions having a big enough stack frame ◮ Sideeffect: finds all (potentially exploitable :) alloca calls ◮ Special paths for ptrace/auditing ◮ Problems: considerable overhead, races, leaks from a single syscall still possible 20 Years of PaX

  23. About Past Present Future Toolchain Support CONSTIFY plugin ◮ Automatic constification of ops structures (200+ in linux) ◮ Structures with function pointer members only ◮ Structures explicitly marked with a do_const attribute ◮ no_const attribute for special cases ◮ Local variables not allowed 20 Years of PaX

  24. About Past Present Future Toolchain Support KERNEXEC plugin ◮ Prevents executing userland code on amd64 ◮ i386 achieves this already via segmentation ◮ Sets most significant bit in all function pointers ◮ Userland addresses become non-canonical ones ◮ GIMPLE pass: C function pointers ◮ RTL pass: return values ◮ Special cases: assembly source, asm() ◮ Two methods: bts vs. or (reserves %r10 for bitmask) ◮ Compatibility vs. performance 20 Years of PaX

  25. About Past Present Future Toolchain Support SIZE_OVERFLOW plugin ◮ Detects integer overflows in expressions used as a size parameter: kmalloc(count * sizeof...) ◮ Written by Emese Révfy ◮ Proper implementation of spender’s old idea ◮ Initial set of functions/parameters marked by the size_overflow function attribute ◮ Walks use-def chains and duplicates statements using a double-wide integer type ◮ SImode/DImode vs. DImode/TImode ◮ Special cases: asm(), function return values, constants (intentional overflows), etc ◮ More in the blog Real Soon Now: http://forums.grsecurity.net/viewforum.php?f=7 20 Years of PaX

  26. About Past Present Future About Introduction Design Concepts Past Userland Present Kernel Self-Protection Toolchain Support Future Userland Kernel 20 Years of PaX

  27. About Past Present Future Userland Overview ◮ Control Flow Enforcement ◮ Size overflow detection & prevention ◮ Kernel-assisted use-after-free detection 20 Years of PaX

  28. About Past Present Future Userland Control Flow Enforcement ◮ Compiler plugin ◮ (No) binary-only code support ◮ Assembly source instrumentation ◮ Runtime code generation support (Just-In-Time compiler engines) 20 Years of PaX

Recommend


More recommend