21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Unfortunately, there is no way to prevent memory dumps on a per-application basis<br />

on Windows. The settings for how to handle an application crash are system-wide,<br />

stored in the registry under HKEY_LOCAL_MACHINE, and they require Administrator<br />

access to change them. Even if you’re reasonably certain Dr. Watson will be the handler<br />

on systems on which your program will be running, there is no way you can disable<br />

its functionality on a per-application basis. On the other hand, any dump that<br />

may be created by Dr. Watson is properly protected by ACLs that prevent any other<br />

user from accessing them.<br />

Discussion<br />

On most Unix systems, a program that crashes will “dump core.” The action of<br />

dumping core causes an image of the program’s committed memory at the time of<br />

the crash to be written out to a file on disk, which can later be used for post-mortem<br />

debugging.<br />

The problem with dumping core is that the program may contain potentially sensitive<br />

information within its memory at the time the image is written to disk. Imagine a<br />

program that has just read in a user’s password, and then is forced to dump core<br />

before it has a chance to erase or otherwise obfuscate the password in memory.<br />

Because an attacker may be able to manipulate the program’s runtime environment<br />

in such a way as to cause it to dump core, and thus write any sensitive information to<br />

disk, you should try to prevent a program from dumping core if there’s any chance<br />

the attacker may be able to get read access to the core file.<br />

Generally, core files are written in such a way that the owner is the only person who<br />

can read and modify them, but silly things often happen, such as lingering core files<br />

accidentally being made world-readable by a recursive permissions change.<br />

It’s best to prevent against core dumps as early in the program as possible, because if<br />

an attacker is manipulating the program in a way that causes it to crash, you cannot<br />

know in advance what state the program will be in when the attacker manages to<br />

force it to crash.<br />

Process core dumping can be restricted on a per-application basis by using the<br />

resource limit capabilities of most Unix systems. One of the standard limits that can<br />

be applied to a process is the maximum core dump file size. This limit serves to protect<br />

against large (in terms of memory consumption) programs that dump core and<br />

could potentially fill up all available disk space. Without this limit in place, it would<br />

even be possible for an attacker who has discovered a way to cause a program to<br />

crash from remote and dump core to fill up all available disk space on the server. Setting<br />

the value of RLIMIT_CORE to 0 prevents the process from writing any memory<br />

dump to disk, instead simply terminating the program when a fatal problem is<br />

encountered.<br />

36 | Chapter 1: Safe Initialization<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!