start	end	text
0	6200	Welcome to splitting the email atom, exploiting parsers to bypass access controls.
6560	13280	Email addresses might seem mundane, but the RFCs governing them are downright bonkers.
13280	18740	I'll show you why predicting an email destination is highly complex,
18740	25300	and I'll take you on a journey of ancient protocols, exotic encodings, access control bypasses,
25300	31360	and how I gained remote code execution from an RFC compliant email address.
33680	38280	First, I'll explain why email address parser discrepancies matter.
38800	43000	Next, I'll cover the shaky foundations that emails are built on.
43300	49340	The core of the talk will focus on parser discrepancies, including Unicode overflows,
49340	54440	encoded word, and Unicode, all with real-world case studies.
54620	59540	Then I'll share my methodology and tools for automating exploitation,
59900	64520	followed by advice on defense. I'll conclude with the key takeaways,
64520	68920	leaving five minutes for questions. There's also a bonus material for DEF CON too.
70740	77040	So this research all started when we realized many websites use the domain part of the email address
77040	84360	to infer the user's organization and apply access control. For example, Slack will automatically
84360	90180	give you access to your company's Slack channel based upon your work email address.
90200	97680	And Cloudflare Zero Trust can be configured to use the email domain to protect your internal network.
97780	104620	This makes email verification a critical security boundary. What could possibly go wrong?
107040	113620	Everyone knows that URL parser discrepancies are critical as they can lead to SSRF path
113620	120380	traversal and other security issues. Using an email domain for access control
120380	124660	makes email address parser discrepancies critical too.
125060	129240	Predicting which domain an email should be routed to should be simple,
129240	135120	but it's actually ludicrously difficult even for valid RFC compliant addresses.
137160	141660	So we've established why email address parser discrepancies matter.
141660	146120	Now let's explore why predicting the email destination is so challenging.
146560	152820	Email addresses are built on a shaky foundation of RFCs designed many years ago.
152840	158860	Validation is often performed using regular expressions, copy and pasted from Stack Overflow,
158860	167020	all trying to follow the RFC. However, one mistake in the RegEx and everything can come crashing down.
169220	174720	I'm not going to bore you with RFCs, but I will highlight the important ones for this talk.
174720	180620	For instance, the characters before the at symbol in an email address are called the local part.
180760	188120	The RFC allows what is called the quoted local part. This enables you to use characters in the
188120	194940	local part that are not normally allowed by using quotes. In the example shown, I use a quoted local
194940	202280	part to use the at symbol as part of the address. The same RFC allows you to use a quoted per,
202280	208040	which means one character preceded by a backslash. This enables you to use a double
208040	214660	quote and a backslash as part of the address provided it is escaped. Characters enclosed
214660	220380	in parentheses are treated as comments and can be placed anywhere within the address except the
220380	226100	local part. They are all ignored when the actual email is delivered.
228280	235700	So here are two email addresses. You might be wondering which one is valid, as this is a
235700	244640	typical question asked in an email presentation. However, it's the wrong question for this talk.
244640	248700	The question you should be asking is which domain do they go to?
248700	255820	You might expect both emails to go to example.com, but that's not what happens. They both go to
255820	263080	psres.net. Remember how I said predicting the email destination is extremely difficult?
263080	269500	This is just the tip of the iceberg. The first example works on Postfix and the second example
269500	276700	works on Sendmail. If you are confused, you should be. Next, let's explain why this happens.
278800	284800	A source route is a sequence of servers which an email is sent before reaching its final
284800	290920	destination. Servers in the chain are separated by commas, with the final destination marked
290920	298940	with a colon before the recipient's full address. Another form of source routing is called the
298940	304980	percent hack. Despite its name, the actual character is determined by the mailer. In this
304980	311520	process, the email is initially sent to example.com, after which the percent symbol is converted into
311520	318720	an at symbol, and the email is sent to foo at psres.net. This process can be repeated several
318720	329150	times. Before email addresses existed, and even the internet, people exchanged messages using UUCP.
329870	335790	UUCP stands for Unix to Unix Copy Protocol. It's an early protocol that separates the
335790	342790	local user and multiple hosts using an exclamation mark, creating what is known as the bang path.
342790	348930	Unlike the standard format for internet email addresses today, the bang path lists the hosts
348930	355350	from left to right, with the destination user mailbox on the right, as you can see in the example.
356930	362090	So going back to the original examples with all the special characters removed,
362090	366330	what the parentheses actually do is remove the at symbol and domain,
366330	370770	and without the domain part, Postfix treats that as a percent source root.
371070	376590	Using a backslash and escape in the at symbol has the same effect on sendmail, which treats the
376590	382830	email as a UUCP address. Pretty damn crazy, right? And I've tested it, and all those special characters
382830	390130	do go to the mailbox. I wish I could tell you that I uncovered this behaviour by analysing
390130	394710	thousands of lines of code and using a debugger and stepping through the code flow in sendmail
394710	401950	and Postfix, but that's not actually how it went down. I noticed an unnamed target was allowing
401950	407090	all sorts of special characters, so I just took all the characters, pasted it into my email and
407090	412890	expected it to fail. But actually, what happened was, I checked the syslog on the box that I was
412890	419310	testing, and I noticed a difference. I was getting host unknown error in the delivery
419310	425550	status notification. This was significant because it would suggest a different host was being used.
426230	430070	If you look at the error, you'll notice the exclamation mark is missing.
430070	434750	I didn't actually notice that at the time. So I started to remove characters,
434750	439930	resend the email, and I still got the same error message. I narrowed it down to the exclamation
439930	447670	mark and thus discovered this UUCP behavior. This was bonkers. By sheer luck, the characters I
447670	453270	pasted into my email address ended with a backslash. I think I did this subconsciously.
453270	459850	And then, when the exclamation mark was then, sorry, and then escape the out symbol,
459850	464310	and then the exclamation mark was treating the address as a UUCP address.
464410	469910	I then wrote a fuzzer to find the other behavior with source routes with Postfix.
470530	474530	These findings gave me great confidence that there were a ton of bugs out there,
474530	481310	so I began to look for more. And this is a bonus slide for DEF CON.
481570	489210	In the RSC, there are optional SMTP parameters. I analyzed the Postfix code with a Poetswinger
489210	495050	colleague, and I discovered that these parameters could be used to remove the domain part of the
495050	500730	email address. I found this parsing bug on a real target, but the application in question
500730	507510	didn't use the email domain for access control. This attack works by escaping the backslash to
507510	513010	break out of the quoted local part, confusing the email validation. Then, you can use the
513010	517770	greater than to end the receipt to command, and then you stick all the rest of the address
517770	526530	within this SMTP optional parameter. And you will notice that this works on a real target
526530	537470	and is a valid SMTP conversation. So when it does the receipt to command, it's a valid syntax for
537470	546410	that. As a further bonus, here is some surprising email parsing behavior that I uncovered works on
546410	552310	Postfix. I couldn't use these for access control bypasses, but nevertheless, they are interesting
552310	560350	and challenges your assumptions of how email addresses are parsed. This first one uses a UUCP
561030	565350	address and is sent regardless of the quotes. It's pretty damn crazy.
566990	573570	This second one uses source roots. So if you use a square bracket syntax, Postfix will still treat
573570	582840	it as a source root and send to that email. So one of the main problems I had to solve with this
582840	589140	research was generating blocked characters. Since many web applications will block multiple art
589140	596300	symbols, so this following section focuses on Unicode overflows, which enable the creation of
596300	602200	ASCII characters from higher Unicode characters. It's pretty much normalization, but I'm calling
602200	611340	Unicode overflows because it's a different technique. So the PHP char function is a good
611340	618200	example of how Unicode overflows can occur. The function generates a character from an integer
618200	624420	code point. Here's an illustration of how the algorithm is used by this function. It loops while
624420	630580	the code point is less than zero, continually adding 256 until it's non-negative, because why
630580	637480	not? It's PHP after all. Then it uses the mod operation to ensure the byte value is always
637480	645040	within a range of zero to 255. So if you introduce a Unicode character is larger than 255, it'd be
645040	653960	truncated into this range. Note that Unicode overflows are just specific to PHP. So generating
654380	660060	a Unicode overflow in JavaScript is quite simple. Using the from code point method,
660060	667830	first you pass the number that will cause the overflow, such as 0x100, which is 256 in decimal.
668360	673420	Next, you provide the second hex number to specify the actual character that you want,
673420	680840	like 0x40, which is the art symbol. The from code point method will generate a Unicode character,
680840	685860	and when this character is transformed to fit within 255, a system that doesn't support
685860	691260	higher Unicode characters will produce the ASCII character specified by the second number.
692960	699040	So I hunted for real-world Unicode overflows, and I found a target that altered characters
699040	705400	within the mailer's SMTP conversation. This application blocks the backslash within the
705400	711680	quoted local part, but I bypassed the validation using Unicode overflows that enabled me to escape
711680	718760	characters and break out of the quoted local part. Despite this, when using an encoded art symbol,
719160	724940	the email wasn't sent, suggesting there is a double validation going on, once in the application
724940	730840	and once before sending. So although I didn't manage to exploit this particular target,
730840	736080	the key takeaway is, you can use a Unicode overflow to bypass validation
736080	740500	and actually smuggle characters within the SMTP conversation.
743150	748630	So Unicode overflows were great, but I needed more methods to generate blocked characters.
748630	753810	So I took a deep dive into the glorious RFC looking for gold, and I found it.
753930	760230	This next section is about encoded word. I discovered this when trying to find ways of
760230	769150	encoding the art symbol without Unicode overflows. Encoded word is specified in RFC 2047,
769150	774030	and it allows the inclusion of Unicode characters using encoded data.
776290	783270	And here is how encoded word works. So first we've got the equals and question mark that
783270	793250	indicate the start of encoded word. The following is the character encoding, in this case UTF-8.
801060	806560	Inside the... so the question marks act as a separator between the charset and the encoding
806560	813120	type. Then it's the type of encoding, and then you've got your encoded data as hex.
813120	820380	So it's prefixed with equals, so equal 41 is an uppercase A, so that's where the data occurs.
822300	827060	And the question mark equals indicate the end of the encoded word.
827680	831140	And the actual email that gets sent is that.
831780	836600	So all the meta characters are removed, and that email is sent to there.
838600	844280	To probe for encoded word, you should make two requests with the two charsets.
844360	850440	The reason for this is that many different email parsing libraries support different charsets.
850440	855580	When probing, you should use lowercase characters in case the site rejects or
855580	863580	transforms to lowercase. So I was initially using x as a charset, but to reduce the size of the
863580	869040	probe. However, on some systems, they will reject unknown charsets and it would fail.
869040	875740	So it's better to use these two probes and then follow up with a charset of x to see if it works.
875740	882680	If successful in each case, you'll send an email to the ones displayed. In a real probe,
882680	887680	you would use a collaborator payload or a similar tool. I've highlighted the encoded
887680	893200	and decoded text in red. So for example, equals 61 is a lowercase a.
895850	902890	So we've covered how encoded word works. So let's dive into some real world case studies.
903190	911490	The following case studies all use the Ruby mail library, which has over 508 million downloads.
911590	919690	At the time of testing, the version was 2.8.1. This library is used by many popular applications,
919690	924230	including GitHub, Zendesk, GitLab, and Bugcrowd.
926390	932230	So for my first case study, I'm going to show you how I exploited GitLab Enterprise. I love
932230	938030	this vector because it's so elegant. So first I used a charset of x because this was not important
938030	946270	on the enterprise product. Then I use an encoded at symbol, so equals 40 is encoded at. And then
946270	952410	I used the underscore character. So interestingly, encoded word supports equals 20 as a space,
952410	959670	but also underscore. What happens then is the email is split in half and the email is sent
959670	966660	to that address. So GitLab thinks the address is example.com, but it actually goes to psres.net.
968990	975170	So what was the impact on GitLab Enterprise? Well, I could verify email addresses that I
975170	981770	didn't control. This means I could gain access to GitLab Enterprise servers that use domain-based
981770	992740	registration restrictions. To understand the next set of slides, let's have a quick recap on how the
992740	998260	email gets sent at the SMTP level. So there's a conversation between the mailer and the SMTP
998260	1003400	client, and there's a handshake that occurs, but that's not important for this part of the talk.
1003400	1009320	The important part is the receipt2 command. You'll notice it's enclosed with angle brackets.
1009660	1014360	We're going to abuse this in the next few slides to change the email destination.
1018640	1026780	GitLab is also an IDP, and I exploited their email verification. So I used x for the slide
1026780	1031140	because it wouldn't all fit on. No one needs to be able to see it, but you'd have to use this
1031140	1039700	tri-set specified in red here. Then I used an encoded at symbol again, but this time I used
1039700	1046740	the greater than symbol, so this is an encoded greater than symbol, and then an encoded space.
1047220	1053200	And then GitLab thinks the domain is example.com, but it actually goes to psres.net.
1053200	1057820	So you can spoof any domain you like and verify any domain you like on GitLab.
1059580	1069500	So, yeah, using this bug, you could bypass domain-based access controls, websites that support GitLab as an IDP.
1069500	1076040	This screenshot shows that I've got a Microsoft verified email address and GitLab email address.
1076580	1078980	It's a bit small, but you can see it's verified.
1080200	1089480	So this one is more complex, and this works on Zendesk and uses the quoted local part with encoded quotes.
1090360	1093920	First, we start the quoted local part.
1095480	1102020	Then we use a Q encoded double quote, so equals 22 is a double quote,
1102800	1106160	followed by an encoded at symbol this time.
1107440	1114040	Next, we have to use the greater than and a null character for Zendesk.
1114040	1119880	So this has the same effect on space. The null character prevents the rest of the address from being used.
1122570	1132050	Due to the quirks of the mailer and the validation that Zendesk used, I had to use an encoded less than character and a double quote.
1132070	1137190	And my theory for this is that Zendesk were doing email parsing multiple times.
1137190	1143050	So adding all this would then decode and then start to remove parts of the email address.
1143590	1148450	And then we finish the quoted local part, and the actual email that gets sent is there.
1148450	1152230	Absolutely crazy. Yeah, pretty nuts.
1153850	1162130	So the impact of this attack was attackers could verify email addresses from domains they don't control,
1162130	1167170	which means they could access Zendesk email domain protected support centers.
1170290	1174170	GitHub were also vulnerable to the greater than and null attack.
1174170	1182970	So first I created an encoded at symbol, then I used an encoded greater than symbol to end the receipt to command.
1183730	1191370	And GitHub required a null character, so adding this null character would then ignore the rest of the address.
1191630	1193770	And that would go to that email again.
1196790	1200350	So using this technique, I was able to verify domains
1200350	1208670	I didn't control on GitHub, and I had verified emails from Mozilla.com, GitHub.com, and Microsoft.com.
1211520	1215800	By spoofing domains on GitHub, I could verify domains I don't control.
1215800	1218500	This means I could bypass domain-based access controls
1218500	1223060	on websites that used GitHub as an identity provider.
1223280	1228400	For example, I could penetrate internal networks protected by Cloudflare Zero Trust.
1228400	1234450	If it was configured to use GitHub as an IDP and email domain validation.
1234720	1240420	So the following screenshot shows Zero Trust trusting domains from GitHub.com.
1240420	1243520	Since any domain can be spoofed and verified,
1243520	1249290	this vulnerability affected Cloudflare Zero Trust instance using email domain validation.
1252410	1255660	So as I was testing multiple Ruby libraries,
1255660	1260960	I discovered that you could use Base64 encoded email addresses.
1260960	1265400	Because why not, right? We all need this, don't we? We need Base64 encoded addresses.
1265640	1273640	In this example, it uses the B as the encoding type, so that indicates Base64.
1274420	1277620	And this is a Base64 foo bar.
1277620	1283280	So I'm using foo bar as an example, but any character can be encoded.
1283280	1288700	And that results into an email of foobar at psres.net.
1288700	1291720	Don't worry, it gets worse. It gets more disgusting.
1292340	1297840	So who remembers this? A script tag encoded in UTF-7.
1297840	1301980	This XSS vector used to work on IE. Anybody remember it?
1302220	1306460	Yeah? Surely? No. Let's see.
1306740	1312440	Surely email parsing libraries won't allow you to use a UTF-7 charset?
1312850	1319820	Of course they do. Using the Ruby library mail, here is a UTF-7 encoded address.
1320040	1325400	So this is a UTF-7 foo bar. You'll notice the ampersand.
1325400	1329730	That's intentional because that's the character that they support for UTF-7.
1330460	1337610	So the charset will be decoded and the email will be sent to foobar at psres.net.
1338340	1342270	I know what you're thinking. Or maybe it's just me.
1342270	1348130	But yes, you can use UTF-7 and Base64 in an email address.
1348660	1355220	In this example, there's a Base64 email address with a UTF-7 charset.
1356030	1359820	First, the email parser will decode Base64.
1360190	1365170	Then the email parser will decode the UTF-7 charset.
1365170	1368110	Finally, the decoded address will be sent there.
1368110	1369250	Absolutely crazy.
1369250	1373910	And I'll emphasize the point that any character can be encoded.
1373910	1376750	I'm just using foobar to make it simple to follow.
1378590	1382970	Then I thought, what about UTF-7 and queue encoding?
1382970	1388650	So here I'm going to modify the A character and replace it with equals 41.
1388650	1397330	This will then get decoded and then it will be decoded and form a UTF-7 encoded foobar.
1397330	1399810	So it's going through two layers of encoding.
1399810	1404310	At this point, you might start having a few doubts about following the RFC.
1404990	1409210	Especially when I tell you that this works in the domain part 2.
1409210	1415710	And when I tested the Ruby mail library, I know what you're thinking.
1417190	1419570	It's... sorry, I've lost track.
1420070	1421570	I know what you're thinking.
1421570	1424830	No website is going to support UTF-7, right?
1424830	1426950	No website is going to support that.
1427070	1432890	But actually, there was a small source code web hosting site called GitHub.
1432890	1435390	They supported UTF-7.
1435490	1438350	I'm so gutted that I didn't exploit them with UTF-7
1438350	1441990	because they'd already fixed it by the time I found this.
1441990	1446150	And then, yeah, it'll go to that email address.
1446150	1447930	So foobar.psrez.net.
1449990	1454170	So then I went hunting for encoded word outside of Ruby.
1454170	1460130	And I found that phpMailer supports encoded word within the name of the recipient.
1460430	1464470	I tried exploiting this in WordPress and other applications,
1464470	1469630	but the requirements of needing angle brackets around the email made exploitation difficult.
1469710	1471970	Still, I bet there are vulnerable systems
1471970	1475150	that decode the actual name of the recipient.
1475650	1479190	So you may find this in bug bounty sites.
1481990	1488150	So we've explored how you can manipulate email parsing to sidestep access controls.
1488150	1489810	But shall we take it a bit further?
1489810	1495730	What if we could use an email address and weaponize it to gain remote code execution?
1496230	1501230	In this section, we'll cover PuniCode attacks and how I exploited Joomla.
1502790	1508770	So PuniCode is a way to represent Unicode characters in the current DNS system.
1508770	1513470	PuniCode always starts with xn and is followed by two hyphens.
1513470	1516850	The algorithm converts the sequence of Unicode characters
1516850	1521980	into a representation that utilizes only alphanumeric characters and hyphens.
1522350	1525810	For example, the domain muchen, I hope I pronounced that right,
1525810	1530330	is encoded with the following PuniCode sequence, as you can see there.
1530330	1534950	Due to the very nature of how PuniCode works, it makes it difficult to test
1534950	1538910	because changing one character can affect the entire output
1538910	1542810	and the character position due to how the algorithm works.
1542810	1548030	So what we want to do is generate some malicious characters that when it's decoded...
1549110	1554390	Sorry, what we want to do is generate malicious characters when it's decoded.
1554390	1556510	But doing so is a big challenge.
1556510	1561730	In these examples, you can see the Unicode character changes when one byte is modified.
1561730	1564700	This makes it difficult to generate a malicious payload.
1566130	1570130	So after reading about PuniCode on Wikipedia,
1570130	1574440	I followed a link to an online PuniCode converter and I began to experiment.
1574950	1578530	The converter used the IDN PHP library.
1578530	1582590	I first started to add zeros to the beginning of the PuniCode address
1582590	1585250	to convert it into ASCII characters.
1585250	1591070	So I initially succeeded generating a comma, which was so surprising I doubted my eyes.
1591110	1595890	Encouraged by this, I started to experiment further and managed to produce an art symbol.
1597670	1602650	So after searching GitHub, I found an interesting target using the library,
1602650	1603430	Joomla.
1603430	1606990	This was great because if I got XSS, then I would have RCE.
1607390	1611650	Doing a source code analysis, I noticed they were escaping the email
1611650	1614070	before it was PuniCode decoded.
1614070	1617270	This means if I could produce some malformed PuniCode,
1617270	1621310	that when decoded produces HTML, I could get XSS.
1621310	1622730	But it wouldn't be that easy.
1624070	1625270	Sound simple?
1625270	1629710	Just give the decoder some malformed PuniCode and generate some HTML.
1629750	1632010	But remember how the algorithm works.
1632010	1636150	Any change in the character can result in a completely different output.
1636190	1641350	I thought about this for a while and I thought that this was a good job for a fuzzer.
1641350	1647230	So I wrote a fuzzer to generate malformed PuniCode and the results were interesting.
1647570	1650450	I found many ways to generate different characters.
1650450	1652410	So you can see what I was trying to do here.
1652410	1654650	I'm trying to generate an SVG type.
1656210	1660450	So I started generating millions of different character combinations.
1660450	1665310	I managed to construct partial XSS vectors, but I encountered several issues.
1665310	1670510	I could only generate two ASCII characters by using more than one PuniCode subdomain.
1670510	1677410	This limitation arose from the specific workings of the PuniCode algorithm PHP
1677410	1681110	and the quirks of this buggy PHP IDN library.
1681110	1684230	As you can see in the examples, I was really close.
1684230	1687850	But these problems made exploiting Joomla very difficult.
1687850	1690880	I concluded that XSS was not feasible.
1691820	1696430	Because although I was able to generate a single quoted attribute,
1696430	1698710	it required an underscore character.
1698710	1705510	Joomla, however, does not permit underscore characters in the domain part of the email address.
1705750	1711030	So you can see those mad PuniCode addresses are trying to inject some HTML.
1712250	1714470	So was that the end of the story?
1714470	1715610	Not quite.
1716110	1718090	I thought about this for a while.
1718090	1721490	And I worked out that you could use a single PuniCode subdomain
1721490	1724330	and you could generate any opening tag.
1724330	1726810	Eventually, after a lot of testing,
1726810	1731370	I concluded the only exploitable vector was an opening style tag.
1731510	1734670	Here I use malform PuniCode to construct it.
1734710	1736370	It looks like a test string, right?
1736370	1738750	But this is actually how it works.
1738750	1740390	Style 1, 2, 3.
1740390	1741750	And 3, 2, 1, sorry.
1741750	1743650	And that would generate a style tag.
1745050	1749710	The rest of the pre-existing Joomla HTML code would add the space
1749710	1752310	and the closing angle bracket for me.
1752310	1754190	So it injects this style tag
1754190	1758530	and then the rest of the HTML adds those characters for me.
1759650	1762050	So what I'd need is two accounts.
1762050	1767710	The first registers with a style tag with malform PuniCode as demonstrated.
1767710	1774650	The second account has the actual CSS payload inside the name of the user.
1774670	1777470	That imports the malicious style sheet.
1777470	1781990	The first account starts with A and the second account starts with X.
1781990	1785250	This is to ensure the style injection occurs first
1785250	1789550	and then the payload with the import occurs second.
1789870	1792170	Notice I'm using curly braces.
1792170	1798650	This is to treat all the HTML that occurs before the import as an invalid CSS selector.
1798650	1802170	And this still works because this is CSS, right?
1802170	1803450	It'll just work.
1805930	1810430	So the first step is to register two accounts for the attacker.
1810430	1815950	The first with the malicious PuniCode and the second with the evil CSS.
1816050	1822630	So here we're using the malform PuniCode in the email and the second account in the name.
1825270	1830570	The attacker then uses import chaining and a custom node server,
1830870	1836670	a custom CSS exfiltrator to quickly exfiltrate the CSERF token from the admin.
1836670	1839510	And when the admin visits the user's page,
1839510	1844570	this CSS will get executed and the CSERF token is leaked to the attacker.
1845650	1848470	The screenshot shows this process happening.
1851180	1859140	Using the exfiltrated token, the attacker then uses the CSS exfiltrator and gives the admin a URL.
1859140	1864180	The admin visits that site and a CSERF attack is then performed on the admin
1864180	1870400	using the exfiltrated token and then the admin template is then modified and then you get RCE.
1872480	1879260	Now, James said I should do a live demo. I wasn't as keen, but let's give it a shot.
1885290	1891070	Right, so on the left is the victim, so it's the admin on the left.
1891070	1895730	On the right is the attacker. We've also got the exfiltrator running
1896490	1899210	and this is where the token will be extracted.
1899930	1905810	So the attacker visits the page. I've pre-filled the data because you don't want to see me typing
1905810	1913870	everything. And the email address contains a malform punicode. So I get an error and that
1913870	1920730	error is just because I haven't configured mail on the server. And then you register a
1920730	1926690	second account and this is with the actual payload in that exfiltrates the token.
1929710	1937470	So the two accounts are registered. Now let's log in as the admin and pray to the demo gods.
1942510	1952960	Right, thank you very much. But we still need to send the message to the admin, right?
1953220	1958300	Hey admin, how's your day going? Yeah, going good, living the dream. Let's click on this.
1961650	1965550	So I'm showing you a real attack. You wouldn't show the payload in there,
1965550	1969430	but we've backdoored Joomla, and then the attacker goes to pond,
1969430	1978650	and we've got ICE, we're casting etc password. Thank you, thank you.
1989040	1994540	So whilst conducting this research, I found it useful to follow the following methodology.
1994540	2001920	Probe, observe, encode, exploit. First probe for encoded word. Observe that it will be decoded
2001920	2007440	to confirm that it's supported. Then encode the various characters and observe how they're
2007440	2012440	decoded. And then follow with an exploit that abuses these characters. So this methodology
2013280	2018740	is spelt out here. So these are the steps you can take to exploit. And this is some of the
2018740	2026480	steps I use to exploit these targets. Hackverter is a free open source tool that I wrote for
2026480	2032960	the burp suite. I've crafted some hackverter tags to help you generate unicode overflows
2032960	2039920	and encoded word attacks easily within burp. Turbo intruder is another free burp extension
2039920	2045380	written by James Kettle. I've created a turbo intruder script to exploit the mailers. So you
2045380	2051300	remember when github supported null for example, this was found with turbo intruder. I've also
2051300	2058600	created a punicode fuzzer to help with malformed punicode. The fuzzer works by giving some input,
2058600	2064000	some punicode address, and then the placeholders are substituted with random numbers, characters,
2064000	2069340	or white space. It was really effective in finding what characters could be generated.
2069340	2074900	We've also updated burp intruder word list with a list of these attacks too.
2075380	2082920	For your convenience. To defend against email splitting attacks, make sure you filter out or
2082920	2089100	disable encoded word. Always verify email addresses before using them, even when received
2089100	2096660	from an SSO provider. After validating the email address, do not use the domain as a sole means of
2096660	2104260	authorization because it can lead to bad stuff. A few blog posts were really inspirational when
2104260	2109300	conducting this research. I recommend you read each one because they are really useful and
2109300	2114400	contain really useful information. The import chaining technique to use to exfiltrate the
2114400	2122000	token is from Petvilla and Donut, awesome researchers. So the three takeaways that I
2122000	2129480	want to leave you with are valid email addresses that can trigger major parser discrepancies.
2129480	2136000	Even email addresses that end in at example.com might go elsewhere and as a result it's never
2136000	2143600	safe to use email domains for access control enforcement. We've created a web security academy
2143600	2149960	CTF so you can try and do an email splitting attack. I've also created a docker file with
2149960	2156420	the vulnerable Joomla installation for your convenience. You can get all the materials and
2156420	2164120	download all the materials for this presentation on the GitHub repository. Thank you very much
2164120	2165300	DEF CON.
