> 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/business-logic/authentication-bypass-via-encryption-oracle.md).

# Authentifizierungsumgehung durch Encryption Oracle

Notizen zur Authentifizierungsumgehung durch Encryption Oracle für die Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungsablauf, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### Authentifizierungsumgehung über ein Verschlüsselungs-Orakel

**Beschreibung des Labs**

Dieses Labor weist eine logische Schwachstelle auf, die ein \*\*serverseitiges Verschlüsselungs\*\*orakel offenlegt. Durch Ausnutzen dieser Schwäche ist es möglich, einen gültigen verschlüsselten Wert zu fälschen, um die Authentifizierung zu umgehen, auf das Admin-Panel zuzugreifen und den Benutzer zu löschen **carlos**.

Bereitgestellte Kennung:

* Benutzer: `wiener`
* Passwort: `peter`

**Erste Beobachtung**

Auf der Anmeldeseite ist die **Angemeldet bleiben** Option verfügbar.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-1c8f2b6704708a6182e65cff57da7ca746fc47ca%2F%7B3E36DA00-915F-4E99-A834-06AC0A639BAC%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn sie verwendet wird, wird ein in **Base64 kodieren** verschlüsseltes Cookie generiert und auf der Kundenseite gespeichert.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-06479314aece8e4eae54a0445e0bf7e609922eb5%2F%7B45D84F5E-FC68-4377-AE0C-264F6B775F2D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

```bash
echo '0HE6oMYJL//S1fLwttqR7WMF3EX4KJmvfFRI53qpVnk=' | base64 -d

# Der dekodierte Wert ist binärer Chiffretext, kein lesbarer Text.
```

### Identifizierung des Verschlüsselungs-Orakels

Wenn ein gültiger Kommentar eingereicht wird, wird keine spezifische Antwort beobachtet.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df90ea91b514f51d437eb3dba0cdaabe68d82b75%2F%7BCA4664B4-97B1-454D-BAF5-98D4D7777D0E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn jedoch ein Kommentar einen Anwendungsfehler verursacht (z. B. eine ungültige E-Mail-Adresse), dann:

* wird eine Fehlermeldung zurückgegeben, die auf dem Bildschirm angezeigt wird;

{% code overflow="wrap" %}

```bash
csrf=cFMQUjAyzETtEr8TLsoir7V5p4C3m4ZG&postId=4&comment=test&name=test&email=test&website=https://localhost
```

{% endcode %}

* ein neues Cookie wird generiert `Benachrichtigung`\*\*, verschlüsselt.

Der angezeigte Inhalt lautet beispielsweise:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8773a3dd5c9ca7ffa97fa91971e0f8bc47bbe38c%2F%7B98731CE0-7072-4F6F-820E-A8ABAAFFE738%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Das zeigt Folgendes:

* der Server \*\*entschlüsselt den Inhalt des `Benachrichtigung` Cookies;

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-170f9cd9ea3b411e2911b413fd030255fc7344f8%2F%7BA516BF0D-8173-48BA-9854-D8E725E90EF8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Der Server fungiert daher als ein **Orakel für Verschlüsselung und Entschlüsselung**.

* der entschlüsselte Text ist **erneut in die HTML-Antwort eingefügt**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-16c05cc800cb2d282e9caf9ed7058823d79f5741%2F%7B6FA85698-84B5-498A-B262-9B0CAF4181DA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Korrelation mit dem Cookie

Durch Einschleusen des verschlüsselten Werts des Cookies \*\*

Das beobachtete Format lautet:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-da4fa9c84fc71b8d2faf60d1ca2fb080634116b5%2F%7B2E30F536-1AB8-430A-9F77-F7E116B0D862%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dies entspricht eindeutig:

* einem Benutzernamen;
* einem Zeitstempel.

#### Fälschung einer Administrator-Identität

Ziel ist es, den Server dazu zu bringen, die folgende Zeichenfolge zu verschlüsseln:

