I have a SqLConnection
method that takes a connection string as a parameter. I am using Veracode to check for vulnerabilities in my code, and I got the following CWE 15 error:
This call to system_data_dll.System.Data.SqlClient.SqlConnection.!newinit_0_1() allows external control of system settings. The argument to the function is constructed using untrusted input, which can disrupt service or cause an application to behave in unexpected ways. The first argument to !newinit_0_1() contains tainted data from the variable connectionString. The tainted data originated from an earlier call to saturnrearchdataaccess_dll.SaturnRearchDataAccess.AdoHelper.GetDirectSqlCommand.
I am setting the connectionString in my Web.config
file, and to my understanding it is complaining that it could be changed at some point.
Is there a way to check if the connectionString is tainted or not?
Here is my function:
public static SqlConnection GetSqlConnection(string connectionStringName)
{
var connectionString = ConfigurationManager.ConnectionStrings[environ + connectionStringName].ConnectionString;
var conn = new SqlConnection(connectionString);
return conn;
}