Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verify path traversal vulnerability in web server

Tags:

I want to verify that my web application does not have a path traversal vulnerability.

I'm trying to use curl for that, like this:

$ curl -v http://www.example.com/directory/../ 

I would like the HTTP request to be explicitly made to the /directory/../ URL, to test that a specific nginx rule involving proxy is not vulnerable to path traversal. I.e., I would like this HTTP request to be sent:

> GET /directory/../ HTTP/1.1 

But curl is rewriting the request as to the / URL, as can be seen in the output:

* Rebuilt URL to: http://www.example.com/ (...) > GET / HTTP/1.1 

Is it possible to use curl for this test, forcing it to pass the exact URL in the request? If not, what would be an appropriate way?

like image 452
Fernando Correia Avatar asked Jul 24 '14 14:07

Fernando Correia


People also ask

What are the possible ways to check for directory traversal vulnerabilities?

The only way to effectively detect directory traversal vulnerabilities is by using a web vulnerability scanner.

How can you protect vs path traversal attacks?

The most effective way to prevent file path traversal vulnerabilities is to avoid passing user-supplied input to filesystem APIs altogether. Many application functions that do this can be rewritten to deliver the same behavior in a safer way.

What is file path traversal attack?

A path traversal vulnerability allows an attacker to access files on your web server to which they should not have access. They do this by tricking either the web server or the web application running on it into returning files that exist outside of the web root folder.

What is directory traversal example?

The simplest example of a directory traversal attack is when an application displays or allows the user to download a file via a URL parameter.


1 Answers

The curl flag you are looking for is curl --path-as-is .

like image 94
J.-B. C. Avatar answered Jan 16 '23 17:01

J.-B. C.