I have developed a tool and when I am running the fortify then I am getting 6 critical issues related to Db connection string stating "Concatenating unvalidated input into a database connection may allow an attacker to override the value of a request parameter. An attacker may be able to override existing parameter values, inject a new parameter or exploit variables out of a direct reach."
public bool sqlDbValidateUser(string databaseHostname, string databaseName, string databaseUsername, string databasePassword)
{
_logger.Info("starting sql DB validation");
string ConnectionString = "Data Source=" + databaseHostname + "; " +
"Initial Catalog=" + databaseName + ";" +
"User id=" + databaseUsername + ";" +
"Password=" + databasePassword + ";";
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
try
{
connection.Open();
return true;
}
catch(Exception)
{
return false;
}
finally
{
if(connection !=null)
{
connection.Close();
}
}
}
}