Sunday, June 04, 2023

Linux Stack Protection By Default

Modern gcc compiler (v9.2.0) protects the stack by default and you will notice it because instead of SIGSEGV on stack overflow you will get a SIGABRT, but it also generates coredumps.




In this case the compiler adds the variable local_10. This variable helds a canary value that is checked at the end of the function.
The memset overflows the four bytes stack variable and modifies the canary value.



The 64bits canary 0x5429851ebaf95800 can't be predicted, but in specific situations is not re-generated and can be bruteforced or in other situations can be leaked from memory for example using a format string vulnerability or an arbitrary read wihout overflowing the stack.

If the canary doesn't match, the libc function __stack_chck_fail is called and terminates the prorgam with a SIGABORT which generates a coredump, in the case of archlinux managed by systemd and are stored on "/var/lib/systemd/coredump/"


❯❯❯ ./test 
*** stack smashing detected ***: terminated
fish: './test' terminated by signal SIGABRT (Abort)

❯❯❯ sudo lz4 -d core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000.lz4
[sudo] password for xxxx: 
Decoding file core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000 
core.test.1000.c611b : decoded 249856 bytes 

 ❯❯❯ sudo gdb /home/xxxx/test core.test.1000.c611b7caa58a4fa3bcf403e6eac95bb0.1121.1574354610000000 -q 


We specify the binary and the core file as a gdb parameters. We can see only one LWP (light weight process) or linux thread, so in this case is quicker to check. First of all lets see the back trace, because in this case the execution don't terminate in the segfaulted return.




We can see on frame 5 the address were it would had returned to main if it wouldn't aborted.



Happy Idea: we can use this stack canary aborts to detect stack overflows. In Debian with prevous versions it will be exploitable depending on the compilation flags used.
And note that the canary is located as the last variable in the stack so the previous variables can be overwritten without problems.




Read more


  1. Underground Hacker Sites
  2. Hacking Tools For Games
  3. Hacker Tools Windows
  4. Hacker Tools Apk
  5. Hacking Tools Free Download
  6. Hacking Tools For Games
  7. How To Hack
  8. How To Hack
  9. Pentest Tools Linux
  10. Pentest Tools For Mac
  11. Hacking Tools For Games
  12. Pentest Box Tools Download
  13. Hacker Tools
  14. Hack Tools Pc
  15. Hacker Tools Mac
  16. Pentest Tools Free
  17. Hack Website Online Tool
  18. Hack Apps
  19. Physical Pentest Tools
  20. Pentest Tools Android
  21. Hacker Security Tools
  22. Blackhat Hacker Tools
  23. Hacker Tools
  24. Computer Hacker
  25. Pentest Tools Android
  26. Hack Tool Apk No Root
  27. Hacking Tools Kit
  28. Best Hacking Tools 2019
  29. Pentest Tools Subdomain
  30. Pentest Tools Nmap
  31. Pentest Tools Website
  32. Underground Hacker Sites
  33. Pentest Tools Linux
  34. Tools Used For Hacking
  35. Hacking Tools Free Download
  36. Hack Tools Pc
  37. Termux Hacking Tools 2019
  38. Hacking Tools And Software
  39. Hacking Tools For Games
  40. Hacking Tools Pc
  41. Hacker Tools Github
  42. Pentest Reporting Tools
  43. Tools Used For Hacking
  44. Github Hacking Tools
  45. Install Pentest Tools Ubuntu
  46. Hack Tools 2019
  47. Hackers Toolbox
  48. Hacking Tools For Beginners
  49. Pentest Tools Download
  50. Tools Used For Hacking
  51. Underground Hacker Sites
  52. Hacking Tools Usb

No comments: