I would answer on basis what's going in my organization. It is not recommended anymore to store the db connection strings in config of appsettings.json file. Our auditors are constantly browsing through the repos to check if someone does that.
As a best practice, we put the connection string in azure keyvault. It takes care of encrypting while storing and decrypting while fetching. If you don't want to use third party solutions, you can still be fine if you take care of a few things -
- Encrypt the password or whole connection string and keep the key only in code (not in config)
- If your database is on same server, then you can totally disable sql server authentication and use only windows authentication. This will make it harder for someone from outside to crack.
- One step further from step 2, try to disable TCP/IP from SSCM and use named pipes only. Then it's not possible for anyone to connect to your db from outside your machine.
There are many more things that can go wrong if you have not properly configured security in your application. If your service account is compromised, even third point can't save your db. I would suggest continue reading on this and treat this as a never ending list.