File tree Expand file tree Collapse file tree 3 files changed +3
-3
lines changed
csharp/ql/src/Security Features/CWE-022/examples Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class TaintedPathHandler : IHttpHandler
6
6
{
7
7
public void ProcessRequest ( HttpContext ctx )
8
8
{
9
- String filename = ctx . Request . QueryString [ "path" ] ;
9
+ string filename = ctx . Request . QueryString [ "path" ] ;
10
10
// BAD: This could read any file on the filesystem.
11
11
ctx . Response . Write ( File . ReadAllText ( filename ) ) ;
12
12
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class TaintedPathHandler : IHttpHandler
6
6
{
7
7
public void ProcessRequest ( HttpContext ctx )
8
8
{
9
- String filename = ctx . Request . QueryString [ "path" ] ;
9
+ string filename = ctx . Request . QueryString [ "path" ] ;
10
10
11
11
string publicFolder = Path . GetFullPath ( "/home/" + user + "/public" ) ;
12
12
string filePath = Path . GetFullPath ( Path . Combine ( publicFolder , filename ) ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class TaintedPathHandler : IHttpHandler
6
6
{
7
7
public void ProcessRequest ( HttpContext ctx )
8
8
{
9
- String filename = ctx . Request . QueryString [ "path" ] ;
9
+ string filename = ctx . Request . QueryString [ "path" ] ;
10
10
// GOOD: ensure that the filename has no path separators or parent directory references
11
11
if ( filename . Contains ( ".." ) || filename . Contains ( "/" ) || filename . Contains ( "\\ " ) )
12
12
{
You can’t perform that action at this time.
0 commit comments