1. Topics
  2. Security
  3. What is address space layout randomization (ASLR)?

What is address space layout randomization (ASLR)?

CopiedCopy failedCopy URL

Address space layout randomization (ASLR) is a defense-in-depth strategy for system memory. It operates on a simple principle: By randomizing the places where the base addresses of key memory regions operate, it becomes more difficult for attackers to find and exploit memory vulnerabilities. We’re now in a post-Mythos world, with dramatically accelerated discovery of Common Vulnerabilities and Exposures (CVEs). ASLR is another layer that, when combined with your overall Linux® security posture, can help slow down attackers and buy time until patches can be deployed.

E-book: Reducing the CVE window

A memory exploit is a way an attacker takes control of a program, often by way of a buffer overflow.

A buffer is a fixed block of memory a program sets aside for incoming data. When the program copies in more than that block can hold, and does not check the length, the extra bytes spill into the memory next to it. On the stack, those bytes can overwrite the saved return address, which tells the program where to continue once it finishes the current task. Replacing it can send the program to an address the attacker chooses.

Before following that address, the program checks a stack canary—a value placed between the buffer and the saved return address. Reaching the return address means the canary was overwritten too. If it no longer matches, the program stops.

Buffer overflows are a common example of the overwrite a stack canary is built to catch. Other memory misuse still depends on predictable layout. Attackers will use other techniques to try to reuse code that's already present in memory. They do this either by jumping into a known library routine or chaining together short, existing instruction sequences rather than injecting an entirely new payload of malicious code. 

 

Stack canary buffer overflow


Read a detailed explanation of a buffer overflow

Red Hat resources

The techniques above work only if the attacker knows where to send the malicious program. If those locations stay the same every time, the attacker can aim the exploit in advance. This is where ASLR comes in. 

Every item in memory has an address. ASLR randomizes where key regions of a process are placed each time a program starts. Without a predictable place to aim, malicious code doesn’t have a reliable place to take hold. ASLR doesn’t prevent attacks, but it greatly reduces the likelihood of success.

ASLR isn’t limited to user applications. Kernel address space layout randomization (KASLR) brings this approach to the operating system kernel. By shifting where critical code and data live in memory, it leaves kernel-targeted attacks facing that same unpredictability. Together, process-level ASLR and KASLR make memory exploits less likely to succeed in both the application and the kernel.

What ASLR randomizes

ASLR typically shifts the layout of several critical areas, including:

  • The temporary storage for function calls and local data (often referred to as “the stack”).
  • Dynamically allocated memory used while a program runs (“the heap”).
  • Shared libraries (the common code modules loaded into many processes).
  • The main executable base (the starting address of the program itself, when it’s built to support randomization).

With ASLR enabled, these locations will change from run to run. An exploit designed around a fixed layout is therefore less likely to hit its target.

ASLR is a basic, effective protection against memory exploits. Attackers who have to guess an address are much less likely to succeed, and when they guess wrong, the process usually crashes instead of handing over control of the system.

That outcome is useful because the crash breaks the attempt. It can also show up in existing monitoring if crashes are already being watched. ASLR makes a successful memory exploit harder until the fix is deployed. Pair it with crash monitoring, so you’ll be aware when it happens, and with your normal patching process, which removes the flaw.

ASLR is a useful default control, but it’s not complete protection on its own.

Its effectiveness depends on how software is built and how the system is configured. An application compiled without support for address randomization may still load at predictable locations, leaving gaps an attacker can aim for. Older or narrower address layouts also offer fewer possible placements than modern 64-bit systems, which can make guessing somewhat more practical in those environments.

Separate flaws that leak memory addresses can also undermine ASLR. If an attacker learns where key regions landed for a running process, randomization loses much of its value for that target.

ASLR is part of the foundation for a multilayer approach to system security. It works most effectively when combined with other controls that limit what an attacker can do even if a memory flaw exists.

To protect memory, ASLR naturally teams up with defenses that stop injected data from running as code. It also pairs with compiler and runtime safeguards that make stack exploits much harder to pull off.

Randomizing layout makes targeting more difficult, while those companion controls make executing or chaining an attack more difficult, even if the overflow still occurs.

ASLR also works alongside broader platform controls: Security-Enhanced Linux (SELinux) for mandatory access controls, fapolicyd for application allowlisting, and Identity Management (IdM) for managing identities and access. Together, ASLR and these controls make it harder for 1 memory flaw to become a full compromise.

A guide to security technologies in Red Hat Enterprise Linux

ASLR is enabled by default in Red Hat® Enterprise Linux. It’s part of the platform’s built-in memory protections, so supported workloads get layout unpredictability without a separate product or added feature. It’s a critical piece of the vulnerability and threat mitigation features found in Red Hat Enterprise Linux.

When paired with Red Hat Lightspeed, connected Red Hat Enterprise Linux systems can see which known vulnerabilities they’re exposed to and build a plan to remediate them. ASLR makes a successful memory exploit harder while that fix is on the way.

Learn more about security in Red Hat Enterprise Linux

Red Hat Enterprise Linux 10

Discover how Red Hat Enterprise Linux 10 addresses today’s most pressing IT challenges, from the Linux skills gap to post-quantum security.

All Red Hat product trials

Our no-cost product trials help you gain hands-on experience, prepare for a certification, or assess if a product is right for your organization.

Keep reading

What is a software bill of materials (SBOM)?

Understand the role of a software bill of materials (SBOM) in software transparency, risk management, and protecting your supply chain from vulnerabilities.

Shift left vs. shift right

To shift left and shift right is to implement continuous testing throughout each stage of the software development lifecycle.

What is SELinux?

Security-Enhanced Linux (SELinux) is a security architecture for Linux® systems that allows administrators to have more control over who can access the system.

Security resources

Featured product

  • Red Hat Enterprise Linux

    A stable, high-performance Linux platform with built-in security and management features to help you run critical workloads anywhere in the hybrid cloud.

Related articles