
JCamargo104365 (Community Member) asked a question.
Hello,
We are getting a CWE 15 flaw in a static scan. I have read through most posts on this and the basic gist is that if the connection string properties are read from user controlled variables then a attacker can gain access by controlling the variables he has access to.
Having said that, in our case the connection string is controlled by user authentication to our system. When a user authenticates to our system, we know what database to connect them to based on their credentials. User access to these variables don't exist.
Is this a proper candidate for mitigation by OS Environment or Network Environment? The database in this case is considered a safe area because only authenticated users to our network have access to these table values.
.png)
Hi @JCamargo104365 (Community Member),
Yes, we report CWE 15 whenever we can see that parts of a connection string come from outside the application, such as your database. There are two main concerns here:
It's not necessarily a good idea to consider the database as generally safe as, often, values in the database are directly derived from user input.
I would recommend going through the steps provided by @Boy, Security Consultant (Veracode) (https://community.veracode.com/s/question/0D52T00004ovKsP/external-control-of-system-or-configuration-setting-cwe-id-15), in your case starting with step 2.
Afterwards, the remaining risk might be acceptable for your organization's Security Team and all controls in place can be documented in a mitigation proposal (I would recommend Mitigation By Design). You can find more information on how to propose a mitigation here: https://docs.veracode.com/r/improve_mitigation
Thank you,
Florian Walter
Thanks Florian for your reply. I have a few followup questions.
From our point of view, this would not be a false-positive but can potentially be mitigated by design. I would recommend doing the following:
Afterwards, all existing controls should be documented in a mitigation proposal which then needs to be reviewed by your Security Team.
Regarding your 2nd point: Could you please elaborate on what you mean by "integrated"?
Thank you,
Florian Walter
So given how we have these connection strings built, all we have to do is use the connection string builder and mark it mitigated by Design?
Hi @JCamargo104365 (Community Member),
I appreciate that the dynamic data comes from the database and is not directly controllable by an attacker. However, we would still recommend applying some validation. Ideally, your application should run securely in a potentially hostile environment and not rely on the database being considered trusted.
Using the `SqlConnectionStringBuilder` will help prevent adding additional arguments by an attacker but won't be able to prevent changing the server name e.g. to "my-evil-database-host.com".
We recommend validating the database configuration against an allow-list of servers you trust, as well as making sure the database is one of the databases you want to access here. Using an allow-list is also something that Veracode Static Analysis is automatically able to detect and close the flaw if applied like this: https://community.veracode.com/s/article/Using-an-Allow-list-in-a-Way-Static-Analysis-can-Detect
Thanks,
Florian Walter