Thursday 18 January 2024

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.




Related articles


  1. Hacking Tools For Windows
  2. Hacker Tools List
  3. Hacking Tools Free Download
  4. Hacking Tools For Mac
  5. Hack Tools
  6. Hack Tools Mac
  7. Hacking Tools Download
  8. Hacker Tools For Mac
  9. Ethical Hacker Tools
  10. Pentest Tools Framework
  11. Hacker Tools Free
  12. Hack Tools Github
  13. Hacking Tools Download
  14. Hack App
  15. Hacker Tools 2020
  16. Hacker Hardware Tools
  17. Pentest Tools Bluekeep
  18. Hacker Tools For Pc
  19. Hack Tools For Mac
  20. Hacker Techniques Tools And Incident Handling
  21. Pentest Tools Apk
  22. Pentest Tools Bluekeep
  23. How To Hack
  24. Hacker Tools For Mac
  25. Hacker Tools Mac
  26. Hack Tools For Windows
  27. Pentest Tools Apk
  28. Hacker Tools Free
  29. Hacker Tools Free Download
  30. Hacking Tools Online
  31. New Hack Tools
  32. Best Pentesting Tools 2018
  33. Hacking Tools For Mac
  34. Hack Rom Tools
  35. New Hacker Tools
  36. Android Hack Tools Github
  37. Hacker Tools Free Download
  38. Tools For Hacker
  39. Pentest Tools Alternative
  40. Pentest Tools Windows
  41. Hacking App
  42. Hacking Tools Name
  43. Hacking Tools For Windows
  44. Hacker Tools Apk
  45. Hacker Tools For Mac
  46. Easy Hack Tools
  47. Hacking Tools For Games
  48. Pentest Tools Download
  49. Hacking Tools Windows 10
  50. Hack Tools For Ubuntu
  51. Pentest Box Tools Download
  52. Hacking Tools Pc
  53. Hacking Tools For Windows
  54. Game Hacking
  55. Hacking Tools Github
  56. Hacking Tools Github
  57. Hacker Tools Apk Download
  58. Hack Tools Github
  59. Hacking Tools For Pc
  60. Pentest Tools Android
  61. Pentest Tools Open Source
  62. Pentest Tools Framework
  63. Pentest Tools Url Fuzzer
  64. Hacker Tools Mac
  65. World No 1 Hacker Software
  66. What Are Hacking Tools
  67. Hacking Tools Windows 10
  68. Hackers Toolbox
  69. Install Pentest Tools Ubuntu
  70. Hack Website Online Tool
  71. Hacker Tools Hardware
  72. Hack Tools For Pc
  73. Hacking Tools Windows 10
  74. Hack Tools Pc
  75. Tools Used For Hacking
  76. Growth Hacker Tools
  77. Pentest Tools Online
  78. Pentest Tools Review
  79. Pentest Tools List
  80. World No 1 Hacker Software
  81. Hacker Tools
  82. Tools For Hacker
  83. Pentest Tools Online
  84. Usb Pentest Tools
  85. Hacking Tools
  86. Underground Hacker Sites
  87. Physical Pentest Tools
  88. Hack Tools
  89. Nsa Hacker Tools
  90. Easy Hack Tools
  91. Nsa Hacker Tools
  92. Hacker Tools Hardware
  93. Nsa Hack Tools
  94. Hacking Tools Online
  95. Pentest Tools Online
  96. Hacking Tools For Windows 7
  97. Hacking Tools For Beginners
  98. Hack App
  99. Pentest Tools Linux
  100. Wifi Hacker Tools For Windows
  101. Pentest Tools For Ubuntu
  102. Hacking Tools Download
  103. Pentest Tools For Android
  104. Pentest Tools Port Scanner
  105. Hacking Tools For Pc
  106. Termux Hacking Tools 2019
  107. Hacking Tools Pc
  108. Hack Tool Apk No Root
  109. Hacking Apps
  110. Pentest Reporting Tools
  111. Hacking Tools
  112. Hacking Tools Kit
  113. Nsa Hack Tools
  114. Hacking Tools For Windows Free Download
  115. Hacker Tools 2020
  116. Hacking Tools For Games
  117. Hacker Tools
  118. Hacker Security Tools
  119. Hack Tools
  120. How To Make Hacking Tools
  121. Best Hacking Tools 2019
  122. Hacking Tools And Software
  123. Hacker Tools For Mac
  124. Hack Tools For Ubuntu
  125. Pentest Tools Port Scanner
  126. Pentest Tools Website Vulnerability
  127. Hack Tools Mac
  128. Hack Tools For Games
  129. Ethical Hacker Tools
  130. Pentest Tools Nmap
  131. Hacking Tools For Mac
  132. Pentest Tools Website