> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/web/path-traversal/path-traversal-with-start-of-path-validation.md).

# Path Traversal mit Überprüfung des Pfadanfangs

Notizen zu Path Traversal mit Überprüfung des Pfadanfangs für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### Dateipfad-Traversal, Validierung des Pfadanfangs

Die Anwendung überträgt den gesamten Dateipfad über einen Query-Parameter und prüft nur, dass dieser Pfad **beginnt** mit dem erwarteten Ordner übereinstimmt. Diese Validierung ist unzureichend: Durch das Anhängen nach dem zulässigen Präfix ist der Zugriff auf beliebige Dateien möglich.

#### **Analyse**

Der Dateiname-Parameter enthält direkt einen absoluten Pfad, zum Beispiel:

```bash
/var/www/images
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0ecb977074c246375d014d04cfb0b6980b01da53%2Fimage%20(254).png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn man einen klassischen Traversal-Versuch unternimmt:

```bash
../../../../../etc/passwd
```

blockiert die Anwendung ihn.

Aber wenn wir **den erwarteten Pfad**, gefolgt von `../` Sequenzen zum Verlassen angeben, erkennt die Validierung die Umgehung nicht:

Da der Pfad korrekt mit `/var/www/images/`, erfüllt die Prüfung ihre Bedingung, aber die endgültige Auflösung verweist tatsächlich auf `/etc/passwd`.

```bash
/var/www/images/../../../../../etc/passwd
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0d1dc24319c0bcc94915926664e561591ad27409%2Fimage%20(255).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/de/web/path-traversal/path-traversal-with-start-of-path-validation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
