![]() |
1
2
The vast majority of Web Applications use a hard-coded username/password for their SQL connection. Checking production credentials into source control, or giving interns the ability to delete the production database is generally frowned upon. Production credentials should be protected, and only privileged employees should have access to them.
It is common for web applications to leak their configuration files. For example if a .xml file is stored in the webroot then it can be accessed remotely:
It is common practice to disallow access to your database (block tcp port 3306 for mysql). In fact this is a requirement of the PCI-DSS. Even if the username and password where to be obtained, it would be useless. |
![]() |
2
3
Read the password from a properties file or LDAP or similar and secure access to those to only the account used to run the software (which none of the developers should have access to). |
![]() |
3
3
Use simple files to store the database properties and read them in the code instead of hardcoding. Not only is this clean but you can also restrict file access. 这个 link 也许会帮助你。 |
![]() |
4
2
This code creates a database connect using a hardcoded, constant password. . That security issue arise because, you've used the DB name, username and password. But surely you can't resolve the issue " Anyone with access to either the source code or the compiled code can easily learn the password “。I bet U can resolve the first issue. You can use Properties to include your DB uesrname and password with which you could encode into the Properties object using 设置属性() 方法。 Now you can include the property object into the GET连接() 方法:
|
![]() |
5
0
You can store the password in a config file and then encrypt the file/sections of the file using DPAPI if you are using Windows box. This way, you won't have to worry about key management too. |