Business logic vulnerabilities
PortSwigger Web Security Academy · Expert
- #Business logic

Bypassing access controls using email address parsing discrepancies
The vulnerability
Only addresses at ginandjuice.shop may register. The check and the mail server read an encoded address differently: the check sees the right domain, while the mail goes to you.
Fix: Reject encoded addresses, and use the same parser for the check and for sending.
The lab
This lab validates email addresses to prevent attackers from registering addresses from unauthorized domains. There is a parser discrepancy in the validation logic and library used to parse email addresses.
To solve the lab, exploit this flaw to register an account and delete carlos.
Required knowledge
To solve this lab, you’ll need to understand the techniques described in the Splitting the Email Atom: Exploiting Parsers to Bypass Access Controls whitepaper by Gareth Heyes of the PortSwigger Research team.
Solution
1. Test Email Registration: Try to register a new account with an email address on a domain other than ginandjuice.shop. The application will correctly block the registration with an "Only emails with the ginandjuice.shop domain are allowed" error.
2. Attempt Q-Encoded Bypass: Based on the article hint, try to register an account with a Q-encoded email address that looks like =?iso-8859-1?q?=61=62=63?=clawhak@ginandjuice.shop. This will be blocked by the security filter.

3. Discover the Vulnerable Encoding: Continue testing different encodings. The UTF-7 encoding, in particular, will bypass the validation filter. A payload like =?utf-7?q?&AGEAYgBj-?=foo@ginandjuice.shop will be accepted by the validation but delivered to the foo address.
4. Create the Final Exploit Payload: Create a UTF-7 encoded email address that uses the Exploit Server’s email client. The payload will be clawhak plus the Exploit Server's ID, followed by a space, and then the required @ginandjuice.shop. The encoded string will look like =?utf-7?q?clawhak&AEA-[EXPLOIT-SERVER_ID]&ACA-?=@ginandjuice.shop. The space after the ID is key, as one parser will interpret it differently than the other.

5. Activate Account and Solve Lab: Go to the “Email client” and you will receive an activation email for the newly created account. Click the activation link and then log in with your credentials. You will now have access to the admin panel. Delete the user carlos to solve the lab.