Sunday, May 28, 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.




More articles


  1. Hackrf Tools
  2. Hack Tool Apk No Root
  3. Pentest Tools Github
  4. Pentest Tools For Ubuntu
  5. Hack Tools Github
  6. Pentest Tools Download
  7. Hack Tools
  8. Wifi Hacker Tools For Windows
  9. Github Hacking Tools
  10. Pentest Tools Review
  11. Hack Tools
  12. Hackrf Tools
  13. Physical Pentest Tools
  14. Hacking Tools Online
  15. Hacker Tools Software
  16. Pentest Tools Find Subdomains
  17. Hacking Tools Free Download
  18. Pentest Tools Windows
  19. Nsa Hack Tools Download
  20. Hack Tools
  21. Wifi Hacker Tools For Windows
  22. Pentest Tools Kali Linux
  23. Hacking App
  24. Hacker
  25. Tools For Hacker
  26. Hacking App
  27. Pentest Tools Framework
  28. Hacker Tools Free Download
  29. Pentest Recon Tools
  30. Pentest Reporting Tools
  31. Hack Tools For Games
  32. Hacker Tools Free Download
  33. Pentest Recon Tools
  34. Blackhat Hacker Tools
  35. Hacker Tools Windows
  36. Hacking Tools Name
  37. Pentest Tools For Mac
  38. Hacker Search Tools
  39. Pentest Tools Windows
  40. Underground Hacker Sites
  41. Pentest Tools Website
  42. Pentest Tools Bluekeep
  43. Hacking Tools For Mac
  44. Pentest Tools Website Vulnerability
  45. Hacking Tools 2019
  46. Pentest Box Tools Download
  47. Nsa Hack Tools Download
  48. Pentest Box Tools Download
  49. Hacking Tools For Games
  50. Hacking Tools Pc
  51. Hack Tool Apk
  52. How To Install Pentest Tools In Ubuntu
  53. Termux Hacking Tools 2019
  54. Hacking Tools Online
  55. Pentest Tools Apk
  56. Pentest Tools Open Source
  57. Pentest Box Tools Download
  58. Pentest Tools For Windows
  59. Pentest Tools For Mac

No comments:

Post a Comment