The lab
here is how portswigger describes it
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.
admin access is gated on a @ginandjuice.shop email, and the server validates the address before letting us register. the catch is that the validator and the mail-sending library disagree about how to decode the same string. the validator reads the address one way and sees a legitimate @ginandjuice.shop domain, while the mail library decodes an embedded encoded-word and actually sends the confirmation to our address. we smuggle our exploit-server address inside a UTF-7 encoded-word so the two parsers read two different recipients from one email.
why the parser discrepancy breaks this#
the bug is that two components parse the same email string with different rules. the validation logic checks that the address ends in @ginandjuice.shop and treats the rest as opaque, but the library that actually delivers the mail understands RFC 2047 "encoded-word" syntax and decodes it before routing. if we hide the real recipient, our attacker@exploit-server plus an @ and a trailing ?=, inside an encoded-word, the validator still sees the harmless @ginandjuice.shop suffix and passes it, while the mail library decodes the encoded-word and sends the confirmation link to us. the server recognises the common encodings (plain, Q-encoding) as suspicious, but not UTF-7, so UTF-7 is the gap that slips past validation while still being decoded on send.
Step 1 - identify the domain restriction#
we go to Register and try to register with [email protected]. the application blocks it, saying the email domain must be ginandjuice.shop. so registration enforces a domain check.

Step 2 - probe encoded-word (Q-encoding)#
we try to register with [email protected]. that is [email protected] with the abc Q-encoded, part of the "encoded-word" standard. it is blocked with the same error, so the server detects and rejects common encoded-word manipulation. less common encodings may slip through.

Step 3 - find the UTF-7 gap#
we try a UTF-7 encoded address, =?utf-7?q?&[email protected], and it does not trigger an error. the server does not recognise UTF-7 as a threat, so UTF-7 can carry a payload past validation while still being decoded by the mail library.

Step 4 - smuggle the exploit-server address#
we register with:
=?utf-7?q?attacker&AEA-[YOUR-EXPLOIT-SERVER_ID]&[email protected]
this decodes to attacker@[YOUR-EXPLOIT-SERVER-ID] [email protected], with the @ symbol and the space encoded in UTF-7. the trailing @ginandjuice.shop keeps validation happy.

Step 5 - receive the confirmation at our server#
we open the Email client and see a registration validation email waiting. the encoded address passed validation thanks to the @ginandjuice.shop suffix, but the mail server decoded the encoded-word and delivered to attacker@[YOUR-EXPLOIT-SERVER-ID]. we click the confirmation link to activate the account.

Step 6 - reach the admin panel#
with the account active and treated as a ginandjuice.shop user, we click Admin panel and reach the list of users.

Step 7 - delete carlos#
we delete the user carlos.

with this, the lab is solved!
