Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Protecting RAM Secrets with Address Windowing Extensions

Protecting RAM Secrets with Address Windowing Extensions

The Virtual Memory Manager (VMM) in Windows does not allow programs to lock user memory in order to prevent that memory from being swapped out to disk. This limitation, not present in other operating systems, has caused numerous security problems with encryption keys, passwords, and other sensitive information leaking from RAM to hard disk automatically under Microsoft Windows.

As demonstrated in my previous column ("Beware of File-Slack Attacks http://www.ddj.com/documents/ddj041006sec/), anything written to hard disk temporarily can be recovered with relative ease. The system virtual-memory-paging swap file can be resized manually, or Windows may resize it as needed. When the pagefile grows in size, there will not be any sensitive data stored in unallocated clusters on the drive, but that does not mean the sensitive data cannot be accessed.

Powering down a Windows box and removing the drive that contains a pagefile allows unrestricted access to its contents. A drive sector editor or other forensic tool can read directly from the sectors and clusters that belong to the system pagefile. Or, the pagefile may shrink when a reboot occurs, exposing formerly allocated clusters from the pagefile as unallocated clusters that can then easily be carved from the drive.

The only way to prevent Windows from swapping data from RAM to pagefile is to manage physical memory directly in your code. Windows 2000 introduced an API for doing just this, known as Address Windowing Extensions (AWE). The primary purpose of AWE is to remove the 4-GB physical memory limit of a 32-bit software architecture by enabling code to allocate large chunks of physical memory and then map access to the physical memory into a window of virtual memory that is 32-bit addressable. This is similar to working with memory-mapped files that are larger than the available physical memory in a computer, except there is no disk I/O involved.

The MSDN Library contains documentation for the AWE support functions: http://msdn.microsoft.com/library/en-us/memory/base/address_windowing_extensions.asp

Sample code for making use of AWE can also be found in an October 1999 MSJ article written by Jeffrey Richter: http://www.microsoft.com/msj/1099/win32/win321099.aspx

Special privileges are required in order for a user account other than System to use AWE. By default, no user, not even Administrator, is granted the necessary privilege. The "Lock Pages in Memory" user right can be assigned by using Group Policy Editor (gpedit.msc), which hosts the Group Policy MMC snap-in.

Windows XP Home does not support Policies or User Rights, but it should be possible to grant the "Lock Pages in Memory" privilege with a hack to the HKLM\SECURITY Registry hive if support under Windows XP is critical for your secure application.

Jason Coombs is Director of Forensic Services for PivX Solutions Inc. (NASDAQ OTCBB: PIVX), a provider of security solutions, computer forensics, and expert witness services. Reach him at [email protected].

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.