Search code examples
c#wpfpasswordbox

Why can I see the password of a PasswordBox in Snoop?


I am trying to understand how does PasswordBox protect the reading of the password from an external application. And what I don't understand is how come I have the capacity to read the password of my WPF window with Snoop :

enter image description here

I thought this was the kind of breach that PasswordBox was supposed to solve.


Solution

  • In order to be useable - at one point or another - the password must be in memory as a clear string and/or must be retreivable as a clear string. SecureString and PasswordBox limit that time of vulnerability. But they can not get rid of it. It can do stuff like force agressive collection by the GC, prevent Optimsiations like String itnerning and even overwriting the memory with random data the moment it runs out of scope.

    The Passwrod property is how you retrieve said naked string. And snoop can apparently query it just like your code can.

    Personally I think that if an attacker can read your memory, you pretty much lost the Security Battle already. If you got a encrypted value in memory, you propably have the key there too. Together with the code actually working on both. So it is not like an attacker could not decrypt it the same way you would. The task is a bit more complex, but that is it.

    The vulnerability to memory reads is why Heartbleed was such a huge thing. You have to blindly trust the RAM. Because if it is compromised, there is nothing you can do about it.