[00:00.000 --> 00:07.400] Good morning, everyone. Welcome to talk two in the creator stage four. Apologies to those [00:07.400 --> 00:12.440] who are watching online. We still are having technical difficulties. And so we only have the [00:12.440 --> 00:18.080] slides on the screen. We are working on it. Hopefully we'll have it for the next talk. [00:19.220 --> 00:26.820] But I would like to introduce Blackis on his talk from easy wins to epic challenges, [00:26.820 --> 00:30.420] the bounty hunter edition. Everyone involved. [00:37.510 --> 00:46.170] Hey, everyone. So I present you a bit of my journey in bug bounty. I tried to select [00:46.830 --> 00:52.910] some bugs that were quite surprising. Surprising in the sense of being very easy [00:52.910 --> 01:02.070] or being very difficult. So I will present a couple of fun bugs. So a bit about myself. [01:02.070 --> 01:08.390] So I'm doing bug bounty for seven years now. I did a lot of CTFSO for 15 years or something [01:08.390 --> 01:14.570] like that. And in general, I'm working for 18 years now. So that's quite a long time I'm doing [01:14.570 --> 01:24.470] that. I'm definitely a web application enjoyer. I love PHP. Who doesn't? And I love doing some [01:24.470 --> 01:30.970] source code review. I'm definitely not a recon guy. Not doing anything like reconnaissance or [01:30.970 --> 01:37.170] something like that. I'm just going to main apps and break them. Most of the time, at least. [01:37.550 --> 01:45.270] I really love, like, complex chain, complex exploit or something like that. [01:45.530 --> 01:53.170] And, yeah, in my journey, I did something around, like, $2 million across all platforms. [01:53.570 --> 02:00.450] And I'm also an ambassador for France. So, yeah, I'm French. That explains my pretty bad English. [02:00.450 --> 02:07.090] I'm sorry for that. If something isn't clear, don't hesitate to come later and just ask me. [02:08.190 --> 02:16.470] So we'll begin with first customer, Swisscom. So I will present a couple of bugs I found on them. [02:18.130 --> 02:29.930] Swisscom is a big provider in Switzerland. They are doing a lot of things. They are active [02:29.930 --> 02:39.910] in 2016. That was my first experience. I started, like, end of 2016 on them. [02:40.670 --> 02:45.430] And that's a pretty good team, to be honest. They're pretty fair. They're pretty kind. Good [02:45.430 --> 02:52.330] communication with them. They have a very big scope, like, millions of IP addresses. So it's [02:52.330 --> 02:59.870] pretty cool. And I did something around, like, $500,000 on them. So, yeah, that's quite [02:59.870 --> 03:09.010] good. Definitely the bug bounty, they decided to open definitely improved their security [03:11.530 --> 03:18.290] stuff over time. And, yeah, the bugs I'm presenting now are quite old. Definitely [03:18.830 --> 03:27.290] they're, like, pretty much other stuff now. But still quite some cool bugs. So if some people [03:27.290 --> 03:32.970] are interested by their bug bounty programs, they're outside of any platform, you can just [03:32.970 --> 03:42.670] take a peek of the URL. Everything is explained there. So let's talk about first target, [03:42.670 --> 03:47.650] which is Swisscom Cockpit. That's the mobile phone manager in Swisscom. That's basically [03:47.650 --> 03:54.390] where you can see your subscription and where you can just buy some packs for traveling and [03:54.390 --> 04:00.110] things like that. There's locking process on it that is quite particular. It trusts you [04:00.110 --> 04:05.630] sending your phone number and you receive an SMS token. You need also to fill a capture and [04:05.630 --> 04:13.210] you're logged in if the card is valid, right? So it definitely manage some serious confidential [04:13.210 --> 04:19.430] data, a lot of PII payments, things like that. You can see everything that is related to [04:19.430 --> 04:28.290] subscription on there. So definitely a good target for me. Also, uh, pretty good stuff for us. [04:28.290 --> 04:34.530] There is a staging instance on the internet that is, like, publicly available. That was cool. [04:34.530 --> 04:39.330] There might be some, uh, stuff that is not published on the production server and things like [04:39.330 --> 04:48.370] that. So let's talk about the first bug. Uh, I saw that on the staging instance, the SMS token [04:48.370 --> 04:55.470] is always 1, 1, 1, 1. Pretty good. Uh, the problem is the staging log in doesn't work. It [04:55.470 --> 05:03.390] always throws some internal server error. So I can't log in with it. And I was, like, yeah, [05:03.390 --> 05:11.710] maybe that's the SMS repository. It might be, like, shared with the production system. So I [05:11.710 --> 05:17.830] just try to log in on the production system. Then try to log in on the staging system. [05:18.570 --> 05:28.050] Then use 1, 1, 1, 1 on production system. And I was logged in. So that was a very simple, uh, bug. [05:28.050 --> 05:35.050] But definitely a good impact. So let's see a demo. If everything is working well, we should be [05:35.050 --> 05:43.530] able to see. Yeah. So I'm just entering a phone number. Just trying to sign in. Doing the same [05:43.530 --> 05:53.720] on the staging instance. And I'm trying on the prod instance to just input 1, 1, 1, 1. Filling [05:53.720 --> 06:04.320] the capture. Sign in. And I'm signed in. So, yeah. Pretty easy. Uh, that's not video of the [06:05.080 --> 06:12.080] real system. I reproduced everything locally. I will share the demo, uh, the demos video and [06:12.080 --> 06:19.860] instances a bit later after the talk. So, yeah. This was paid 8,000 dollars. Which is pretty [06:19.860 --> 06:25.900] good because that was super easy. But that, uh, have a nice impact for them because I have like [06:25.900 --> 06:35.980] PII of every customer there. Uh, maybe millions of PII there. So, yeah. Pretty good. Uh, second [06:35.980 --> 06:44.100] bag. So, as I said, the login process is, uh, pretty easy. You just input, uh, your phone [06:44.100 --> 06:50.660] number. You submit. Then, uh, you receive, uh, SMS codes that you need to submit with, uh, [06:50.660 --> 06:57.780] capture. But the process is also setting you, uh, three encrypted cookies. The first one is a [06:57.780 --> 07:03.400] cockpit capture text. Uh, it definitely by the name, I guess, it definitely manages capture [07:03.400 --> 07:10.360] text. Uh, the cockpit MSISDN key that manage the phone numbers that you input at the first step. [07:10.680 --> 07:17.800] And the cockpit SMS token key which, I guess, is a pin code that was received by SMS. So, I was [07:17.800 --> 07:27.120] like, okay, maybe they are using, like, the same key for encryption. So, I decided to, like, copy [07:27.120 --> 07:34.040] the cockpit SMS token key cookie into the cockpit capture text. Reload the page. And the [07:34.040 --> 07:40.920] pin code is just leaked into the capture. So, here it is. That's not very clear because there's [07:40.920 --> 07:50.160] some, uh, maybe, uh, padding issue. But you can see the code there that is 7998. So, that's [07:50.160 --> 07:57.920] once again an authentication bypass by leaking, uh, the SMS pin token into the capture which is, [07:57.920 --> 08:12.800] like, pretty lame but pretty good for me. So, let's do a small, if I can move that. Here it is. [08:12.800 --> 08:21.420] Out of the demo. So, just filling the phone number again. Trying to see the cookies. [08:22.180 --> 08:30.880] Putting the SMS token key into the capture text cookie. Just reloading. And we get the pin code [08:30.880 --> 08:41.380] into the capture which is RKB5T. That's a pin code I received by SMS. So, I'm once again logged in [08:41.380 --> 08:51.080] with that. So, pretty cool but definitely, uh, not as serious as the previous bug but because it [08:51.080 --> 08:57.120] was pretty hard to see, to read the capture. You can't really automate the attack so they decided [08:57.120 --> 09:05.400] to pay $3,000 for that. Once again, it was quite an easy bug so I can complain, uh, on the amount [09:05.400 --> 09:14.560] so I decided it might be the time to stop on cockpits. But no, here is a, is a cell bug. Uh, [09:14.560 --> 09:21.740] try to log in, input your phone number but at the time you receive the SMS pin code, just cancel [09:21.740 --> 09:29.020] and authentication successful. I have no idea why. I, I suppose they did something bad by [09:29.020 --> 09:37.260] patching, uh, some of my bugs. Uh, yeah, probably a fail. So, they decided to pay, uh, $8,000 for [09:37.260 --> 09:42.020] that because I just canceled the login process and I was logged in. Uh, I suppose you don't [09:42.020 --> 09:49.060] expect a demo for that. I mean, that's not really needed, I guess. So, for this time, let's really [09:49.060 --> 09:57.080] move on to another target. So, uh, Swisscom WorkLink, uh, is a Swisscom acquisition that was [09:57.080 --> 10:03.720] like a company that just bought. I decided to have a check. They were using, uh, completely [10:03.720 --> 10:11.620] unknown CMS called weblication, something in PHP, you know, that trigger me always. Uh, so I [10:11.620 --> 10:21.960] decided to, uh, buy a weblication license, uh, so I can grab the code and turn that into, like, [10:21.960 --> 10:29.920] some source code review. Uh, firstly, I saw that the thing is not using SQL at all. Uh, it's only [10:29.920 --> 10:40.600] some, uh, XML databases and some, uh, file system storage, which is quite not so usual. So, firstly, [10:40.600 --> 10:46.960] I saw that, uh, they have a general pass traversal prevention mechanism and in general, uh, they're [10:46.960 --> 10:53.900] trying, like, to sanitize every, uh, every variables that you can input. There is an easy [10:53.900 --> 11:00.280] bypass because they are, like, uh, trying to remove, uh, pass traversal characters and later in [11:00.280 --> 11:06.720] the process, they're trying to remove pipes. So, you can just, like, uh, use, uh, dot pipe dot [11:06.720 --> 11:12.520] pipe slash and it will be transformed to pipe, uh, to dot dot slash. So, there is, like, an easy [11:12.520 --> 11:18.560] bypass of the, uh, mechanism to prevent pass traversal. So, I decided to have a look for some [11:18.560 --> 11:25.420] pass traversal issues. Uh, I found pretty easily, uh, vulnerabilities that allow me to delete all [11:25.420 --> 11:32.760] the files, uh, in a directory, but, uh, it wasn't, uh, reachable because it checked for a [11:32.760 --> 11:42.500] specific directory on the app that was never used anywhere. So, there is no way to create that, uh, [11:42.500 --> 11:48.900] I found, uh, an arbitrary directory creation, which is generally something that is quite [11:48.900 --> 11:54.740] useless, but for that case, it was quite useful for me. So, I created the directory that was [11:54.740 --> 12:01.940] needed, uh, to reach the directory empty vulnerability. Uh, so, cool. I can delete files [12:01.940 --> 12:08.840] in directories, uh, but, come on, that's not useful. I'm definitely not wanting to deface [12:08.840 --> 12:18.200] their website, that's definitely not the goal. So, uh, I did, I, I had a check, and, uh, in the [12:18.200 --> 12:26.340] weblications, slash, uh, five directories, there is a .htaccess file, that's the only file there, [12:26.340 --> 12:34.180] but in the subdirectories, there is like all the databases, uh, all the XML databases there. Uh, [12:34.180 --> 12:42.020] the only, uh, mechanism of protection there is a .htaccess file, so maybe we can just remove the [12:42.020 --> 12:49.120] .htaccess file, so we can access the XML databases then. For some reason, I don't know why, [12:49.120 --> 12:58.180] but I decided that to, uh, name all the XML databases with a .php extension, that's quite a [12:58.180 --> 13:06.100] strange, uh, decision, but I found that, uh, the logs, uh, the login logs, uh, that, uh, database [13:06.100 --> 13:12.960] is containing, uh, the session token for all users there, so I can just read it, that's an [13:12.960 --> 13:21.080] authentication bypass, that's a win. No, it works locally, it doesn't work remotely. I have like, uh, [13:21.080 --> 13:28.960] internal server error everywhere, so I was quite in despair, I was crying a bit. Um, so my guess [13:28.960 --> 13:38.920] was, uh, my, uh, so WorkLink was using, uh, PHP short tags, so, uh, it clashed with, uh, XML open [13:38.920 --> 13:47.700] tags, so the, the system was, uh, thinking that the XML file was some PHP, it broke because of [13:47.700 --> 13:53.740] some syntax error, and so just through internal server error, so, definitely didn't work. I [13:53.740 --> 14:02.420] decided to go and say, search, uh, other vulnerabilities. I found a pre-auth FC there, but it [14:02.420 --> 14:10.020] failed again for the exact same reason, so I cried a bit again. And I found something that was [14:10.720 --> 14:16.980] maybe interesting, but quite lame, I didn't see the impact at first. I found an XML injection in [14:16.980 --> 14:24.480] the log user database. Uh, so, pretty much the same, it's also, uh, PHP extension, uh, in the [14:24.480 --> 14:32.560] same directories. So, uh, the, the injection is on the user name, and that's like the database [14:32.560 --> 14:39.680] that contains, uh, if a user name is, uh, blocked by the system, so if you're trying to log in, uh, [14:39.680 --> 14:45.980] with a specific user name more than three times, and the login is failed, you're like injected in [14:45.980 --> 14:52.980] that, uh, specific database. So, there is a XML injection there. Okay. Not so useful, I can [14:52.980 --> 15:00.600] block up entire users maybe, but, yeah, quite lame. So, I did have a check on how, uh, the XML [15:00.600 --> 15:07.960] database are passed by the application, uh, I saw that, uh, the developers, uh, did that quite [15:07.960 --> 15:14.100] well. They decided to add some layers of protection, uh, trying to prevent, uh, X include by [15:14.100 --> 15:21.620] calling dumb document, uh, X include function with a false parameter. No luck for them, uh, [15:21.620 --> 15:28.860] thanks PHP, uh, it enabled X include instead, so definitely not what they wanted. Uh, so for [15:28.860 --> 15:35.020] those that don't know, X include is, uh, XML features that allow to include other XML or even [15:35.020 --> 15:41.360] not XML documents into the current one, so it's like, exactly like PHP include, but for XML. [15:44.100 --> 15:52.780] So, trying to put, uh, that username will definitely, uh, add a X include directive that will [15:52.780 --> 16:01.160] load, uh, the login logs database into the, uh, blocked users database. Uh, that's, that's a [16:01.160 --> 16:08.200] notation for X include directive, uh, that's a bit complicated, but, yeah, definitely the [16:08.200 --> 16:14.800] impact there is, like, we can just include the entire, uh, login logs database into the [16:14.800 --> 16:21.480] blocked user database. But, uh, yeah, X include is doing their best to, like, reformat all the [16:21.480 --> 16:28.140] file to be a fully valid XML. You can break, you can't really break, uh, the file by using X [16:28.140 --> 16:34.200] include, which is quite good, it's doing, like, automatic correction and things like that. But, [16:34.200 --> 16:39.140] no, that's still useless, I mean, yeah, I can include the database into another, but that's [16:39.140 --> 16:47.240] quite useless. But, I tried to see how the log users feature is working and I found a blind X [16:47.240 --> 16:54.660] pass injection, so, in the username is you, if you can, if you inject, uh, some X pass, uh, [16:54.660 --> 17:01.540] notation, you have, uh, an injection there. So, you can definitely extract the entire log, [17:01.540 --> 17:08.800] uh, log database and I guess you see, uh, what's the interest there. We can, uh, inject, uh, [17:08.800 --> 17:14.880] the content of, of the database, uh, in, in the log database and then we can, like, [17:14.880 --> 17:23.240] exfiltrate it. So, the log database, uh, yes, I, I, I, I would say that. But, uh, so we can [17:23.240 --> 17:29.520] choose a, a blind X pass injection, we can exfiltrate session token byte by a byte per [17:29.520 --> 17:37.300] bytes. That gave me, I mean, take around the application and that time in the admin panel [17:37.300 --> 17:46.480] there is, like, feature to get RC. So, this time is a win. It works remotely. So, the chain was [17:46.480 --> 17:53.100] log user with, uh, XM injection in the username with X include directive pointing to the XM [17:53.100 --> 18:02.980] logs. Exfiltrate it with X pass injection, get admin session, get RC and let, let's go for a [18:02.980 --> 18:17.530] demo. So, we can see there on the right that the blog database is empty. Now we try to log in [18:17.530 --> 18:25.450] with X, uh, to see that just the blog database is now filled with, uh, one entry for the X, uh, [18:26.150 --> 18:35.990] user. We now try to inject some XML to see if there is a XM injection there. And yes, it is. [18:35.990 --> 18:44.570] There is now a FUBAR attribute, uh, in the, in the block, uh, block entry. So, that time we're [18:44.570 --> 18:55.430] using the payloads that, uh, we saw before with the X include directive trying to include, uh, [18:58.590 --> 19:04.070] the login log. So, yeah, I just saw that the login log contains some, uh, session stuff there. [19:04.250 --> 19:12.870] So, we make that user with the payload to be blocked. We can see that to X include directive is [19:12.870 --> 19:19.290] now there in the file of the blocked, uh, database. We make, uh, another user, another random [19:19.290 --> 19:25.610] user to be blocked. So, the file will be passed again and this time there is like the entire [19:25.610 --> 19:33.270] login log database in that block database. So, this time it was completely replaced, uh, by the, [19:33.270 --> 19:40.370] by the original login logs file. So, now we can try to use, uh, the X pass injection. So, we are [19:40.370 --> 19:46.870] like targeting, uh, a log element, trying to infiltrate the session. We check here, we're [19:46.870 --> 19:54.510] checking if it begins by a L. We know it is because we can see that on the right screen. So, if [19:54.510 --> 20:02.170] it begins by a L, we should receive that the account is blocked. But if we check, uh, if it [20:02.170 --> 20:08.390] begins by X, we receive that no user is found. So, we have an hour to leak, uh, the characters [20:08.390 --> 20:16.210] one by one. So, I write a little script. And yeah, it definitely leaks the session token [20:16.210 --> 20:24.490] character by character. So, yeah, we got, we got an admin account to that and get RC remotely. [20:24.510 --> 20:35.950] For that, uh, Swisscom decided to pay me $3,000. So, uh, $2,500 for the bag, uh, $500 for the, um, [20:35.950 --> 20:44.230] for, uh, bonus for the nice shell. And also the editor decided to, uh, reward me for, with, uh, [20:44.230 --> 20:50.230] $2,000. They didn't have the bag money, but they were like impressed by the bag. So, pretty [20:50.230 --> 20:58.470] cool for the, for, from them. So, now let's switch to yet another customer, uh, another [20:58.470 --> 21:06.030] Swiss one, uh, so Swiss Post. I'm not sure I need to explain what is Swiss Post, but it's [21:06.030 --> 21:10.950] about, they are like the postal office in Switzerland, but they are also a private [21:10.950 --> 21:17.870] company, uh, doing a lot of different things and they are like involved in a lot of, uh, [21:17.870 --> 21:23.490] major projects in Switzerland like e-voting. Uh, they decide, uh, they, they are also very [21:23.490 --> 21:29.510] active in cyber security. They like about a lot of local, uh, cyber security, security [21:29.510 --> 21:35.410] companies. So, so they are like very active in the cyber security, uh, stuff in [21:35.410 --> 21:42.050] Switzerland. They decided to start, uh, bag bounty in 2019, uh, especially for their [21:42.310 --> 21:47.850] e-voting platform, uh, and they decided to add, uh, assets, uh, over time. So, uh, they [21:50.490 --> 21:57.610] are pretty good, pretty much the same as Swisscom to be honest. Uh, we can have a lot of, uh, [21:57.610 --> 22:02.510] communication with them, they are pretty good. And yeah, if some people are from the [22:02.510 --> 22:09.830] voting village, uh, go on their bag bounty programs, they are paying like, uh, 230K for a [22:09.830 --> 22:15.230] very critical bag there, that's definitely a good program. I'm not a crypto guy, so I'm not [22:15.230 --> 22:22.350] going back, maybe you are. So, if you want to have a check, uh, everything is described on [22:22.350 --> 22:33.810] their VDP page, so vdp.post.ch. So, uh, for, for the first bag, I will talk about their, uh, [22:33.810 --> 22:40.110] payment system, so they are like their own payment system, uh, completely custom, uh, [22:40.110 --> 22:45.270] everything is quite common, you get some sign requests, uh, there's a lot of different [22:45.270 --> 22:51.190] endpoints for failure and success, and, uh, also you can stack money on your account, on [22:51.190 --> 22:56.910] your postal account, you have a balance system, so it's always interesting if we can get, like, [22:56.910 --> 23:03.810] infinite money there. I will switch this bag because we have some time issue, let's go on [23:03.810 --> 23:11.930] the second one. So, I did find a lot of, uh, stuff there, so I was, uh, hacking on them, and I [23:11.930 --> 23:20.190] was trying to manipulate some payment session there, uh, changing price in a transaction, uh, [23:20.370 --> 23:26.250] a lot of things, but, uh, a delivery man rang the doorbell in my office, so I need to get the [23:26.250 --> 23:32.850] package, seeing everything, I decided that was the time for a coffee break, and then after [23:32.850 --> 23:39.790] maybe 10, 15 minutes, I don't know, got back to my chair, and I had some money coming from [23:39.790 --> 23:49.170] nowhere on my account, so I had no idea why. So, I decided to replay everything I did, I was [23:49.170 --> 23:56.430] like, probably I triggered something, and I didn't even know, so I tried to replay everything, [23:56.430 --> 24:03.010] so, that failed. No idea what happened. So, I did to replay everything, including the coffee [24:03.010 --> 24:12.230] break, that was maybe the main point, so I did a coffee break with a colleague, and there was my [24:12.230 --> 24:20.330] account was affected again. So, I was like, okay, what's the fact, I tested a lot of things, and [24:20.330 --> 24:26.410] the real explanation is, uh, when you run the transaction, after the transaction is [24:26.410 --> 24:33.470] timed out, so you didn't, uh, make the payment, uh, in the good time frame, it's just [24:33.470 --> 24:39.430] considered successful, so probably a bad check of payment states, it default to success [24:39.430 --> 24:51.190] instead of defaulting to, uh, a failure, so, yeah. Let's go for a demo. So, let's buy a very [24:51.190 --> 25:00.150] good croissant, because I'm French. Oh, that's not a good demo. I want a croissant, a bigger [25:00.150 --> 25:13.180] one. Let's go for it. Just wait. Just go grab a coffee, maybe. Are you patient enough? Oh, yeah. [25:15.360 --> 25:23.400] No, joking, it will just last. Yeah, success payments, just by waiting. I'm in pretty good [25:24.880 --> 25:32.280] solution to get some money, right? So, I was paid, uh, $3,000 for that, uh, that's probably the [25:32.280 --> 25:41.240] most I get for, like, a coffee break or two. Definitely was quite profitable, right? So, let's [25:41.240 --> 25:47.920] go to another project of them. Uh, they have, like, a subdomain, uh, using, uh, very, very [25:47.920 --> 25:56.160] unknown, uh, CMS. So, Peppershop, that's like a Swiss page PCMS. They also do some manager thing [25:56.160 --> 26:03.660] and things like that. I never heard of them. So, I decided, once again, to buy a license, uh, of [26:03.660 --> 26:12.700] the CMS, so I get access to the code. Once again, it's PHP, so I'm super interested by that. And I [26:12.700 --> 26:21.440] just had a look at the code, everything was quite, you know, PHP. Uh, so I saw that, uh, an [26:21.440 --> 26:30.160] admin feature, uh, that is quite interesting is a restart backup thing. Uh, it's some, like, [26:30.160 --> 26:37.040] custom things. They decided that the delimiter between SQL queries will be that stuff. No idea [26:37.040 --> 26:44.860] why. Why don't use, like, semicolon like everyone do? I don't know. They decided it is. And they [26:44.860 --> 26:51.540] also have, uh, some features I never, I don't know why, because I didn't see any occurrences [26:51.540 --> 26:59.180] where they are using that, but they do. So, if you use, uh, the base64 start and the base64 end [26:59.180 --> 27:07.020] tags, that will be replaced by a single coded string of, uh, the base64 decoded string that is [27:07.040 --> 27:15.840] between the tag. I don't know why. I, I, that's quite a strange feature to be honest. So, uh, the [27:15.840 --> 27:22.840] restart backup, uh, the restart, uh, feature is using, uh, backup from a local file system, uh, [27:22.840 --> 27:29.300] that needs to be generated from the CMS backup feature, so, uh, you can't upload anything or [27:29.300 --> 27:37.020] something like that. So, my goal was, maybe I can inject SQL queries in backup from the frontend, [27:37.040 --> 27:48.800] uh, the method is exploiting the very, like, strange passing to break SQL contexts. So, my idea [27:48.800 --> 27:57.480] is, uh, if I use, like, so specific, uh, separator or, uh, like, tags in some data, uh, that is [27:57.480 --> 28:03.340] stored in the database, uh, so, uh, that will be stored in the database, uh, maybe when they [28:03.340 --> 28:10.140] will backup and restart again, that will break something if I get some data with those tags, uh, [28:10.140 --> 28:15.920] maybe on my profile, on my, I don't know, username, name, other comments, uh, things like [28:15.920 --> 28:23.780] that. The first problem is, uh, most fields are sanitized by default. That's like a global [28:23.780 --> 28:32.700] sanitize, uh, sanitization that is done on every field. Um, so, no, no new lines, no hash, no [28:32.700 --> 28:40.940] special characters in general. Uh, the second problem is that if the restore fail on one SQL [28:40.940 --> 28:50.000] query, it's like ending the process and not going further in the file. I mean, for the first [28:50.000 --> 28:57.040] problem, the solution is quite easy. Most, uh, fields are sanitized but not all. They are like [28:57.040 --> 29:03.420] exception. One of them are like, uh, comments that are put on the other. So, I can definitely [29:04.000 --> 29:12.160] reach that field, uh, on the front end. And the second, uh, problem, we have like a separate [29:12.160 --> 29:19.520] between queries and way to inject single code. So, that should be possible, uh, to get like a [29:19.520 --> 29:29.660] valid file after injecting things. So, let's imagine, uh, uh, a valid SQL query in the file [29:29.660 --> 29:36.200] formats. So, we control fully the values of Bimmerkugen. I have no idea what it means but [29:36.200 --> 29:42.700] that's the name of the database, of the, uh, table. I have no idea what it is. So, we can [29:42.700 --> 29:48.620] control that fully and you can see the separator at the end. So, we're trying to use their [29:48.620 --> 29:56.480] base 64 feature to break from single codes. So, we're trying to get something like that. That will [29:56.480 --> 30:04.640] be transformed to that. So, we inject a single code, a parenthesis, a comment and that is working [30:04.640 --> 30:14.260] pretty well to be honest. So, then my goal is to inject new queries in the packet file. So, this [30:14.260 --> 30:23.240] time I'm also adding, uh, a separator and a new, uh, query with a comment at the end. So, after [30:23.240 --> 30:29.720] being, uh, uh, passed by the restore procedures that will give that. And that's definitely [30:29.720 --> 30:39.680] valid. So, I was able to, uh, just inject, uh, an update to, uh, an arbitrary table, changing [30:39.680 --> 30:49.520] arbitrary column there. Pretty good. Um, so, the impact is I can run arbitrary queries on the [30:49.520 --> 30:58.180] restore process. If they take a backup and restore, that will run my queries. Pretty good. But, uh, [30:58.180 --> 31:05.780] the database is obviously that PHP, uh, storing some serialized, uh, PHP objects because, you [31:05.780 --> 31:13.480] know, relational databases is done for that. Storing full objects. So, I found, uh, pretty [31:13.480 --> 31:20.900] fastly a custom gadget, uh, that allow to delete local files. Once again, not the most [31:20.900 --> 31:25.940] interesting primitive for us because that's definitely not a goal to delete, uh, files on [31:25.940 --> 31:34.320] them. But I saw that, uh, the admin authentication mechanism is just, uh, dot access file. So, [31:36.700 --> 31:44.700] if we delete the dot access file, uh, everyone can go to slash admin and, uh, I mean, just [31:44.700 --> 31:49.400] that. There is no authentication besides that. Such as, like, you need, as a valid [31:49.400 --> 31:55.860] credential or you need to pipe as a dot access. The payload is too big for the screen, I'm [31:55.860 --> 32:04.300] sorry. So, let's get a demo for this one. Once again, super classic. So, the payload is [32:04.320 --> 32:16.760] in shop. So, we put the payload, uh, in the other commands. You can see the payload there. [32:16.760 --> 32:23.520] It's pretty big. It's just, uh, trying to update the other table and set, uh, a big, uh, [32:23.520 --> 32:32.840] serialized, uh, object in the data of the others. So, now, my user have, uh, like another [32:32.840 --> 32:40.920] ways, uh, or, uh, or tags, uh, or by basics for tags. So, let's go to an administrator [32:40.920 --> 32:57.460] account. Let's do a backup. Yeah, that's a fail. Let's go to the backup. Let's log in. So, [32:57.460 --> 33:04.600] let's do a backup and now trying to restore it. Not, not, before restoring it, we can see [33:04.600 --> 33:10.940] in the other that, uh, we have, like, or data that is injected, uh, in the other. So, now, [33:10.940 --> 33:17.200] trying to restore. That's definitely not the same data. We were able to update the other and [33:17.200 --> 33:27.460] add, like, a serialized object. So, let's go see the others that triggered, uh, the serialized [33:27.460 --> 33:33.600] objects and now we can go to the admin panel and there's no more authentication on it. So, [33:33.600 --> 33:41.240] yeah, that definitely deleted, uh, the htaccess so everyone is admin which is, uh, to be [33:41.240 --> 33:49.840] honest a bit, uh, frightening because, like, by exporting that I gave everyone admin access. Oops. [33:50.480 --> 34:00.620] So, they pay me, uh, six and, six hundred fifty dollars which is quite bad but, uh, the real, uh, [34:00.620 --> 34:06.360] thing is that Swiss Post is not using the backup and restore feature because they have too much [34:06.360 --> 34:13.840] data and the official backup feature there is just crashing because there is too much data. You [34:13.840 --> 34:20.240] know, like, problem of memory issues and things like that. So, that's even fair they decided to [34:20.240 --> 34:24.980] pay a bounty for that because they are, like, no chance they are using the backup and restore [34:24.980 --> 34:34.640] feature. So, yeah, still quite firm. Let's go on another customer, the most known one, [34:34.640 --> 34:45.340] redacted. Uh, I wasn't able to name them so let's consider that, uh, we just put a bit of [34:45.340 --> 34:54.880] context. Imagine a PHP CMS, once again PHP, widely used, uh, with a lot of complex code, [34:54.880 --> 35:02.820] complex features, and a little blacklist criticizing the code at every release, every time. [35:03.760 --> 35:13.820] So, first bag, there is a new CV there, uh, that's a Prius SE to a SSTI in the wild, like [35:13.820 --> 35:22.240] used by a threat actor. So, the maintainers decided to make an emergency patch. I decided to [35:22.240 --> 35:29.960] reverse it, obviously. Uh, so, uh, there is like a double level of templating, uh, on the app. [35:30.320 --> 35:37.780] And the patch from, uh, the maintainers were just a plain replace to, uh, remove, uh, the tags [35:37.780 --> 35:46.580] just after a single evaluation of the templates. Uh, the problem is, maybe someone saw that? [35:48.140 --> 35:55.300] You saw that? I know. The regex is not matching new lines. Uh, that means that you can just [35:55.300 --> 36:01.820] use the original payload, but use a new line before the closing tags, you're bypassing that [36:01.820 --> 36:09.380] regex, and that's like a Prius SE again. That was paid, uh, ten thousand dollars, because, you [36:09.380 --> 36:16.560] know, Prius SE are always cool, and small bonus, my colleague, uh, also found another bypass, [36:16.580 --> 36:24.800] you just had to not close the tags. So, that was enough, uh, templates, uh, will contain some [36:24.800 --> 36:34.400] tags, ending tags later, so, yeah, that's also bypass it. So, as a second bag, and I'm sorry, [36:34.400 --> 36:42.460] this one will be quite complex, I will try my best to explain it, uh, correctly, but, yeah, [36:42.460 --> 36:51.340] that's a complex one. So, I found a bag, uh, that is, to be honest, barely exportable, but it's [36:51.340 --> 37:00.080] super fun technically. So, the worst impact, uh, to use was, uh, Prius SE, but, uh, the [37:00.080 --> 37:06.820] precondition of it make it quite unlikely, but, yeah, it's still a fun one. So, for the [37:06.820 --> 37:15.760] context, uh, that application, uh, was using Laminas PHP library to, for everything that is [37:15.760 --> 37:23.500] using, like, emails. Laminas is doing a lot of checks and transformation to be sure that the [37:23.500 --> 37:28.220] email is valid and things like that, there's like a lot of different label, uh, libraries [37:28.220 --> 37:35.200] there, and on the application we're testing, uh, we have, uh, control over, uh, from [37:35.200 --> 37:43.420] header that will be, uh, used for sending some emails. So, that parameter will be passed, uh, [37:43.420 --> 37:51.500] over the fifth argument of mail, for those who know, uh, mail function, uh, of a fifth [37:51.500 --> 37:58.800] argument that is, like, arguments that will be passed to the send mail, uh, binary. So, if [37:58.800 --> 38:03.440] that fifth argument is, uh, completely controlled by an attacker, you can have, like, [38:03.440 --> 38:10.160] argument injection to the send mail binary. There are, like, no next point to that, uh, but [38:10.160 --> 38:18.180] it definitely depends on the MTA that is used. So, uh, every MTA is chipped with different [38:18.180 --> 38:26.480] send mail binaries. So, for this, uh, talk, we will consider, uh, send mail MTA here. That's [38:26.480 --> 38:33.420] like a first condition. Why send mail? Because I'm cheating. That's my bug. I decide to [38:33.440 --> 38:44.240] whatever is the condition. So, that's what, uh, I want to be. So, uh, the problem is [38:44.240 --> 38:50.720] Laminas validating email address. We can't, like, put anything that is not a valid email [38:50.720 --> 38:57.020] address. Uh, Laminas is supporting, uh, cutted string, uh, format, so, uh, double quotes [38:57.020 --> 39:02.200] and pretty much anything. Uh, dot atom format, that's like the standard, uh, email [39:02.200 --> 39:09.340] formats. Uh, for that, they are using super big regrets. Uh, that was super hard to read. [39:10.820 --> 39:19.820] And, yeah, the thing is, uh, they're also using, uh, escape shell lag, uh, on the email [39:19.820 --> 39:29.660] before being used on the, uh, main function. But, uh, PHP is automatically applies escape [39:29.660 --> 39:35.060] shell command to the entire command, uh, when calling mail, uh, that will apply escape [39:35.060 --> 39:40.960] shell command to send mail. Uh, double escape means, uh, no escape at all, means argument [39:40.960 --> 39:50.340] injection, thanks PHP. So, another problem is, uh, Laminas or the application, I don't [39:50.340 --> 39:57.680] know, is, uh, lower casing your email and every exploit for, uh, send mail, uh, generally [39:57.680 --> 40:06.880] using, uh, the C and the X uppercase arguments with very long pass. And the, the problem [40:06.880 --> 40:13.340] is we are limited to 64 characters for the local parts and definitely if you need, like, [40:13.340 --> 40:18.740] long pass, uh, for two arguments, that's definitely not cool because we are, like, [40:18.740 --> 40:26.000] limited in size. Painful. I was, like, a bit in despair. I was pretty sure that won't be [40:26.000 --> 40:34.280] exploitable at all. But, yeah, I still decided to make, like, cause of testing. I was pretty [40:34.280 --> 40:42.080] much like that after a few hours. But, at some point, I saw that, uh, there was, like, a [40:42.080 --> 40:50.080] stranger if my email contains, uh, uh, right angle brackets. So, if I put XSX, uh, right [40:50.080 --> 40:55.820] angle bracket at black dot is, I received by the app invalid domain black dot is right [40:55.820 --> 41:00.300] bracket. I was, like, that's, that's strange. That's definitely not the domain I put in my [41:00.300 --> 41:07.900] mail. So, I decided to debug a bit the behavior. So, Laminas, uh, did, uh, the validation of [41:07.900 --> 41:14.320] the email. Laminas and the app, uh, were crafting a full email with the headers and the body [41:14.770 --> 41:22.500] and put the email in the form, uh, header. Then, uh, Laminas passed the generated email. [41:22.500 --> 41:30.820] Then, the app is extracting the sender again from it. Validates that it's still a valid email. [41:30.920 --> 41:39.420] So, painful process. So, I was like, okay, but that doesn't explain the error. So, that's a [41:39.420 --> 41:45.900] traditional form header. So, it's just, uh, double quotes your name, double quotes and in [41:45.900 --> 41:52.480] brackets, uh, the full email. But, when I tried to inject XSX right brackets at black dot [41:52.500 --> 41:59.700] S, that was like the form that was generated. So, we have like an injection in the email part, [41:59.700 --> 42:07.600] but that's quite useless in my opinion. Uh, there was like no CRLs, there was like protection [42:08.260 --> 42:14.180] and mechanism to prevent that. So, I was like, okay, that's definitely useless. But, I [42:14.180 --> 42:22.340] decided to like investigate because that's quite a dirty thing still. So, yeah. Uh, we [42:22.500 --> 42:29.220] received, uh, a lot of RFC, a lot of documentation and I saw there's like something called, uh, [42:29.220 --> 42:38.160] my man coded words. So, uh, that's described by the, uh, the RFC 2047. That's for using [42:38.160 --> 42:52.280] special characters in, uh, email headers and body. That's a format, so, uh, it was seen, uh, [42:56.780 --> 43:07.660] so, in that case, I'd like generate AAA. So, all the characters that is used, uh, in the [43:07.660 --> 43:14.140] mime uncoded words notation are also valid characters in an email address. At least, uh, [43:14.140 --> 43:21.940] in the double, uh, double code encoded formats. So, I was like, maybe I can inject mime [43:21.940 --> 43:29.520] uncoded words in my, uh, sender email. So, uh, that will be put in the mail headers and when [43:29.520 --> 43:36.360] extracting back by Laminas, it will like pass the mime uncoded words and generate an email that [43:36.360 --> 43:44.900] will maybe contain, uh, some, uh, parameter injection to send mail. So, uh, I needed, uh, [43:44.900 --> 43:51.920] some spaces to like inject another argument to send mail. Uh, but, uh, equal, uh, equal [43:51.940 --> 43:57.760] 20 is forbidden by the specification of the AFC, but I found that, uh, underscore is [43:57.760 --> 44:04.680] defined as a space by the AFC. So, we can, uh, just input, uh, spaces by using an [44:04.680 --> 44:12.560] underscore. Don't ask me why, there's probably a reason for that. So, as we saw, uh, the [44:12.560 --> 44:19.840] send mail, uh, send mail payload is always, uh, needing to point to a local configuration [44:19.840 --> 44:27.200] file. So, we need to have, uh, a control of a malicious local file. Fortunately for us, the [44:27.200 --> 44:33.520] CMS have, uh, a nice file upload. So, we can upload files there. The problem is, uh, the [44:33.520 --> 44:39.240] upload file that contains underscore, but underscore replaced by spaces, but we can [44:39.240 --> 44:47.060] replace, uh, underscore by, uh, equal five F characters. So, that's a problem, but not [44:47.060 --> 44:53.220] so much. The problem is, uh, we need a lot of replacement character and the size [44:53.220 --> 44:59.520] limitation is still 64 characters and the mime encoded routes, uh, increase the size of a [44:59.520 --> 45:08.320] string by quite a lot. So, let's consider that, uh, a web route is, uh, slash app. That's [45:08.320 --> 45:15.060] short. That's definitely what I need. So, I'm still, uh, cheating again. So, uh, that's [45:15.060 --> 45:22.080] another preconditions. The first one is you need send mail to be used and you need, uh, a [45:22.080 --> 45:30.500] short, uh, web route. So, yeah, that's quite some strong precondition. So, I knew that send [45:30.500 --> 45:36.940] mail payload that I am using, uh, the C and the X, uh, arguments. That's definitely too [45:36.940 --> 45:43.400] long for us. So, I was like, okay, uh, the C arguments is, uh, loading arbitrary config [45:43.400 --> 45:50.380] file. Maybe that's enough to see. Maybe we don't need, uh, uh, X arguments. So, I decided to [45:50.380 --> 45:57.160] focus on that and see what is possible to, uh, send a config file. So, in the config file you [45:57.160 --> 46:02.880] have, like, the path to the dead letter file. So, the dead letter is like where it, with, it [46:02.880 --> 46:11.180] will log, uh, like, incidents in sending emails. So, maybe we can, like, uh, that's, uh, a [46:11.180 --> 46:17.120] file that will be in the web routes and I have maybe a file right but we don't control [46:17.120 --> 46:24.760] anything in the mail. And there is also, uh, uh, bound second recipient in that config file [46:24.760 --> 46:30.300] that will be included in the dead letter because that will, like, you have an email that is [46:30.300 --> 46:35.500] failed but then it will try to send to that second recipient and it will write that in the [46:35.500 --> 46:42.140] dead letter file. So, maybe we can have arbitrary file rights or at least, uh, partial [46:42.140 --> 46:49.980] arbitrary file right but that's PHP so if I have just, uh, a partial file right that would be [46:49.980 --> 47:00.260] enough to get a valid PHP file. So, I just sent, uh, a default send mail MTA config and, uh, the [47:00.260 --> 47:06.700] two, uh, option, uh, to get arbitrary file right and that's, that was sufficient. So, then I'm [47:06.700 --> 47:13.700] sending the mail to not existent at localhost so it fails. So, that will bounce. So, that, uh, [47:13.700 --> 47:22.780] the, the, the config that I was using. So, I decided to have a look at the MyMainCodedWord and [47:22.780 --> 47:30.240] trying to, like, reduce the size of it. Uh, I was able to win some size like you can just empty [47:30.260 --> 47:37.420] the car sets. There is no need of, uh, filling it. Uh, don't, uh, we get, we need double cuts [47:37.420 --> 47:42.980] around the payloads because, uh, the email need to be valid and you need to use a double [47:42.980 --> 47:50.480] coded, uh, format. Don't ask me why but we need, we needed to end it with, uh, two double [47:50.480 --> 47:57.660] cuts. I have no idea that's magic. I didn't investigate it that. So, we can definitely use [47:57.660 --> 48:05.640] the uppercase later now because we have the MyMainCodedWords. Uh, so, 64 cards is still too [48:05.640 --> 48:13.180] short but with the precondition of having a short web root and everything that just enter [48:13.180 --> 48:22.820] exactly, uh, the, the 64 characters. So, it's, uh, upper class and the final payload was [48:23.200 --> 48:31.560] just that. Don't ask me why that's a magic, uh, definitely some magic payload. I have now a [48:31.560 --> 48:38.620] t-shirt but it's my, in my hotel room with a payload printed on it. Uh, yeah, that's quite a [48:38.620 --> 48:47.240] unisex payload and it is to Prius SE on the top in very specific conditions. So, yeah, that [48:47.240 --> 48:52.720] was just, uh, settings, uh, if I re-uploaded in to send my command injecting a new, uh, [48:52.720 --> 49:01.020] config file for send mail, get arbitrary rights, some PHP in the web app, get RCE, works [49:01.020 --> 49:08.820] only on send mail MTA, web root being short so I cheated a bit. But, yeah, you need some [49:08.820 --> 49:13.660] Einstein's to explain that. So, definitely not, uh, not really a spot up in the right but [49:13.660 --> 49:22.700] still was quite fun technically. So, let's go for a demo. The last one. Uh, so, uh, [49:23.520 --> 49:36.000] once again, the question shop. I'm just uploading, uh, the send mail MTA default config [49:36.000 --> 49:47.340] file with just like or do two config keys. Yeah, doing the upload manually, sorry, it takes a [49:47.340 --> 49:59.340] bit of time. So, yeah, you can see that I'm putting the dead letter in the slash app slash [49:59.340 --> 50:07.520] back dot dot PHP with a double bounce address containing a payload. So, yeah, now the config [50:07.520 --> 50:16.460] file is uploaded. We can just run the payload in the from, uh, in the from email. That's [50:16.460 --> 50:23.060] exactly the payload from the, the slides. We're sending that to, uh, a local host address [50:23.060 --> 50:27.360] that doesn't exist. So, that should draw, draw an error. We see that the page is [50:27.360 --> 50:34.380] completed bank because that generated an error. So, now we can go to, uh, the slash back [50:34.380 --> 50:42.260] dot dot PHP. We can see the dead letter there and I did add some back dot there and we get [50:42.260 --> 50:52.940] arbitrary PHP, uh, execution. So, definitely quite cool. So, that was paid 5,000, uh, [50:52.940 --> 51:00.960] dollars despite the fact that it was, uh, hardly exploitable. Uh, made me cry a bit. I [51:00.960 --> 51:08.820] spent a lot of time on it. So, I hope your brain fried exactly, uh, like me. And that's my [51:08.820 --> 51:13.740] end word. So, uh, thanks for having listened to the end. Hope you had fun. Hope you [51:13.740 --> 51:21.060] learned some things. And also I will maybe soon open a blog, uh, a blog with a lot of my [51:21.060 --> 51:27.800] bags, like a hundred of them. So, yeah, follow me on Twitter if you want some news and thank [51:27.800 --> 51:28.400] you.