Click here to Skip to main content
15,886,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<%   
    Response.Clear()
    Response.ContentType = "application/force-download"    
    Response.AppendHeader("Content-Disposition", "attachment; filename=""" & Server.UrlEncode(Request.QueryString("filename"))& """")                      
    Response.Buffer = True
    Response.Flush()
    Response.WriteFile(Request.QueryString("path"))
    Response.End()
%>


What I have tried:

I have tried to do a Server.URLencode
Posted
Updated 9-Apr-18 4:00am
v2

1 solution

Simple. Don't EVER directly use user input in your response.

You're using Request.QueryString("filename") and Request.QueryString("path") directly in the response without ever processing the filename and path strings to make sure they

1) Have values at all (not null or empty)
2) Does not have invalid characters in what is expected to be a filename or path, like CR and LF.

This is trivial stuff. ALWAYS, ALWAYS, ALWAYS validate user input before you try to use it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900