> 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/race-conditions/exploitation-of-time-sensitive-vulnerabilities.md).

# Ausnutzung zeitkritischer Schwachstellen

Notizen zur Ausnutzung zeitkritischer Schwachstellen für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Kontext zur Behebung.

### Ausnutzung zeitkritischer Schwachstellen

### Laborkontext

Die Website bietet eine Funktion zum **Passwort zurücksetzen** über einen per E-Mail gesendeten Link. / Auf der logischen Seite der Anwendung gibt es keine echte Race Condition, aber die Erzeugung von **Token** ist **basiert**: sie hängt von einem **vorhersehbaren Wert** (Zeit), wodurch es möglich ist, durch das Senden von Anfragen \*\*zur gleichen Zeit\*\* einen gültigen Token für einen anderen Benutzer zu fälschen.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c58a84bf71f02dd10b85375f3d415c416bce37ea%2F%7BDF7E5660-9207-4CDB-B974-C67123A4191D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Erste Beobachtungen

1. Wir verwenden **Passwort vergessen** mit Benutzer `wiener`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-626227ff5ce7b6028baaf462af347a06ca8fd1cf%2F%7BB837963E-072E-48E3-B684-700364BE996A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Eine E-Mail mit einem Link vom Typ:
* `/forgot-password?user=wiener&token=<token>`

{% code overflow="wrap" %}

```bash
Hallo!

Bitte folgen Sie dem untenstehenden Link, um Ihr Passwort zurückzusetzen.

https://0a1300c9040343bf810b7f2a00e60085.web-security-academy.net/forgot-password?user=wiener&token=3930dc6d3d076151204ad4147326f81a5e1609a8
```

{% endcode %}

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a26e0e7d9ed5174051929e952e4701fbf0c31666%2F%7B113509E4-671D-401B-8EA0-F6AE9725AB1E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Der Token sieht aus wie ein **SHA1** (40 hexadezimale Zeichen).

`forgot-password?user=wiener&token=3930dc6d3d076151204ad4147326f81a5e1609a8`

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-930b5c1465387f7d158ca316aa89aa6512b44d48%2F%7BB66B464D-4E68-4DAB-BEEC-0A8D7F05E9A5%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Der Token sieht aus wie ein **SHA1** (40 hexadezimale Zeichen).

```bash
hashid '3930dc6d3d076151204ad4147326f81a5e1609a8'
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b340c74876dd768b3c7c3d51ff402645274e0abb%2F%7B4BC8DA5A-DA34-4C1C-9B18-9B2014CD516F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

1. Durch das Generieren mehrerer Token

Annahme: Der Token wird hauptsächlich aus einem **Zeitstempel** (oder einem zeitbasierten Wert) und nicht aus einem robusten Geheimnis.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c3e7d33579f6ed4584f7ebc7de1cde1e72139d4%2F%7B178FE46D-40F0-4953-A695-CB87823E2810%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Kernidee: Zwei Anfragen in derselben Millisekunde erzwingen

Wenn wir auslösen können **zwei Zurücksetzungen** zur gleichen Zeit, und der Token nur vom Zeitpunkt abhängt, dann **werden die beiden Token identisch sein**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bec565b7f22d7983fb35e5825b4630f0ab626d2a%2F%7B12B696E9-90B1-4254-9667-9BE6B0B5A8A1%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Problem: Der Server (PHP) vermeidet manchmal Kollisionen mit derselben Sitzung / demselben CSRF. / Lösung: besorge **zwei separate Sitzungen**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2ee71deeee62f0504694e71a121ce2e6c5d653b1%2F%7BFEB5680C-2F57-42E6-B7C8-FF2B83D48C79%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Vorbereitung: Zwei Sitzungs- + CSRF-Paare beschaffen

Es werden zwei separate Anfragen an Folgendes gestellt:

* `GET /forgot-password`

```http
GET /forgot-password HTTP/2
Host: 0a1300c9040343bf810b7f2a00e60085.web-security-academy.net
Cookie:
```

Jede Antwort ergibt ein neues Paar:

* `PHPSESSID=<...>`
* ein neuer CSRF-Token (Wert im Formular verborgen)

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b60d532445a46566acaa6178aab35384c8538fa7%2F%7B98B7B0DE-2B48-4BED-8144-C012C86D110E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Es gibt **zwei vorbereitete Anfragen**, jeweils mit:

* seinem `PHPSESSID` Cookie
* dem zugehörigen CSRF-Feld

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f3e9ec62d0b0ff2b38e6b310296c91946facabb9%2F%7BE079B013-0BBB-45D5-82A6-61EA24021EB4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Auslösung: Parallel senden

Dann senden wir **parallel** zwei POST-Anfragen zum Zurücksetzen (derselbe Endpunkt) in Burp (gruppieren + parallel senden), damit sie ankommen **im gleichen Zeitfenster**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1639be135577b23a01cc8c769db888ffb9427bd9%2F%7B73C6239F-A361-47DD-9C21-B14A292C373F%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Beobachtetes Ergebnis: Die beiden empfangenen E-Mails enthalten \*\*genau denselben Token\*\*:

```bash
933ccbd314dc37df95887cd914b07e330517f7bb
933ccbd314dc37df95887cd914b07e330517f7bb
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6e01ba6eb1ee900953b12829b07e9dce10948360%2F%7BB899DE0C-EB53-4923-BF3D-9D085BD0D5C9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Fazit: Der Token hängt im Wesentlichen von **Zeitstempel**, nicht von einem einzelnen Geheimnis pro Benutzer ab.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a02641ffd57f018d7f18479178fe15dcb54edee5%2F%7B792B8500-D851-4581-94E5-A377EB809957%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Vorgehen: Carlos mit Wieners Token zurücksetzen

Ziel: Token gültig für `carlos`.

Methode:

1. Starten Sie parallel zwei Zurücksetzungen:

* eine für `wiener`
* eine für `carlos`

```bash
forgot-password?user=wiener&token=da1d6e3ed67bef3efa9fe74fcfbf7603120ea744
forgot-password?user=carlos&token=da1d6e3ed67bef3efa9fe74fcfbf7603120ea744
```

Da die Token identisch sind, ist der empfangene Token (z. B. per `wiener` E-Mail) auch gültig für `carlos`.

Wenn die Website diese URL akzeptiert, können Sie **ein neues Passwort festlegen** für `carlos`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f516708a8f594fc919108cb151310a273c478af2%2F%7BDCB16AF0-DCAB-499F-A6BF-EF1784E72D57%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Abschluss des Labs

1. Melden Sie sich an als `carlos` mit dem neuen Passwort.
2. Öffnen Sie die \*\*Admin-Anmeldung\*\*.
3. Entfernen Sie den `carlos` Benutzer, um das Lab zu validieren.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3b7b12ddd7f01c59ee5b83b2f2b93214ec5bbd08%2F%7B686872ED-506C-438E-94DB-7ED0530354C1%7D.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/race-conditions/exploitation-of-time-sensitive-vulnerabilities.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.
