start	end	text
0	900	Hello, everyone.
900	3060	Thanks for being here.
3060	8420	It's actually pretty cool, because Sunday talks are a bit of a catch-22.
9540	15160	Because on one hand, we are not jet-lagged anymore, which is great.
15160	20680	On the other hand, we're all exhausted from all the hacking and partying that's been going on these days.
20860	22140	Which is terrible.
22400	27580	But still, I'm very, very happy to be here and to see so many of you.
27680	31140	This talk is Smart Devices, Dumb Resets.
31140	53540	And it will be a fairly short session about some of my experiments with various retailers and how they approach resetting devices before reselling them as repackaged, pre-owned, or whatever other term they use for labeling stuff that's been, well, used and returned.
53580	58120	The ones that really, really make me giggle is pre-loved.
58320	64260	And I really hope that whoever used my robot vacuum before me didn't use it for love.
65580	66420	Okay.
66420	67960	Just a quick disclaimer.
67960	70960	In this talk, I will not mention any retailers.
71120	75980	My aim here is not to point fingers, but to inform and to entertain.
75980	84900	So, any information which may indicate a potential retailer or vendor is purely coincidental and only used to make a point.
86020	89800	So, before we jump into the fun stuff, let me introduce myself.
89800	98500	I am Matej Anthony-Josephs, a senior penetration tester at HappeningXYZ, where I work with a really cool team of hackers.
99500	101620	I'm a junior husband.
101720	105340	Or does three years of marriage promote me to mid-level?
105760	107040	I don't know.
107040	114300	Anyway, I'm also the founder of Hive Hack, a boutique cybersecurity company built alongside my wife.
114600	117420	And generally speaking, I just love hacking stuff.
117420	121740	Websites, people, devices, pretty much everything.
121840	129640	And I'm not a hardware hacking expert whatsoever, but I enjoy the potential impact of IoT hacking.
130020	139100	The idea that actions done in a virtual environment can have an impact in the physical environment fascinates me to this day.
140060	147800	So, I remember how one time I was at a conference and found that the self-service check-in tablets were not properly configured.
148000	154060	I escaped the kiosk mode pretty easily and went on to discover that the tablet was running Windows.
154720	159620	So, I found the Wi-Fi password and connected my own device to the network.
159620	169960	And after a quick network scan, I found several devices with HTTP and HTTPS ports open.
170600	171900	And guess what those were?
171900	174260	Those were the badge printers.
175340	179740	But they were password protected, so there was nothing I could do about it, right?
180340	182580	Well, yeah, that's wrong.
182980	183760	Well, guess what?
183760	185540	They were using default credentials.
185540	188080	Something as simple as admin, admin.
188720	192480	So, next thing you know, I was printing my own custom badge.
192680	195160	And there were several levels of failure here.
195600	198460	Firstly, the kiosk mode was not properly configured.
198840	204400	Secondly, the tablets were in the same network as the network printers, well, the badge printers.
204400	208260	And thirdly, the web portal of the printers was using default credentials.
208660	212480	Perhaps lastly, no one was attending the tablets.
212480	214300	No one was there to stop me.
214440	223140	Actually, one of the volunteers who was confused about the badge not looking like all the others handed it over to me without asking any questions.
223900	229180	So, this was a full exploitation chain of people, processes, and technology.
229280	236240	And while I absolutely love web application hacking, you don't typically end up with souvenirs from web apps.
236240	238540	Whereas with IoT, you sometimes may.
238540	241840	Like the custom badge which you can see in the picture.
243020	244060	Right.
244060	245800	So a bit of context here.
245800	251120	The idea behind this talk came about seven years ago when I was a broke student.
251320	254180	I used to live two minutes away from the beach.
254460	257660	And I decided to order an inflatable kayak.
257660	261820	It was $150, which was a lot of money for me back then.
261840	265820	So I used it for a week and even lent it to some friends to use it.
265820	271000	But one day, well, it started deflating.
271880	273060	It was punctured.
273060	274820	So I decided to send it back.
275140	279500	And to be honest, I'm not going to lie, I was a bit concerned that they will not accept it.
279500	281400	It was obviously used.
281480	283320	It still had sand in it.
283500	285000	It was packaged horribly.
285860	289900	But a few days later, I was pleasantly surprised to see that I got a refund.
290360	292340	So this got my gears spinning.
292400	299680	I thought, wow, I can really borrow things as long as I use their full price as a deposit.
300260	306960	Actually, a few days later, I noticed that the kayak was reposted as pre-owned for cheaper.
307080	315780	I did not do this, but in theory, one could have bought the item, returned it, and then buy it again from a different account for a bit of a discount.
316520	322040	So I recently asked ChatGPT if this would be considered fraud.
322380	325600	And by the way, don't take legal advice from ChatGPT.
325780	327520	But here's what it said.
327820	342400	This is not fraudulent if you are operating in the return policy, if the price drop is legitimate, so you're not actually getting involved in any sort of savvy shopping.
343620	352000	However, it is potentially fraudulent or unethical if you are trying to game the system or force a price drop.
352000	357340	So long story short, you should not abuse these return policies to get price drops.
357480	362120	But you may be wondering now, where does IoT actually come into play here?
362120	366400	Because we've been talking for five minutes and haven't touched upon IoT yet.
366400	367800	Well, bear with me.
367800	376060	Last year at DEF CON 32, Andrew Bellini delivered a brilliant, beginner-friendly talk about hacking IoT devices.
376120	380200	So I decided to start playing around with some hardware hacking.
380720	384020	And this is when the idea became reality.
384220	392900	Also, Michael Coppola had a great presentation at DEF CON 20 about backdooring stock firmware images for consumer routers.
393260	400420	He even shared a tool he developed, the Router Post-Exploitation Framework, RPEF for short.
400420	405500	Unfortunately, the last commit to that project was in 2013.
405780	409340	So it would be great if someone could revive it.
409440	416100	I also took a lot of inspiration from Matt Brown, who always puts some great hardware hacking content on YouTube.
416480	421200	Also, Dennis Giesa had some great talks at DEF CON in the past few years.
421220	426560	One of my favorite ones being about hacking vacuum robots.
427540	436600	Now, there are many great researchers in the IoT hacking space, and I'm sure you got the chance to meet some of them in these past few days.
437020	442180	So, for this research, I formulated the following hypothesis.
442440	448780	Retailers do not implement enough checks to prevent reselling backdoored devices.
449400	454020	And to verify this, I defined a simple methodology.
454140	459300	First, I'd have to identify devices with firmware which can be overwritten.
459640	470720	Then, I should order those devices, modify their firmware, return them with the modified firmware, and wait for the devices to be resold as pre-owned.
470720	476580	And of course, buy them again to ensure that the firmware modification was persistent.
477080	481660	And the last step is actually the most important one here.
481720	485440	As I do not want my backdoor to spread in the wild.
485760	494440	And to do this, I created a simple web scraper which notified me on Discord every time a device from my list became available as pre-owned.
495040	499700	This way, I could order it immediately, as soon as it was posted.
500080	511620	Moreover, to reduce the risk of any negative impact if I failed to buy the device again, my backdoor was very, very simple and only worked as a proof of concept.
511860	525280	So instead of implementing a full agent, which is communicating with my C2 server, I just created a mechanism whereby a simple request is being made to an EC2 instance owned by me.
525280	526360	Nothing more.
526360	534820	So if the device is plugged in and connected to the internet, all it does is make a simple GET request to my HTTP server.
535060	536500	Simple, right?
538900	543820	So... well, the specific device used for this research is less important.
544260	549500	However, I'll give you enough information to find similar devices yourselves.
550140	555740	In theory, almost all OpenVRT compatible routers can be used for this.
555840	563800	And that is because people have actively installed the OpenVRT firmware on them, and the process is very well documented.
563880	569960	So it is known that these devices support other firmware than the original one, right?
571760	576840	Now people have been looking at updating IoT firmware for ages.
576980	588560	This may be either because they do not trust the vendors with their data, or just because they're not happy with the performance or the customization options for the devices.
588560	595920	So for instance, devices such as vacuum cleaning robots may expose sensitive information about the users.
596780	604180	You could probably get an idea of the structure of the person's home, maybe get an idea of where they live.
604640	617200	Now I'm not sure if this is a feature or a bug, considering that we know that in 2018, the Strava fitness tracking app was used to expose hidden military bases in Afghanistan.
617790	628420	In any case, there are several communities for people who want to create custom firmware for IoT devices.
629280	639520	Now, you can join those communities and easily find hundreds, if not maybe thousands, of good candidates for this type of research.
639780	645640	So for me, one of the most important aspects was that the devices must be cheap.
646000	654100	I expected to break several of them during this research, so I didn't really want to break the bank through it.
654100	663280	Moreover, based on my experience, suppliers of cheap IoT devices typically don't invest too much in security.
663820	676740	Now this may be a misconception, however, because cheap devices are more widely used and tested by users, whereas expensive devices may actually have less real-world security testing.
677260	684660	In any case, I picked up several TP-Link routers, everyone's favorite IoT hacking beginner-friendly devices.
685980	697880	And I ordered them from several reputable retailers, and the reason for this is that I was confident that I could override the firmware, but I expected each retailer to act differently.
698080	703580	So I bought 15 devices from 5 different retailers, 3 from each.
704400	708800	So I attempted a few different techniques for updating the firmware.
708800	715860	First, I opened up, physically opened up one of the devices, and pulled the firmware using SPI.
715860	722600	And in theory, opening up the device would break the seal, preventing the device from being resold.
723000	725280	And, well, we'll see about that.
725360	730940	With the firmware downloaded, I used Binwalk to check out the file system.
730980	738560	So I configured a service to run every 10 minutes and make a request to my IP address with a specific identifier.
739960	744340	Moreover, I added a self-destruct in this service.
744340	749500	So after 3,000 requests, the service was disabled and the script was deleted.
749700	755260	So in theory, after about 21 days of running, the device would return to its initial state.
756300	763840	And here you can actually see a few of my prior experiments, trying to change the TP-Link logo to my own.
765560	770760	So with the modifications, I recreated the binary using MakeSquashFS.
770760	785160	And as you can see in the screenshot in the middle, or maybe you can't because the text is quite small, there was an initial discrepancy between the compression used for the original firmware and the modified one.
785400	791120	The initial firmware was XZ-compressed, whereas my one was ZLib-compressed.
791120	798360	So for this reason, it is important to run MakeSquashFS with the compression flag set to the desired method.
798380	807760	This would prevent any sort of issues which may come further down the road when the firmware is not actually too close to the initial one.
809200	821320	So now in terms of writing the firmware, one can either use SPI to flash the memory, or the web interface potentially, to upload new firmware.
821640	828840	So if you're lucky, you can go straight through the web interface, meaning that you could even conduct this attack remotely.
829640	838060	On some devices, the web interface may check for various signatures, and in that case SPI is most likely the way to go.
838460	845940	And as you can see in the screenshot on the right, I was unable to upload the firmware via the web interface.
846240	849240	Well, it's actually the left, but your right.
850580	867400	So I tried to write the firmware using SPI, and as my IoT hacking setup is rudimentary, to say the least, overwriting the firmware using SPI actually required very steady hands, which unfortunately I don't possess.
867560	872140	And this was frustrating, and I really thought of pivoting to a different device.
872140	875840	And this was all until I found a little workaround.
876780	891120	TFTP, the Trivial File Transfer Protocol, which some devices use for recovery purposes, so where they query a TFTP server on a predefined local IP looking for a specific firmware file.
891720	903660	So my tests seemed to work fine, and in the end, despite pressing and holding the reset button, only configurations were being removed, but my custom backdoored firmware remained.
905060	908860	So now was the time to try and return these devices.
908860	915400	And I mentioned that I changed my mind, I don't need them any longer, and that I was actually looking for different devices.
916180	918940	And this was only one week after ordering.
919400	926940	So a courier came up to pick up the hardware, and within another week, I received my money back.
926940	927840	Great.
927880	930420	No comments, no additional questions asked.
930540	933580	Not even for the device which I opened up.
934240	939100	So none of them have yet connected to my C2 IP up to this point.
939180	948980	So it either means that the technical teams did not check the devices at all, or perhaps that they checked them offline, without connecting them to the internet.
949400	955840	Basically they probably just plugged the devices in, the LEDs blinked, and they thought okay, fair enough, they work.
957320	959660	Right, so now what?
959920	967580	To be honest, I was expecting to get some sort of callback from the devices in the retailer's network.
967700	970900	And this would have proven some interesting impact.
971040	975020	Potentially getting a backdoor within the internal network of retailers.
975240	977860	But this was not the case, unfortunately.
978620	984900	With my scraper constantly running, I was waiting to see if the items were being resold.
984900	989020	And at some point I thought that they will just end up in a landfill.
989580	992960	But a few days later, I got a notification.
993300	996080	And another few days later, another one.
996520	1001020	So all tested retailers have reposted the devices as repackaged.
1001120	1003160	And I tried to buy them all back.
1003800	1009100	Well, out of the 15 devices I was only able to buy 13 back.
1009100	1012820	Two of them were sold to someone else who was quicker than me.
1013200	1017980	So you can see the resealed tape on the outer edges of the box.
1018400	1022640	And you can probably also see that it says personalized security on the box.
1022640	1024180	Well, of course it does.
1025440	1034000	And yes, I got a callback from all 15 devices, even the two which were actively used and which I was unable to get.
1034360	1039780	And almost a month later, I stopped getting callbacks from the two devices.
1039800	1044940	And this is most likely thanks to the self-destruct script which I set up.
1045280	1051180	Actually, it's maybe more of a self-restore script because it actually brings the devices back to normal.
1051940	1062240	Okay, so going back to the hypothesis that retailers did not implement enough checks to prevent reselling backdoor devices, I can strongly confirm that that is the case.
1062300	1066960	Or at least it certainly was the case for the five retailers which I tested.
1067500	1082080	So not only did they resell the devices, but they also did not properly check for the functionalities which was obviously the case as I did not get any requests in my C2 server before they were resold.
1082420	1091720	So even if they were to check the functionalities of the devices, they would have worked perfectly and probably they would have been resold anyway.
1092340	1094540	But let's talk about impact here.
1094540	1100380	I only tested this on routers, but it can be done on almost any type of IoT devices.
1100580	1108800	Instead of a simple script which sends a simple request to an IP address, a full-scale backdoor could be set up.
1109280	1120020	Or maybe you could set up a botnet using each router as a proxy for your attacks so you would have access to several clean residential IP addresses for your attacks.
1120820	1131280	At DEFCON 31, Dennis Giese talked about vacuum robots and even showed a proof of concept of how the camera can be used to transmit visual information.
1131780	1140060	Now think about this, returning a vacuum cleaning robot after modifying the firmware to provide a live feed from the camera.
1140640	1143720	You could actually see what's going on inside someone's house.
1143720	1148760	And I say house here because regular people would be the ones typically buying repackaged devices.
1148760	1157380	But who knows, maybe the facility manager at the office thought that they can save the company a bit of money by buying a repackaged vacuum robot.
1157660	1161340	Great, now you could potentially see inside some offices.
1161680	1168460	Or even worse, the attacker could see that you haven't vacuumed in five weeks and decide to start a cleaning cycle for you out of pity.
1169660	1172900	Well, surveillance cameras are a great example as well.
1172900	1178360	Interesting case, we often see live feeds on Shodan from people's homes.
1178560	1184380	The default configuration should be that the camera is not publicly accessible, right?
1184620	1190340	But how about modifying the firmware to make the feed public regardless of this configuration?
1191020	1198060	You can repeat this on pretty much any type of IoT device, washing machines, air conditioning units, you name it.
1198880	1201090	But is this attack critical?
1202030	1204270	Well, I honestly don't think so.
1204270	1213710	And while most of this talk, I showed the shortcomings of retailers, they do have pretty well funded fraud prevention teams.
1213710	1218090	So it's unlikely that this attack could be done at scale in this context.
1218370	1225370	So think about it this way, you just bought 500 devices, updated the firmware and decided to return them.
1225450	1231250	Well, it's unlikely that they will be as passive as they were with my 15 devices.
1232390	1235650	Thus, it could be quite difficult to do this attack at scale.
1235770	1240710	And I would argue that it is even more difficult to do this attack in a targeted manner.
1240710	1247770	So I mean, how could you coerce someone into buying that specific device which you modify the firmware of?
1248270	1253430	And while it may seem that this talk was mostly about bashing retailers, that's not the case.
1253430	1255090	It's not their fault here.
1255090	1264750	If you overwrite the original firmware, while maintaining the expected functionalities, I guarantee that no one will notice.
1265090	1274490	I would even go even further to say that if we take retailers out of this completely, the severity of this attack vector increases.
1274750	1281270	Think about it this way, you are a threat actor, and you open your own online store.
1281270	1288370	You build it up over a few months, invest in advertising, and you sell products below market value.
1288570	1294850	At a price low enough that it's a great deal, but high enough that it doesn't raise any suspicions.
1296630	1304490	You buy thousands of devices from a reputable vendor, modify the firmware, package them nicely, and sell them.
1304590	1312010	And as you sell them, you have information about the buyers, like their names, their addresses, in some cases the company name.
1313290	1316330	So here, the attack could be done at scale.
1316570	1325570	It could also be targeted, so you can only activate the backdoor if the device is being bought by someone specifically.
1326550	1332370	So in terms of solutions, I think that the only sustainable solution here is going open source.
1332370	1341130	And this may seem counterintuitive, to be honest, because devices which support open source firmware can have their firmware overwritten.
1343760	1355980	But if it becomes common practice for devices to come blank, and the users to write their own firmware on every device, it will become harder for such an attack vector to be successful.
1356120	1359780	However, the obvious downside here is usability.
1360240	1366420	IoT products would not be plug and play, and the technical level of the users would have to increase significantly.
1366580	1375600	Actually, just wanted to check, how many of you here have proactively updated the firmware or on any of your IoT devices?
1376520	1379140	Okay, maybe a bit over half.
1379140	1392020	And well, when I say proactively, I don't mean because you got a notification that you must update it, but just because you went to the vendor's site and thought, oh, look, there's a new version, I should install it.
1392120	1396560	And think about it this way, we're all security people here, or most of us.
1396740	1399000	How about the regular consumers?
1400320	1407020	So no, there's no way right now to make people install their own firmware on blank IoT devices.
1407020	1421400	But don't worry, there are still some technical solutions like locking the bootloader, signing the firmware, implementing secure boot, and potentially encrypting the firmware.
1421400	1430360	But still, even with these in place, there are some fantastic researchers out here who found workarounds and ways to break most of these solutions.
1430440	1434240	Some of them have even presented their research here at DEF CON these days.
1435080	1448860	So besides technical solutions, one could consider things like tamper-evident seals, tamper-proof screws, one-way plastic clips, and of course, it goes without saying, even these are insufficient.
1448980	1455460	Actually, people at the tamper-evident village at DEF CON have actively showed how to bypass these measures.
1456080	1462060	And as you can probably tell, temporary solutions are not aligned with the open source approach.
1462060	1480660	At the end of the day, there will always be a clash between open and closed source, where most IoT vendors will want to push their own firmware and prevent the possibility of overwriting it, while the open source community will typically look for workarounds and solutions because they do not trust these vendors.
1481200	1484460	So, what can we actually do?
1485020	1496880	If you want to avoid falling victim to this, I would suggest avoiding buying repackaged devices, or even new ones, from vendors or retailers which are not reputable.
1497660	1501680	Well, this does not really protect you if you are targeted.
1501680	1514240	As far back as 2010, it has been alleged that the NSA's Tailored Access Operation Unit intercepted shipping deliveries to plant back doors in electronic devices ordered by their targets.
1514960	1515880	So what can you do?
1515880	1517600	Not buy IoT devices?
1517600	1518840	Live off the grid?
1518840	1522380	Now that's not realistic for 90% of us, right?
1522480	1528660	For non-technical people, I would say that not everything needs to be connected to the internet.
1529000	1535240	Yes, IoT is about convenience, but now it's just becoming a bit too much.
1536280	1544240	Also, perhaps stick to reputable vendors, as it's more likely that they are running mature security programs.
1544260	1552720	And for the technical people in this room, I encourage you to engage in IoT bug bounty and vulnerability disclosure programs.
1552960	1558200	And if you identify that firmware can be overwritten on devices, report it.
1558200	1566880	And I'm aware that many programs specifically mention that these attacks, which require physical access, are out of scope.
1567020	1575620	But I would argue, based on this little talk which I just delivered, that vulnerabilities requiring physical access should also be in scope.
1576680	1589880	At the end of the day, the more the suppliers of IoT devices are made aware of this potential attack vector, the more likely they are to fix it in the future.
1589900	1591440	Thank you.
1597070	1597630	Cool.
1597630	1599590	Maybe we've got a minute or two for questions.
1599590	1600510	Yes, please.
1610390	1616090	So you're asking if buying directly from the manufacturer would be a better option?
1617030	1617930	Yeah, for sure.
1617930	1618510	Without a doubt.
1618510	1620870	That would prevent this specific attack vector.
1620870	1623150	However, the devices may still be vulnerable.
1623150	1623650	So who knows?
1623650	1625830	Maybe people can resell them on.
1625830	1632330	I think that the issue here is not necessarily the fact that retailers resell these devices.
1632410	1636730	It's just that anyone can overwrite the firmware on many of these.
1637390	1637990	Cool.
1637990	1638910	Yes, please.
1650530	1653590	Yeah, that was pretty straightforward.
1653710	1657310	So in this case, the firmware was completely unobfuscated, unencrypted.
1657310	1658850	So just use binwalk.
1659930	1663130	Oh, yeah, just SPI.
1663130	1664710	So reading it with SPI.
1664710	1668090	But funnily enough, with TP-Link, they also post their firmware online.
1668090	1669630	So it's publicly available.
1670770	1676590	So I only took the file system.
1676590	1678950	That was the only part that actually interested me there.
1679650	1680750	Yes, exactly.
1680750	1686350	So I found the SquashFS file system there, took that out, and used it directly.
1686790	1687090	Cool.
1687090	1687950	There was another question.
1687950	1688670	One more question.
1688670	1689210	Yeah.
1725100	1726000	That's pretty cool.
1726000	1727220	I promised it was not me.
1729120	1729900	Thank you, guys.
1729900	1730480	Thank you.
