vS116732 (Community Member) asked a question.

Server-Side Request Forgery (SSRF) (CWE ID 918)

Veracode Static Analysis report flaw with CWE 918 when it detect data from outside of the application. Here is my code spinet

 

protected virtual void RetrieveFile(string filePath) {

string downloadURL = ConfigurationManager.AppSettings["FileDownloadURL"];

HttpWebResponse response = null;

System.IO.Stream dataStream = null;

 

try {

System.Net.WebRequest request = System.Net.WebRequest.Create(downloadURL + "?FilePath=" + Server.UrlEncode(filePath));

response = (HttpWebResponse)request.GetResponse();

 

dataStream = response.GetResponseStream();

Response.ClearHeaders();

Response.ClearContent();

 

 

Response.Flush();

Response.End();

}

catch (System.Threading.ThreadAbortException ex) { }

catch (Exception ex) {

      WSApplication.Application.Report(CommonMessages.ErrorWhileDownload, ex.ToString(), "RetrieveFile");

throw ex;

}

finally {

if (dataStream != null)

dataStream.Close();

if (response != null)

response.Close();

}

 


Topics (3)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.