```bash
administrator:1766913113564
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3594dd843ec91657d6fd3109c0b8caf088cf6df8%2F%7BB99DE7CF-7BCE-4058-9E02-DF9F6A451DF9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dazu wird dieser Wert in das anfällige Feld (ungültiger Kommentar/ungültige E-Mail) eingeschleust, wodurch:

* die Fehlermeldung angezeigt wird, die diese Zeichenfolge enthält;

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-71b56cb8b65bd1996936e932e33fc8d8de9c0d99%2F%7BF469F5A4-6D70-41BA-9326-889C2BC22AFA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

die Generierung eines neuen `Benachrichtigung` Cookies, einschließlich des eingeschleusten Textes.

{% code overflow="wrap" %}

```bash
Set-Cookie: notification=VQbs3ex4CbvKjTm0LM5wuZa79pnAzKI9MEsa1O0MbX%2fJpfl9baj6yL3ryxh4u6nyiWHVwxP7%2fVDPyft%2f1qAbbQ%3d%3d; HttpOnly
```

{% endcode %}

### Identifizierung des Verschlüsselungsalgorithmus

Durch beliebiges Kürzen des verschlüsselten Werts gibt der Server den folgenden Fehler zurück

```bash
PTBLGtTtDG1/yaX5fW2o%2bsi968sYeLup8olh1cMT%2b/1Qz8n7f9agG20%3d
```

`Die Eingabelänge muss beim Entschlüsseln mit einem gepaddeten Chiffreverfahren ein Vielfaches von 16 sein`

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6edc2449f91bef9d278bd1e005590eaf0fc64ca7%2F%7B86526481-7898-40D5-8113-809AAE3C7710%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dies deutet eindeutig auf die Verwendung von **AES mit Padding**, arbeitet in Blöcken von **16 Byte**.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-921a3d43ea0db8951b4b6ffbee9ae35a884766ff%2F%7BA6A7EDD6-E0F9-4DDC-99CE-CA4AFBE3E432%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Manipulation von Chiffreblöcken

Das aufgetretene Problem ist das Vorhandensein ungültiger Padding-Zeichen am Ende der Nachricht. / Um dies zu beheben, wird der eingefügte String von Füllzeichen vorangestellt, um die Blöcke korrekt auszurichten:

```
xxxxxxxxxadministrator:1766913113564
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-db48f1a39a887b49244698967f194e57043ef5d4%2F%7B3FB22BF1-1A82-41BE-966D-0E22EFD0D949%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Anschließend wird ein neues verschlüsseltes Cookie generiert.

VQbs3ex4CbvKjTm0LM5wuZJqwlVboMZ2IzNuiTfVH6iHj9RZUT59d5kGoS64tVE5wWiEfmp6VbJG%2bb%2fNW5%2bblA%3d%3d

### Zerschneiden und Neu zusammensetzen des Cookies

Durch Löschen der ersten **zwei verschlüsselten Blöcke** (entsprechend den Füllzeichen) bleiben nur die Blöcke übrig, die Folgendes enthalten:

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-53b11c36be65a667931372eed1d9916d85e8d95c%2F%7BB155871E-4388-4A10-BEB4-7B2665F6EF57%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-a85d9e6c8504608250675b0e1e0a6c2633a84516%2F%7BC52B4886-B120-45A9-B85C-755072EB80DD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Dieser endgültige verschlüsselte Wert wird vom Server akzeptiert.

```
h4/UWVE%2bfXeZBqEuuLVROcFohH5qelWyRvm/zVufm5Q%3d
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0b23a0e83ce8947384e9e367f5fe9fe3b619ac7e%2F%7B9B975810-3156-49D5-BBE6-87F32FCBF48B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Authentifizierung umgehen

Abschließende Schritte:

1. Löschen Sie das vorhandene Session-Cookie.
2. Ersetzen Sie den Wert des Cookies \*\*
3. Laden Sie die Seite neu.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cb818e32f157dec337db5f2539aeb3f9668ba4d7%2F%7BF7D93958-A273-4244-8FE3-5A0243528964%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/business-logic/authentication-bypass-via-encryption-oracle.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.
