2017-08-08 2 views
1

Jedermann haben Idee, wie dieser Veracode Problem zu beheben (CWE 113)Unsachgemäße Neutralization von CRLF Sequenzen in HTTP-Header (CWE ID 113)

ich bereits unter Link versucht, aber seine Arbeit nicht.

Fix for CWE-113: Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')

Unten ist die Funktion, wo ich Problem.

protected void Page_Load(object sender, EventArgs e) 
     { 
      _presenter = new VwCSVPresenter(this); 
      this._presenter.OnViewLoaded(); 

      Response.ContentType = CONTENT_TYPE; 
      Response.Clear(); 
      if (!string.IsNullOrEmpty(this.FileName)) 
      { 
       // name the local file the user will download 
       var localFileName = Request.QueryString[QS_MODULE]; 
       //test1: var localFileName = Regex.Replace(Request.QueryString[QS_MODULE], @"\n|\r|%0d|%0D|%0a|%0A", string.Empty); 
       //test2: tried the same with string Replace eg: 
       //var localFileName = Request.QueryString[QS_MODULE].Replace("\r", string.Empty) 
           //.Replace("%0d", string.Empty) 
           //.Replace("%0D", string.Empty) 
           //.Replace("\n", string.Empty) 
           //.Replace("%0a", string.Empty) 
           //.Replace("%0A", string.Empty); 

       if (!string.IsNullOrEmpty(localFileName)) 
        localFileName += CSV_EXTENSION; 

       Response.AppendHeader(HTTP_HEADER_CONTENT_NAME, string.Format(HTTP_HEADER_CONTENT_VALUE, localFileName)); 
       Response.TransmitFile(this.FileName); 
      } 
      Response.End(); 
     } 

Antwort

0

Ich habe mein Problem behoben von Server.UrlEncode() hinzufügen für die localFieName und Varacode die Fehler gelöscht.

Response.AppendHeader(HTTP_HEADER_CONTENT_NAME, string.Format(HTTP_HEADER_CONTENT_VALUE, Server.UrlEncode(localFileName))); 
Verwandte Themen