Assigning a SecureString value to SQLConnection.ConnectionString will bypass the security, making it useless.
A SecureString is meant to fix these normal string issues, ref:
- not pinned, garbage collector can move it around, leaving copies in memory
- not encrypted
- If your process gets swapped out to disk, the string will be sitting in your swap file
- not mutable, modifying it will keep the old version and the new version both in memory
- no way to clear it out when you're done using it
IMHO the SecureString type is a patch for a shoddy security implementation, and currently SecureString hasn't been implemented all across the framework, so it's benefits can't be used fully.
I have the same problem, I'm opting for RSA encryption storing sensitive info in memory.
Another solution is hosting your data access layer via a service on the database server, and the service runs under the local system account, that connects to the database and serves the data, while the local user wont have access to the service config.