Is it possible to read released memory of another process?

Viewed 61
Context

I want to write a software where, at some point, the user will have to type a password. I would like to make it as secure as possible since this password may give access to potentially highly sensitive data.

What I planned to achieve is to zero the memory that holds the entered password before releasing it in order to minimize the time it is exposed in memory.

Motivation

The main reason I'm concerned with this is that, despite I know each process memory is isolated thanks to memory virtualization, I discovered that the Windows API exposes some functions like ReadProcessMemory() (maybe we have an equivalent on Unix-like platforms) which allows to access another process memory.

Such a feature is very annoying for me because it constitutes a potential security breach for my software, hence the reason why I care about zeroing the data in memory as soon as it's not needed anymore to reduce its exposure.

Issue

My problem is that I intended to build my GUI with .
The appropriate widget for typing sensitive data seems to be QLineEdit since it proposes an echo mode tuning whether we want to hide the data in the GUI while typing or not. A feature clearly made for passwords.

But... when it comes to zero the memory, it seems it's not possible to do it since this widget returns the text by copy (see here) where I was expecting a reference (and there is no such alternative).

Question

Something came to my mind, are functions such as ReadProcessMemory() also able to access released memory ?

I mean, if they can't, I don't necessarily need to zero the memory, I just have to set the text to something else and thus either the QString will be updated (if it can contain the new one) or it will be released and a new QString will be created.

I read in the ReadProcessMemory()'s documentation the following sentence:

"The function fails if the requested read operation crosses into an area of the process that is inaccessible."

But I'm not sure if I'm not misinterpreting it (i.e. if released memory belongs to what they call "inaccessible area") and still I have no guarantee that other APIs from other OSes won't expose a more powerful function.

Note: I only interested to Windows, Mac OS and the common Linux distributions (debian-based or Red Hat-based).

0 Answers
Related