start	end	text
0	7400	Good morning, everyone. Welcome to talk two in the creator stage four. Apologies to those
7400	12440	who are watching online. We still are having technical difficulties. And so we only have the
12440	18080	slides on the screen. We are working on it. Hopefully we'll have it for the next talk.
19220	26820	But I would like to introduce Blackis on his talk from easy wins to epic challenges,
26820	30420	the bounty hunter edition. Everyone involved.
37510	46170	Hey, everyone. So I present you a bit of my journey in bug bounty. I tried to select
46830	52910	some bugs that were quite surprising. Surprising in the sense of being very easy
52910	62070	or being very difficult. So I will present a couple of fun bugs. So a bit about myself.
62070	68390	So I'm doing bug bounty for seven years now. I did a lot of CTFSO for 15 years or something
68390	74570	like that. And in general, I'm working for 18 years now. So that's quite a long time I'm doing
74570	84470	that. I'm definitely a web application enjoyer. I love PHP. Who doesn't? And I love doing some
84470	90970	source code review. I'm definitely not a recon guy. Not doing anything like reconnaissance or
90970	97170	something like that. I'm just going to main apps and break them. Most of the time, at least.
97550	105270	I really love, like, complex chain, complex exploit or something like that.
105530	113170	And, yeah, in my journey, I did something around, like, $2 million across all platforms.
113570	120450	And I'm also an ambassador for France. So, yeah, I'm French. That explains my pretty bad English.
120450	127090	I'm sorry for that. If something isn't clear, don't hesitate to come later and just ask me.
128190	136470	So we'll begin with first customer, Swisscom. So I will present a couple of bugs I found on them.
138130	149930	Swisscom is a big provider in Switzerland. They are doing a lot of things. They are active
149930	159910	in 2016. That was my first experience. I started, like, end of 2016 on them.
160670	165430	And that's a pretty good team, to be honest. They're pretty fair. They're pretty kind. Good
165430	172330	communication with them. They have a very big scope, like, millions of IP addresses. So it's
172330	179870	pretty cool. And I did something around, like, $500,000 on them. So, yeah, that's quite
179870	189010	good. Definitely the bug bounty, they decided to open definitely improved their security
191530	198290	stuff over time. And, yeah, the bugs I'm presenting now are quite old. Definitely
198830	207290	they're, like, pretty much other stuff now. But still quite some cool bugs. So if some people
207290	212970	are interested by their bug bounty programs, they're outside of any platform, you can just
212970	222670	take a peek of the URL. Everything is explained there. So let's talk about first target,
222670	227650	which is Swisscom Cockpit. That's the mobile phone manager in Swisscom. That's basically
227650	234390	where you can see your subscription and where you can just buy some packs for traveling and
234390	240110	things like that. There's locking process on it that is quite particular. It trusts you
240110	245630	sending your phone number and you receive an SMS token. You need also to fill a capture and
245630	253210	you're logged in if the card is valid, right? So it definitely manage some serious confidential
253210	259430	data, a lot of PII payments, things like that. You can see everything that is related to
259430	268290	subscription on there. So definitely a good target for me. Also, uh, pretty good stuff for us.
268290	274530	There is a staging instance on the internet that is, like, publicly available. That was cool.
274530	279330	There might be some, uh, stuff that is not published on the production server and things like
279330	288370	that. So let's talk about the first bug. Uh, I saw that on the staging instance, the SMS token
288370	295470	is always 1, 1, 1, 1. Pretty good. Uh, the problem is the staging log in doesn't work. It
295470	303390	always throws some internal server error. So I can't log in with it. And I was, like, yeah,
303390	311710	maybe that's the SMS repository. It might be, like, shared with the production system. So I
311710	317830	just try to log in on the production system. Then try to log in on the staging system.
318570	328050	Then use 1, 1, 1, 1 on production system. And I was logged in. So that was a very simple, uh, bug.
328050	335050	But definitely a good impact. So let's see a demo. If everything is working well, we should be
335050	343530	able to see. Yeah. So I'm just entering a phone number. Just trying to sign in. Doing the same
343530	353720	on the staging instance. And I'm trying on the prod instance to just input 1, 1, 1, 1. Filling
353720	364320	the capture. Sign in. And I'm signed in. So, yeah. Pretty easy. Uh, that's not video of the
365080	372080	real system. I reproduced everything locally. I will share the demo, uh, the demos video and
372080	379860	instances a bit later after the talk. So, yeah. This was paid 8,000 dollars. Which is pretty
379860	385900	good because that was super easy. But that, uh, have a nice impact for them because I have like
385900	395980	PII of every customer there. Uh, maybe millions of PII there. So, yeah. Pretty good. Uh, second
395980	404100	bag. So, as I said, the login process is, uh, pretty easy. You just input, uh, your phone
404100	410660	number. You submit. Then, uh, you receive, uh, SMS codes that you need to submit with, uh,
410660	417780	capture. But the process is also setting you, uh, three encrypted cookies. The first one is a
417780	423400	cockpit capture text. Uh, it definitely by the name, I guess, it definitely manages capture
423400	430360	text. Uh, the cockpit MSISDN key that manage the phone numbers that you input at the first step.
430680	437800	And the cockpit SMS token key which, I guess, is a pin code that was received by SMS. So, I was
437800	447120	like, okay, maybe they are using, like, the same key for encryption. So, I decided to, like, copy
447120	454040	the cockpit SMS token key cookie into the cockpit capture text. Reload the page. And the
454040	460920	pin code is just leaked into the capture. So, here it is. That's not very clear because there's
460920	470160	some, uh, maybe, uh, padding issue. But you can see the code there that is 7998. So, that's
470160	477920	once again an authentication bypass by leaking, uh, the SMS pin token into the capture which is,
477920	492800	like, pretty lame but pretty good for me. So, let's do a small, if I can move that. Here it is.
492800	501420	Out of the demo. So, just filling the phone number again. Trying to see the cookies.
502180	510880	Putting the SMS token key into the capture text cookie. Just reloading. And we get the pin code
510880	521380	into the capture which is RKB5T. That's a pin code I received by SMS. So, I'm once again logged in
521380	531080	with that. So, pretty cool but definitely, uh, not as serious as the previous bug but because it
531080	537120	was pretty hard to see, to read the capture. You can't really automate the attack so they decided
537120	545400	to pay $3,000 for that. Once again, it was quite an easy bug so I can complain, uh, on the amount
545400	554560	so I decided it might be the time to stop on cockpits. But no, here is a, is a cell bug. Uh,
554560	561740	try to log in, input your phone number but at the time you receive the SMS pin code, just cancel
561740	569020	and authentication successful. I have no idea why. I, I suppose they did something bad by
569020	577260	patching, uh, some of my bugs. Uh, yeah, probably a fail. So, they decided to pay, uh, $8,000 for
577260	582020	that because I just canceled the login process and I was logged in. Uh, I suppose you don't
582020	589060	expect a demo for that. I mean, that's not really needed, I guess. So, for this time, let's really
589060	597080	move on to another target. So, uh, Swisscom WorkLink, uh, is a Swisscom acquisition that was
597080	603720	like a company that just bought. I decided to have a check. They were using, uh, completely
603720	611620	unknown CMS called weblication, something in PHP, you know, that trigger me always. Uh, so I
611620	621960	decided to, uh, buy a weblication license, uh, so I can grab the code and turn that into, like,
621960	629920	some source code review. Uh, firstly, I saw that the thing is not using SQL at all. Uh, it's only
629920	640600	some, uh, XML databases and some, uh, file system storage, which is quite not so usual. So, firstly,
640600	646960	I saw that, uh, they have a general pass traversal prevention mechanism and in general, uh, they're
646960	653900	trying, like, to sanitize every, uh, every variables that you can input. There is an easy
653900	660280	bypass because they are, like, uh, trying to remove, uh, pass traversal characters and later in
660280	666720	the process, they're trying to remove pipes. So, you can just, like, uh, use, uh, dot pipe dot
666720	672520	pipe slash and it will be transformed to pipe, uh, to dot dot slash. So, there is, like, an easy
672520	678560	bypass of the, uh, mechanism to prevent pass traversal. So, I decided to have a look for some
678560	685420	pass traversal issues. Uh, I found pretty easily, uh, vulnerabilities that allow me to delete all
685420	692760	the files, uh, in a directory, but, uh, it wasn't, uh, reachable because it checked for a
692760	702500	specific directory on the app that was never used anywhere. So, there is no way to create that, uh,
702500	708900	I found, uh, an arbitrary directory creation, which is generally something that is quite
708900	714740	useless, but for that case, it was quite useful for me. So, I created the directory that was
714740	721940	needed, uh, to reach the directory empty vulnerability. Uh, so, cool. I can delete files
721940	728840	in directories, uh, but, come on, that's not useful. I'm definitely not wanting to deface
728840	738200	their website, that's definitely not the goal. So, uh, I did, I, I had a check, and, uh, in the
738200	746340	weblications, slash, uh, five directories, there is a .htaccess file, that's the only file there,
746340	754180	but in the subdirectories, there is like all the databases, uh, all the XML databases there. Uh,
754180	762020	the only, uh, mechanism of protection there is a .htaccess file, so maybe we can just remove the
762020	769120	.htaccess file, so we can access the XML databases then. For some reason, I don't know why,
769120	778180	but I decided that to, uh, name all the XML databases with a .php extension, that's quite a
778180	786100	strange, uh, decision, but I found that, uh, the logs, uh, the login logs, uh, that, uh, database
786100	792960	is containing, uh, the session token for all users there, so I can just read it, that's an
792960	801080	authentication bypass, that's a win. No, it works locally, it doesn't work remotely. I have like, uh,
801080	808960	internal server error everywhere, so I was quite in despair, I was crying a bit. Um, so my guess
808960	818920	was, uh, my, uh, so WorkLink was using, uh, PHP short tags, so, uh, it clashed with, uh, XML open
818920	827700	tags, so the, the system was, uh, thinking that the XML file was some PHP, it broke because of
827700	833740	some syntax error, and so just through internal server error, so, definitely didn't work. I
833740	842420	decided to go and say, search, uh, other vulnerabilities. I found a pre-auth FC there, but it
842420	850020	failed again for the exact same reason, so I cried a bit again. And I found something that was
850720	856980	maybe interesting, but quite lame, I didn't see the impact at first. I found an XML injection in
856980	864480	the log user database. Uh, so, pretty much the same, it's also, uh, PHP extension, uh, in the
864480	872560	same directories. So, uh, the, the injection is on the user name, and that's like the database
872560	879680	that contains, uh, if a user name is, uh, blocked by the system, so if you're trying to log in, uh,
879680	885980	with a specific user name more than three times, and the login is failed, you're like injected in
885980	892980	that, uh, specific database. So, there is a XML injection there. Okay. Not so useful, I can
892980	900600	block up entire users maybe, but, yeah, quite lame. So, I did have a check on how, uh, the XML
900600	907960	database are passed by the application, uh, I saw that, uh, the developers, uh, did that quite
907960	914100	well. They decided to add some layers of protection, uh, trying to prevent, uh, X include by
914100	921620	calling dumb document, uh, X include function with a false parameter. No luck for them, uh,
921620	928860	thanks PHP, uh, it enabled X include instead, so definitely not what they wanted. Uh, so for
928860	935020	those that don't know, X include is, uh, XML features that allow to include other XML or even
935020	941360	not XML documents into the current one, so it's like, exactly like PHP include, but for XML.
944100	952780	So, trying to put, uh, that username will definitely, uh, add a X include directive that will
952780	961160	load, uh, the login logs database into the, uh, blocked users database. Uh, that's, that's a
961160	968200	notation for X include directive, uh, that's a bit complicated, but, yeah, definitely the
968200	974800	impact there is, like, we can just include the entire, uh, login logs database into the
974800	981480	blocked user database. But, uh, yeah, X include is doing their best to, like, reformat all the
981480	988140	file to be a fully valid XML. You can break, you can't really break, uh, the file by using X
988140	994200	include, which is quite good, it's doing, like, automatic correction and things like that. But,
994200	999140	no, that's still useless, I mean, yeah, I can include the database into another, but that's
999140	1007240	quite useless. But, I tried to see how the log users feature is working and I found a blind X
1007240	1014660	pass injection, so, in the username is you, if you can, if you inject, uh, some X pass, uh,
1014660	1021540	notation, you have, uh, an injection there. So, you can definitely extract the entire log,
1021540	1028800	uh, log database and I guess you see, uh, what's the interest there. We can, uh, inject, uh,
1028800	1034880	the content of, of the database, uh, in, in the log database and then we can, like,
1034880	1043240	exfiltrate it. So, the log database, uh, yes, I, I, I, I would say that. But, uh, so we can
1043240	1049520	choose a, a blind X pass injection, we can exfiltrate session token byte by a byte per
1049520	1057300	bytes. That gave me, I mean, take around the application and that time in the admin panel
1057300	1066480	there is, like, feature to get RC. So, this time is a win. It works remotely. So, the chain was
1066480	1073100	log user with, uh, XM injection in the username with X include directive pointing to the XM
1073100	1082980	logs. Exfiltrate it with X pass injection, get admin session, get RC and let, let's go for a
1082980	1097530	demo. So, we can see there on the right that the blog database is empty. Now we try to log in
1097530	1105450	with X, uh, to see that just the blog database is now filled with, uh, one entry for the X, uh,
1106150	1115990	user. We now try to inject some XML to see if there is a XM injection there. And yes, it is.
1115990	1124570	There is now a FUBAR attribute, uh, in the, in the block, uh, block entry. So, that time we're
1124570	1135430	using the payloads that, uh, we saw before with the X include directive trying to include, uh,
1138590	1144070	the login log. So, yeah, I just saw that the login log contains some, uh, session stuff there.
1144250	1152870	So, we make that user with the payload to be blocked. We can see that to X include directive is
1152870	1159290	now there in the file of the blocked, uh, database. We make, uh, another user, another random
1159290	1165610	user to be blocked. So, the file will be passed again and this time there is like the entire
1165610	1173270	login log database in that block database. So, this time it was completely replaced, uh, by the,
1173270	1180370	by the original login logs file. So, now we can try to use, uh, the X pass injection. So, we are
1180370	1186870	like targeting, uh, a log element, trying to infiltrate the session. We check here, we're
1186870	1194510	checking if it begins by a L. We know it is because we can see that on the right screen. So, if
1194510	1202170	it begins by a L, we should receive that the account is blocked. But if we check, uh, if it
1202170	1208390	begins by X, we receive that no user is found. So, we have an hour to leak, uh, the characters
1208390	1216210	one by one. So, I write a little script. And yeah, it definitely leaks the session token
1216210	1224490	character by character. So, yeah, we got, we got an admin account to that and get RC remotely.
1224510	1235950	For that, uh, Swisscom decided to pay me $3,000. So, uh, $2,500 for the bag, uh, $500 for the, um,
1235950	1244230	for, uh, bonus for the nice shell. And also the editor decided to, uh, reward me for, with, uh,
1244230	1250230	$2,000. They didn't have the bag money, but they were like impressed by the bag. So, pretty
1250230	1258470	cool for the, for, from them. So, now let's switch to yet another customer, uh, another
1258470	1266030	Swiss one, uh, so Swiss Post. I'm not sure I need to explain what is Swiss Post, but it's
1266030	1270950	about, they are like the postal office in Switzerland, but they are also a private
1270950	1277870	company, uh, doing a lot of different things and they are like involved in a lot of, uh,
1277870	1283490	major projects in Switzerland like e-voting. Uh, they decide, uh, they, they are also very
1283490	1289510	active in cyber security. They like about a lot of local, uh, cyber security, security
1289510	1295410	companies. So, so they are like very active in the cyber security, uh, stuff in
1295410	1302050	Switzerland. They decided to start, uh, bag bounty in 2019, uh, especially for their
1302310	1307850	e-voting platform, uh, and they decided to add, uh, assets, uh, over time. So, uh, they
1310490	1317610	are pretty good, pretty much the same as Swisscom to be honest. Uh, we can have a lot of, uh,
1317610	1322510	communication with them, they are pretty good. And yeah, if some people are from the
1322510	1329830	voting village, uh, go on their bag bounty programs, they are paying like, uh, 230K for a
1329830	1335230	very critical bag there, that's definitely a good program. I'm not a crypto guy, so I'm not
1335230	1342350	going back, maybe you are. So, if you want to have a check, uh, everything is described on
1342350	1353810	their VDP page, so vdp.post.ch. So, uh, for, for the first bag, I will talk about their, uh,
1353810	1360110	payment system, so they are like their own payment system, uh, completely custom, uh,
1360110	1365270	everything is quite common, you get some sign requests, uh, there's a lot of different
1365270	1371190	endpoints for failure and success, and, uh, also you can stack money on your account, on
1371190	1376910	your postal account, you have a balance system, so it's always interesting if we can get, like,
1376910	1383810	infinite money there. I will switch this bag because we have some time issue, let's go on
1383810	1391930	the second one. So, I did find a lot of, uh, stuff there, so I was, uh, hacking on them, and I
1391930	1400190	was trying to manipulate some payment session there, uh, changing price in a transaction, uh,
1400370	1406250	a lot of things, but, uh, a delivery man rang the doorbell in my office, so I need to get the
1406250	1412850	package, seeing everything, I decided that was the time for a coffee break, and then after
1412850	1419790	maybe 10, 15 minutes, I don't know, got back to my chair, and I had some money coming from
1419790	1429170	nowhere on my account, so I had no idea why. So, I decided to replay everything I did, I was
1429170	1436430	like, probably I triggered something, and I didn't even know, so I tried to replay everything,
1436430	1443010	so, that failed. No idea what happened. So, I did to replay everything, including the coffee
1443010	1452230	break, that was maybe the main point, so I did a coffee break with a colleague, and there was my
1452230	1460330	account was affected again. So, I was like, okay, what's the fact, I tested a lot of things, and
1460330	1466410	the real explanation is, uh, when you run the transaction, after the transaction is
1466410	1473470	timed out, so you didn't, uh, make the payment, uh, in the good time frame, it's just
1473470	1479430	considered successful, so probably a bad check of payment states, it default to success
1479430	1491190	instead of defaulting to, uh, a failure, so, yeah. Let's go for a demo. So, let's buy a very
1491190	1500150	good croissant, because I'm French. Oh, that's not a good demo. I want a croissant, a bigger
1500150	1513180	one. Let's go for it. Just wait. Just go grab a coffee, maybe. Are you patient enough? Oh, yeah.
1515360	1523400	No, joking, it will just last. Yeah, success payments, just by waiting. I'm in pretty good
1524880	1532280	solution to get some money, right? So, I was paid, uh, $3,000 for that, uh, that's probably the
1532280	1541240	most I get for, like, a coffee break or two. Definitely was quite profitable, right? So, let's
1541240	1547920	go to another project of them. Uh, they have, like, a subdomain, uh, using, uh, very, very
1547920	1556160	unknown, uh, CMS. So, Peppershop, that's like a Swiss page PCMS. They also do some manager thing
1556160	1563660	and things like that. I never heard of them. So, I decided, once again, to buy a license, uh, of
1563660	1572700	the CMS, so I get access to the code. Once again, it's PHP, so I'm super interested by that. And I
1572700	1581440	just had a look at the code, everything was quite, you know, PHP. Uh, so I saw that, uh, an
1581440	1590160	admin feature, uh, that is quite interesting is a restart backup thing. Uh, it's some, like,
1590160	1597040	custom things. They decided that the delimiter between SQL queries will be that stuff. No idea
1597040	1604860	why. Why don't use, like, semicolon like everyone do? I don't know. They decided it is. And they
1604860	1611540	also have, uh, some features I never, I don't know why, because I didn't see any occurrences
1611540	1619180	where they are using that, but they do. So, if you use, uh, the base64 start and the base64 end
1619180	1627020	tags, that will be replaced by a single coded string of, uh, the base64 decoded string that is
1627040	1635840	between the tag. I don't know why. I, I, that's quite a strange feature to be honest. So, uh, the
1635840	1642840	restart backup, uh, the restart, uh, feature is using, uh, backup from a local file system, uh,
1642840	1649300	that needs to be generated from the CMS backup feature, so, uh, you can't upload anything or
1649300	1657020	something like that. So, my goal was, maybe I can inject SQL queries in backup from the frontend,
1657040	1668800	uh, the method is exploiting the very, like, strange passing to break SQL contexts. So, my idea
1668800	1677480	is, uh, if I use, like, so specific, uh, separator or, uh, like, tags in some data, uh, that is
1677480	1683340	stored in the database, uh, so, uh, that will be stored in the database, uh, maybe when they
1683340	1690140	will backup and restart again, that will break something if I get some data with those tags, uh,
1690140	1695920	maybe on my profile, on my, I don't know, username, name, other comments, uh, things like
1695920	1703780	that. The first problem is, uh, most fields are sanitized by default. That's like a global
1703780	1712700	sanitize, uh, sanitization that is done on every field. Um, so, no, no new lines, no hash, no
1712700	1720940	special characters in general. Uh, the second problem is that if the restore fail on one SQL
1720940	1730000	query, it's like ending the process and not going further in the file. I mean, for the first
1730000	1737040	problem, the solution is quite easy. Most, uh, fields are sanitized but not all. They are like
1737040	1743420	exception. One of them are like, uh, comments that are put on the other. So, I can definitely
1744000	1752160	reach that field, uh, on the front end. And the second, uh, problem, we have like a separate
1752160	1759520	between queries and way to inject single code. So, that should be possible, uh, to get like a
1759520	1769660	valid file after injecting things. So, let's imagine, uh, uh, a valid SQL query in the file
1769660	1776200	formats. So, we control fully the values of Bimmerkugen. I have no idea what it means but
1776200	1782700	that's the name of the database, of the, uh, table. I have no idea what it is. So, we can
1782700	1788620	control that fully and you can see the separator at the end. So, we're trying to use their
1788620	1796480	base 64 feature to break from single codes. So, we're trying to get something like that. That will
1796480	1804640	be transformed to that. So, we inject a single code, a parenthesis, a comment and that is working
1804640	1814260	pretty well to be honest. So, then my goal is to inject new queries in the packet file. So, this
1814260	1823240	time I'm also adding, uh, a separator and a new, uh, query with a comment at the end. So, after
1823240	1829720	being, uh, uh, passed by the restore procedures that will give that. And that's definitely
1829720	1839680	valid. So, I was able to, uh, just inject, uh, an update to, uh, an arbitrary table, changing
1839680	1849520	arbitrary column there. Pretty good. Um, so, the impact is I can run arbitrary queries on the
1849520	1858180	restore process. If they take a backup and restore, that will run my queries. Pretty good. But, uh,
1858180	1865780	the database is obviously that PHP, uh, storing some serialized, uh, PHP objects because, you
1865780	1873480	know, relational databases is done for that. Storing full objects. So, I found, uh, pretty
1873480	1880900	fastly a custom gadget, uh, that allow to delete local files. Once again, not the most
1880900	1885940	interesting primitive for us because that's definitely not a goal to delete, uh, files on
1885940	1894320	them. But I saw that, uh, the admin authentication mechanism is just, uh, dot access file. So,
1896700	1904700	if we delete the dot access file, uh, everyone can go to slash admin and, uh, I mean, just
1904700	1909400	that. There is no authentication besides that. Such as, like, you need, as a valid
1909400	1915860	credential or you need to pipe as a dot access. The payload is too big for the screen, I'm
1915860	1924300	sorry. So, let's get a demo for this one. Once again, super classic. So, the payload is
1924320	1936760	in shop. So, we put the payload, uh, in the other commands. You can see the payload there.
1936760	1943520	It's pretty big. It's just, uh, trying to update the other table and set, uh, a big, uh,
1943520	1952840	serialized, uh, object in the data of the others. So, now, my user have, uh, like another
1952840	1960920	ways, uh, or, uh, or tags, uh, or by basics for tags. So, let's go to an administrator
1960920	1977460	account. Let's do a backup. Yeah, that's a fail. Let's go to the backup. Let's log in. So,
1977460	1984600	let's do a backup and now trying to restore it. Not, not, before restoring it, we can see
1984600	1990940	in the other that, uh, we have, like, or data that is injected, uh, in the other. So, now,
1990940	1997200	trying to restore. That's definitely not the same data. We were able to update the other and
1997200	2007460	add, like, a serialized object. So, let's go see the others that triggered, uh, the serialized
2007460	2013600	objects and now we can go to the admin panel and there's no more authentication on it. So,
2013600	2021240	yeah, that definitely deleted, uh, the htaccess so everyone is admin which is, uh, to be
2021240	2029840	honest a bit, uh, frightening because, like, by exporting that I gave everyone admin access. Oops.
2030480	2040620	So, they pay me, uh, six and, six hundred fifty dollars which is quite bad but, uh, the real, uh,
2040620	2046360	thing is that Swiss Post is not using the backup and restore feature because they have too much
2046360	2053840	data and the official backup feature there is just crashing because there is too much data. You
2053840	2060240	know, like, problem of memory issues and things like that. So, that's even fair they decided to
2060240	2064980	pay a bounty for that because they are, like, no chance they are using the backup and restore
2064980	2074640	feature. So, yeah, still quite firm. Let's go on another customer, the most known one,
2074640	2085340	redacted. Uh, I wasn't able to name them so let's consider that, uh, we just put a bit of
2085340	2094880	context. Imagine a PHP CMS, once again PHP, widely used, uh, with a lot of complex code,
2094880	2102820	complex features, and a little blacklist criticizing the code at every release, every time.
2103760	2113820	So, first bag, there is a new CV there, uh, that's a Prius SE to a SSTI in the wild, like
2113820	2122240	used by a threat actor. So, the maintainers decided to make an emergency patch. I decided to
2122240	2129960	reverse it, obviously. Uh, so, uh, there is like a double level of templating, uh, on the app.
2130320	2137780	And the patch from, uh, the maintainers were just a plain replace to, uh, remove, uh, the tags
2137780	2146580	just after a single evaluation of the templates. Uh, the problem is, maybe someone saw that?
2148140	2155300	You saw that? I know. The regex is not matching new lines. Uh, that means that you can just
2155300	2161820	use the original payload, but use a new line before the closing tags, you're bypassing that
2161820	2169380	regex, and that's like a Prius SE again. That was paid, uh, ten thousand dollars, because, you
2169380	2176560	know, Prius SE are always cool, and small bonus, my colleague, uh, also found another bypass,
2176580	2184800	you just had to not close the tags. So, that was enough, uh, templates, uh, will contain some
2184800	2194400	tags, ending tags later, so, yeah, that's also bypass it. So, as a second bag, and I'm sorry,
2194400	2202460	this one will be quite complex, I will try my best to explain it, uh, correctly, but, yeah,
2202460	2211340	that's a complex one. So, I found a bag, uh, that is, to be honest, barely exportable, but it's
2211340	2220080	super fun technically. So, the worst impact, uh, to use was, uh, Prius SE, but, uh, the
2220080	2226820	precondition of it make it quite unlikely, but, yeah, it's still a fun one. So, for the
2226820	2235760	context, uh, that application, uh, was using Laminas PHP library to, for everything that is
2235760	2243500	using, like, emails. Laminas is doing a lot of checks and transformation to be sure that the
2243500	2248220	email is valid and things like that, there's like a lot of different label, uh, libraries
2248220	2255200	there, and on the application we're testing, uh, we have, uh, control over, uh, from
2255200	2263420	header that will be, uh, used for sending some emails. So, that parameter will be passed, uh,
2263420	2271500	over the fifth argument of mail, for those who know, uh, mail function, uh, of a fifth
2271500	2278800	argument that is, like, arguments that will be passed to the send mail, uh, binary. So, if
2278800	2283440	that fifth argument is, uh, completely controlled by an attacker, you can have, like,
2283440	2290160	argument injection to the send mail binary. There are, like, no next point to that, uh, but
2290160	2298180	it definitely depends on the MTA that is used. So, uh, every MTA is chipped with different
2298180	2306480	send mail binaries. So, for this, uh, talk, we will consider, uh, send mail MTA here. That's
2306480	2313420	like a first condition. Why send mail? Because I'm cheating. That's my bug. I decide to
2313440	2324240	whatever is the condition. So, that's what, uh, I want to be. So, uh, the problem is
2324240	2330720	Laminas validating email address. We can't, like, put anything that is not a valid email
2330720	2337020	address. Uh, Laminas is supporting, uh, cutted string, uh, format, so, uh, double quotes
2337020	2342200	and pretty much anything. Uh, dot atom format, that's like the standard, uh, email
2342200	2349340	formats. Uh, for that, they are using super big regrets. Uh, that was super hard to read.
2350820	2359820	And, yeah, the thing is, uh, they're also using, uh, escape shell lag, uh, on the email
2359820	2369660	before being used on the, uh, main function. But, uh, PHP is automatically applies escape
2369660	2375060	shell command to the entire command, uh, when calling mail, uh, that will apply escape
2375060	2380960	shell command to send mail. Uh, double escape means, uh, no escape at all, means argument
2380960	2390340	injection, thanks PHP. So, another problem is, uh, Laminas or the application, I don't
2390340	2397680	know, is, uh, lower casing your email and every exploit for, uh, send mail, uh, generally
2397680	2406880	using, uh, the C and the X uppercase arguments with very long pass. And the, the problem
2406880	2413340	is we are limited to 64 characters for the local parts and definitely if you need, like,
2413340	2418740	long pass, uh, for two arguments, that's definitely not cool because we are, like,
2418740	2426000	limited in size. Painful. I was, like, a bit in despair. I was pretty sure that won't be
2426000	2434280	exploitable at all. But, yeah, I still decided to make, like, cause of testing. I was pretty
2434280	2442080	much like that after a few hours. But, at some point, I saw that, uh, there was, like, a
2442080	2450080	stranger if my email contains, uh, uh, right angle brackets. So, if I put XSX, uh, right
2450080	2455820	angle bracket at black dot is, I received by the app invalid domain black dot is right
2455820	2460300	bracket. I was, like, that's, that's strange. That's definitely not the domain I put in my
2460300	2467900	mail. So, I decided to debug a bit the behavior. So, Laminas, uh, did, uh, the validation of
2467900	2474320	the email. Laminas and the app, uh, were crafting a full email with the headers and the body
2474770	2482500	and put the email in the form, uh, header. Then, uh, Laminas passed the generated email.
2482500	2490820	Then, the app is extracting the sender again from it. Validates that it's still a valid email.
2490920	2499420	So, painful process. So, I was like, okay, but that doesn't explain the error. So, that's a
2499420	2505900	traditional form header. So, it's just, uh, double quotes your name, double quotes and in
2505900	2512480	brackets, uh, the full email. But, when I tried to inject XSX right brackets at black dot
2512500	2519700	S, that was like the form that was generated. So, we have like an injection in the email part,
2519700	2527600	but that's quite useless in my opinion. Uh, there was like no CRLs, there was like protection
2528260	2534180	and mechanism to prevent that. So, I was like, okay, that's definitely useless. But, I
2534180	2542340	decided to like investigate because that's quite a dirty thing still. So, yeah. Uh, we
2542500	2549220	received, uh, a lot of RFC, a lot of documentation and I saw there's like something called, uh,
2549220	2558160	my man coded words. So, uh, that's described by the, uh, the RFC 2047. That's for using
2558160	2572280	special characters in, uh, email headers and body. That's a format, so, uh, it was seen, uh,
2576780	2587660	so, in that case, I'd like generate AAA. So, all the characters that is used, uh, in the
2587660	2594140	mime uncoded words notation are also valid characters in an email address. At least, uh,
2594140	2601940	in the double, uh, double code encoded formats. So, I was like, maybe I can inject mime
2601940	2609520	uncoded words in my, uh, sender email. So, uh, that will be put in the mail headers and when
2609520	2616360	extracting back by Laminas, it will like pass the mime uncoded words and generate an email that
2616360	2624900	will maybe contain, uh, some, uh, parameter injection to send mail. So, uh, I needed, uh,
2624900	2631920	some spaces to like inject another argument to send mail. Uh, but, uh, equal, uh, equal
2631940	2637760	20 is forbidden by the specification of the AFC, but I found that, uh, underscore is
2637760	2644680	defined as a space by the AFC. So, we can, uh, just input, uh, spaces by using an
2644680	2652560	underscore. Don't ask me why, there's probably a reason for that. So, as we saw, uh, the
2652560	2659840	send mail, uh, send mail payload is always, uh, needing to point to a local configuration
2659840	2667200	file. So, we need to have, uh, a control of a malicious local file. Fortunately for us, the
2667200	2673520	CMS have, uh, a nice file upload. So, we can upload files there. The problem is, uh, the
2673520	2679240	upload file that contains underscore, but underscore replaced by spaces, but we can
2679240	2687060	replace, uh, underscore by, uh, equal five F characters. So, that's a problem, but not
2687060	2693220	so much. The problem is, uh, we need a lot of replacement character and the size
2693220	2699520	limitation is still 64 characters and the mime encoded routes, uh, increase the size of a
2699520	2708320	string by quite a lot. So, let's consider that, uh, a web route is, uh, slash app. That's
2708320	2715060	short. That's definitely what I need. So, I'm still, uh, cheating again. So, uh, that's
2715060	2722080	another preconditions. The first one is you need send mail to be used and you need, uh, a
2722080	2730500	short, uh, web route. So, yeah, that's quite some strong precondition. So, I knew that send
2730500	2736940	mail payload that I am using, uh, the C and the X, uh, arguments. That's definitely too
2736940	2743400	long for us. So, I was like, okay, uh, the C arguments is, uh, loading arbitrary config
2743400	2750380	file. Maybe that's enough to see. Maybe we don't need, uh, uh, X arguments. So, I decided to
2750380	2757160	focus on that and see what is possible to, uh, send a config file. So, in the config file you
2757160	2762880	have, like, the path to the dead letter file. So, the dead letter is like where it, with, it
2762880	2771180	will log, uh, like, incidents in sending emails. So, maybe we can, like, uh, that's, uh, a
2771180	2777120	file that will be in the web routes and I have maybe a file right but we don't control
2777120	2784760	anything in the mail. And there is also, uh, uh, bound second recipient in that config file
2784760	2790300	that will be included in the dead letter because that will, like, you have an email that is
2790300	2795500	failed but then it will try to send to that second recipient and it will write that in the
2795500	2802140	dead letter file. So, maybe we can have arbitrary file rights or at least, uh, partial
2802140	2809980	arbitrary file right but that's PHP so if I have just, uh, a partial file right that would be
2809980	2820260	enough to get a valid PHP file. So, I just sent, uh, a default send mail MTA config and, uh, the
2820260	2826700	two, uh, option, uh, to get arbitrary file right and that's, that was sufficient. So, then I'm
2826700	2833700	sending the mail to not existent at localhost so it fails. So, that will bounce. So, that, uh,
2833700	2842780	the, the, the config that I was using. So, I decided to have a look at the MyMainCodedWord and
2842780	2850240	trying to, like, reduce the size of it. Uh, I was able to win some size like you can just empty
2850260	2857420	the car sets. There is no need of, uh, filling it. Uh, don't, uh, we get, we need double cuts
2857420	2862980	around the payloads because, uh, the email need to be valid and you need to use a double
2862980	2870480	coded, uh, format. Don't ask me why but we need, we needed to end it with, uh, two double
2870480	2877660	cuts. I have no idea that's magic. I didn't investigate it that. So, we can definitely use
2877660	2885640	the uppercase later now because we have the MyMainCodedWords. Uh, so, 64 cards is still too
2885640	2893180	short but with the precondition of having a short web root and everything that just enter
2893180	2902820	exactly, uh, the, the 64 characters. So, it's, uh, upper class and the final payload was
2903200	2911560	just that. Don't ask me why that's a magic, uh, definitely some magic payload. I have now a
2911560	2918620	t-shirt but it's my, in my hotel room with a payload printed on it. Uh, yeah, that's quite a
2918620	2927240	unisex payload and it is to Prius SE on the top in very specific conditions. So, yeah, that
2927240	2932720	was just, uh, settings, uh, if I re-uploaded in to send my command injecting a new, uh,
2932720	2941020	config file for send mail, get arbitrary rights, some PHP in the web app, get RCE, works
2941020	2948820	only on send mail MTA, web root being short so I cheated a bit. But, yeah, you need some
2948820	2953660	Einstein's to explain that. So, definitely not, uh, not really a spot up in the right but
2953660	2962700	still was quite fun technically. So, let's go for a demo. The last one. Uh, so, uh,
2963520	2976000	once again, the question shop. I'm just uploading, uh, the send mail MTA default config
2976000	2987340	file with just like or do two config keys. Yeah, doing the upload manually, sorry, it takes a
2987340	2999340	bit of time. So, yeah, you can see that I'm putting the dead letter in the slash app slash
2999340	3007520	back dot dot PHP with a double bounce address containing a payload. So, yeah, now the config
3007520	3016460	file is uploaded. We can just run the payload in the from, uh, in the from email. That's
3016460	3023060	exactly the payload from the, the slides. We're sending that to, uh, a local host address
3023060	3027360	that doesn't exist. So, that should draw, draw an error. We see that the page is
3027360	3034380	completed bank because that generated an error. So, now we can go to, uh, the slash back
3034380	3042260	dot dot PHP. We can see the dead letter there and I did add some back dot there and we get
3042260	3052940	arbitrary PHP, uh, execution. So, definitely quite cool. So, that was paid 5,000, uh,
3052940	3060960	dollars despite the fact that it was, uh, hardly exploitable. Uh, made me cry a bit. I
3060960	3068820	spent a lot of time on it. So, I hope your brain fried exactly, uh, like me. And that's my
3068820	3073740	end word. So, uh, thanks for having listened to the end. Hope you had fun. Hope you
3073740	3081060	learned some things. And also I will maybe soon open a blog, uh, a blog with a lot of my
3081060	3087800	bags, like a hundred of them. So, yeah, follow me on Twitter if you want some news and thank
3087800	3088400	you.
