How to resolve veracode scan sql conection error(cwe 15).
Veracode CWE 15 flaw
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
How to resolve veracode scan sql conection error(cwe 15).
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Oct 4, 2023, 2:16 AM EDT
I guess you are preparing the Connection String using the server name and db name as input, and the scan is considering it as a threat. Try to avoid preparing connection strings with user input and keep it in web config or app config and read it based on the user login, you can create a connection factory class etc for that.
satish maddili44 reputationPosted Oct 31, 2023, 2:49 AM EDT
Hi Sachin,
I am reading connection string from web.config
private readonly string _connectionString = string.Empty;
private readonly int _sqlTimeout = 30;
public AdoUtility(string connectionString, int sqlTimeout)
{
this._connectionString = connectionString;
this._sqlTimeout = sqlTimeout;
}
using (SqlConnection cn = new SqlConnection())
{
cn.ConnectionString = _connectionString;
cn.Open();
cn.Close();
}
using (SqlConnection cn = new SqlConnection())
{
cn.ConnectionString = _connectionString;
above lines gettng error