Наш клиент использует инструмент сканирования Veracode для сканирования приложения ASP.NET. Мы устранили множество недостатков, за исключением приведенных ниже.
Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')
(CWE ID 113)(1 flaw) in the line
HttpContext.Current.Response.AddHeader("Content-Disposition", contentDisposition);
Это соответствующий код:
public static void DownloadFile(string fileName, byte[] dByteData, bool isNoOpen = false)
{
byte[] fileContents = new byte[] { };
string contentDisposition = string.Empty;
fileContents = dByteData;
if (string.IsNullOrWhiteSpace(fileName))
{
return;
}
fileName = fileName.Replace("\n", "").Replace("\r", "");
string contentType = "application/*.".Replace("\n", "").Replace("\r", "");
contentDisposition = "attachment; filename=\"" + HttpContext.Current.Server.UrlPathEncode(fileName) + "\"";//While Downloading file - file name comes with junk characters
contentDisposition= contentDisposition.Replace("\n", "").Replace("\r", "");
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = contentType;
if (isNoOpen)
{
HttpContext.Current.Response.AddHeader("X-Download-Options", "noopen");
}
HttpContext.Current.Response.AddHeader("Content-Disposition", contentDisposition);
HttpContext.Current.Response.AddHeader("Content-Length", fileContents.Length.ToString());
HttpContext.Current.Response.BinaryWrite(fileContents.ToArray());
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
Внешний контроль имени файла или пути (CWE ID 73)
if (File.Exists(filePath))
{
File.Delete(filePath);
}
Выдает ошибку в строке File.Delete
. Мы пытались очистить путь к файлу, а также использовали Path.GetFullpath
, но только напрасно.