The method RetrieveTableDisplay()
invokes a SQL query built using input coming from an untrusted source. This call could allow an attacker to modify the statement's meaning or to execute arbitrary SQL commands.
string sql =
SqlHelper.GetSqlString(Constants.RetrieveTableDisplay) + tableName +
" WHERE ACCOUNT_NBR='" + AccountNumber +
"' ORDER BY " + GenerateOrderByClause(tableName) + " ) a ) where rn > " +
(currentPageNumber * currentPageSize).ToString() + " AND rn <= " +
((currentPageNumber * currentPageSize) + currentPageSize).ToString();
string recordCount =
"select count(*) from " + tableName +
" WHERE ACCOUNT_NBR='" + AccountNumber + "'";
//Issue is somewhere here of sql injection
if (!Utils.IsUnitTestCase)
{
try
{
using (DbCommand cmd =
OraDB.GetSqlStringCommand(this.ProcessTableName(sql)))
{
using (IDataReader reader = OraDB.ExecuteReader(cmd))
{
object o = OraDB.ExecuteScalar(CommandType.Text, recordCount);
if (o != null)
{
lstEntities.TotalRecords = Convert.ToInt32(o);
}
while (reader.Read())
{
objBasTransactionLog = new BASTransactionLog();
PopulateEntity(objBasTransactionLog, reader);
lstEntities.Add(objBasTransactionLog);
}
}
}
}
}
Custom Recommendations:
The remedy is to never use string concatenation to build SQL statements. Prepared statements, also called placeholders, should be used to build SQL statements.