Address Space Layout Randomization (ASLR) is a memory-protection process for operating systems that guards against buffer-overflow attacks. It helps to ensure that the memory addresses associated with running processes on systems are not predictable, thus flaws or vulnerabilities associated with these processes will be more difficult to exploit.\nASLR is used today on Linux, Windows, and MacOS systems. It was first implemented on Linux in 2005. In 2007, the technique was deployed on Microsoft Windows and MacOS. While ASLR provides the same function on each of these operating systems, it is implemented differently on each one.\nThe effectiveness of ASLR is dependent on the entirety of the address space layout remaining unknown to the attacker. In addition, only executables that are compiled as Position Independent Executable (PIE) programs will be able to claim the maximum protection from ASLR technique because all sections of the code will be loaded at random locations. PIE machine code will execute properly regardless of its absolute address.\n\nASLR limitations\nIn spite of ASLR making exploitation of system vulnerabilities more difficult, its role in protecting systems is limited. It's important to understand that ASLR:\n\nDoesn't resolve vulnerabilities, but makes exploiting them more of a challenge\nDoesn't track or report vulnerabilities\nDoesn't offer any protection for binaries that are not built with ASLR support\nIsn't immune to circumvention\n\nHow ASLR works\nASLR increases the control-flow integrity of a system by making it more difficult for an attacker to execute a successful buffer-overflow attack by randomizing the offsets it uses in memory layouts.\nASLR works considerably better on 64-bit systems, as these systems provide much greater entropy (randomization potential).\nIs ASLR working on your Linux system?\nEither of the two commands shown below will tell you whether ASLR is enabled on your system.\n$ cat \/proc\/sys\/kernel\/randomize_va_space\n2\n$ sysctl -a --pattern randomize\nkernel.randomize_va_space = 2\n\nThe value (2) shown in the commands above indicates that ASLR is working in full randomization mode. The value shown will be one of the following:\n0 = Disabled\n1 = Conservative Randomization\n2 = Full Randomization\n\nIf you disable ASLR and run the commands below, you should notice that the addresses shown in the ldd output below are all the same in the successive ldd commands. The ldd command works by loading the shared objects and showing where they end up in memory.\n$ sudo sysctl -w kernel.randomize_va_space=0\t \/lib\/x86_64-linux-gnu\/libdl.so.2 (0x00007ffff7c63000)\n libc.so.6 => \/lib\/x86_64-linux-gnu\/libc.so.6 (0x00007ffff7a79000)\n \/lib64\/ld-linux-x86-64.so.2 (0x00007ffff7fd3000)\n$ ldd \/bin\/bash\n linux-vdso.so.1 (0x00007ffff7fd1000) \/lib\/x86_64-linux-gnu\/libtinfo.so.6 (0x00007ffff7c69000)\n libdl.so.2 => \/lib\/x86_64-linux-gnu\/libdl.so.2 (0x00007ffff7c63000)\n libc.so.6 => \/lib\/x86_64-linux-gnu\/libc.so.6 (0x00007ffff7a79000)\n \/lib64\/ld-linux-x86-64.so.2 (0x00007ffff7fd3000)\n\nIf the value is set back to 2 to enable ASLR, you will see that the addresses will change each time you run the command.\n$ sudo sysctl -w kernel.randomize_va_space=2\t \/lib\/x86_64-linux-gnu\/libdl.so.2 (0x00007f1cb7cda000)\n libc.so.6 => \/lib\/x86_64-linux-gnu\/libc.so.6 (0x00007f1cb7af0000)\n \/lib64\/ld-linux-x86-64.so.2 (0x00007f1cb8045000)\n$ ldd \/bin\/bash\n linux-vdso.so.1 (0x00007ffe1cbd7000) \/lib\/x86_64-linux-gnu\/libtinfo.so.6 (0x00007fed59742000)\n libdl.so.2 => \/lib\/x86_64-linux-gnu\/libdl.so.2 (0x00007fed5973c000)\n libc.so.6 => \/lib\/x86_64-linux-gnu\/libc.so.6 (0x00007fed59552000)\n \/lib64\/ld-linux-x86-64.so.2 (0x00007fed59aa7000)\n\nAttempting to bypass ASLR\nIn spite of its advantages, attempts to bypass ASLR are not uncommon and seem to fall into several categories:\n\nUsing address leaks\nGaining access to data relative to particular addresses\nExploiting implementation weaknesses that allow attackers to guess addresses when entropy is low or when the ASLR implementation is faulty\nUsing side channels of hardware operation\n\nWrap-up\nASLR is of great value, especially when run on 64 bit systems and implemented properly. While not immune from circumvention attempts, it does make exploitation of system vulnerabilities considerably more difficult. Here is a reference that can provide a lot more detail on the Effectiveness of Full-ASLR on 64-bit Linux, and here is a paper on one circumvention effort to\u00a0bypass ASLR\u00a0using branch predictors.