Sensitive Dependency property values are exposed by snoop tool in WPF application, How to prevent that?

160 Views Asked by At

I am using one user control which has it's password property. To set that password property i am using DependencyProperty created in viewmodel. When I am running application and trying to debug using Snoop tool(SnoopWpf), and when i look into user control properties it shows the password set for that control. I want to prevent snoop tool to show password property value. Is there any way we can add security to perticular dependency property?

XAML Code:

<class:MyControl x:Name="myControl" IsReadOnly="True" 
CtlPassword="{Binding myPassword, Mode=OneWay}" 
</class:MyControl> 


private static DependencyProperty PasswordProperty = DependencyProperty.Register("myPassword", typeof(String), typeof(myControl), new PropertyMetadata(null));

public String myPassword
{
     get { return (String)GetValue(PasswordProperty); }
     set { SetValue(PasswordProperty, value); }
}

I looked into this link for one of the solution - Snoop proof solution Can we add any security to this myPassword property? Which will hide this property from any debugging tool

1

There are 1 best solutions below

0
On

Don't store passwords in string properties. This is a big no-no if you care about security. At least use a SecureString - or don't store them at all.

There is an example of how to use a behaviour to bind the to a SecurePassword property available here:

Bind SecurePassword to ViewModel