I am currently looking into security measures adapted by OSX and noticed something really weird. Though they claim to support ASLR for all binaries by default, it seems that all of the dylib are located at fixed address across runs.
Here is my script to test this, the output is also shown below
test.c
#include<stdio.h>
int main(){
printf("main address : %p\n",&main);
printf("printf address : %p\n",&printf);
return 0;
}
output for five consecutive runs
main address : 0x10bbd5f00
printf address : 0x7fff9a053154
main address : 0x109c82f00
printf address : 0x7fff9a053154
main address : 0x1044a7f00
printf address : 0x7fff9a053154
main address : 0x103d7cf00
printf address : 0x7fff9a053154
main address : 0x10c90ef00
printf address : 0x7fff9a053154
The result clearly shows that while PIE is enabled, ASLR is certainly not.
To further check whether ASLR is specifically disabled for libsystem_c.dylib, I also ran the test code with DYLD_PRINT_SEGMENTS=1, and confirmed all dylib are located in fixed locations.
So my question is, is ASLR really available/supported on mac?
If yes, how should I enable it?
If no, what are possible reasons that apple fail/refuse to implement this feature?
Notes :
The code is ran on OSX El Captain(10.11.6) and Mojave(10.14.6)