Avoid Exposing Sensitive Information

When a program reads passwords or other sensitive information, it should perform whatever processing is required, and then immediately erase the information from memory. (We show an example of this in Section 8.5.) Leaving such information in memory is a security risk, for the following reasons:

Following on from the last point, as a general principle, a secure program should prevent core dumps, so that a core dump file can’t be inspected for sensitive information. A program can ensure that a core dump file is not created by using setrlimit() to set the RLIMIT_CORE resource limit to 0 (see Details of Specific Resource Limits).

Note

By default, Linux doesn’t permit a set-user-ID program to perform a core dump in response to a signal (Core Dump Files), even if the program has dropped all privileges. However, other UNIX implementations may not provide this security feature.