I would not say that storing a plaintext password in Web.config is a security vulnerability in itself. But password encryption is a useful defense in depth, and not just security through obscurity:
- What if IIS is not configured correctly to serve Web.config?
- What if a security vulnerability is discovered in ASP.NET (for example, missing an oracle vulnerability ) that allows anyone to download Web.config?
- There is varying degrees of access to the web server, from full administrative privileges to entering server-side code. If an attacker manages to do this, he will be able to read Web.config, but will not be able to access the machine keys, especially if your application runs under private trust.
In the end, it's up to you whether the risk of storing plaintext passwords in Web.config is acceptable. Of course, if Windows authentication is an option, then you might want to use this instead of SQL authentication.
UPDATE:. Speaking of security, it is helpful to identify assets and threats. In this case, the asset is confidential data in the database (if the data is not significant, then why worry about protecting it with a password?), And the threat is the possibility that the attacker will somehow gain access to Web.config and, therefore, to the database data also. A possible mitigation is encrypting the database password in Web.config.
How dangerous is this? Are we really planning such an astronomical phenomenon?
This mitigation has already proven its worth once: when the ASP.NET Oracle vulnerability was discovered. Anyone who stored the plaintext password in Web.config was at risk; anyone who encrypted the password was not. How confident are you that another similar vulnerability in ASP.NET will not be discovered in the next few years?
Should we also encrypt the source code and decrypt it at runtime? It seems excessive to me.
So what if an attacker gains access to your source code? What asset are you protecting and what threat are you bothering? I think in many cases the source code is much less valuable than the data. (Iโm thinking here about ready-made commercial and open source software that anyone can get.) And if your source code is valuable, maybe obfuscation is something to think about.
I feel that they already have limited access to your mailbox, then your host failed or you already installed vulnerable services.
What about ASP.NET security vulnerabilities or your code? From time to time they appear.
I am worried about standard practice. Is this the standard?
Microsoft recommended encryption of connection strings.
What you need to do is evaluate the risk that saving the plaintext password is: