How to detect if stack smashing protection is enabled in an iOS app How to detect if stack smashing protection is enabled in an iOS app xcode xcode

How to detect if stack smashing protection is enabled in an iOS app


You could check the generated code yourself. Compile with and without protection, then have a look at the disassembled code (for XCode you can use: View disassembly in XCode 4 (or Xcode 5 or Xcode 6), or just use your favorite disassembler).

Samples of the generated code in both cases can be found here: https://security.stackexchange.com/questions/158609/how-is-the-stack-protection-enforced-in-a-binary?newreg=af786a3bcdc841e1b92110299a2951af

Last but not least, just try to write a small test of your own, which attempts to corrupt the stack. Once you are able to smash the stack, enable the protection flag, rebuild and see if it has any effect. Trivial examples can be found, of course, here: https://en.wikipedia.org/wiki/Stack_buffer_overflow


-fstack-protector-all is a valid option for llvm compiler used in Xcode, see for example http://lists.llvm.org/pipermail/cfe-dev/2017-April/053662.html. It is just poorly documented unfortunately.

For how to verify you can look at assembly generated with and without the option as suggested in the other answer or just compare the generated binaries size at first.