How to protect QSPI Flash?? - Page 1
Forum section: electronics / general

author: jtronix
author_rank: Regular Contributor
timestamp: February 19, 2016, 05:07:45 am
content: Hello,In my system, microprocessor is directly interface to QSPI Flash.During power on uP execute from QSPI flash and it copies all data to RAM then it executes from RAM.But all data and code are pleaced in QSPI Flash and is not protected so anyone can copy the entire flash and they can make the duplicate product. I want to protect code sector for reading like happen in microcontroller flash protection.QSPI Flash P/N: S25FL128uP: Renesas RZ A1H

author: ataradov
author_rank: Super Contributor
timestamp: February 19, 2016, 05:22:26 am
content: I know noting about Renesas MCUs, but typically QSPI interface supports scrambling just for that reason.In any event, unless you have a way to securely store a decryption key inside the device, then there is not much you can do.

author: ataradov
author_rank: Super Contributor
timestamp: February 19, 2016, 05:34:16 am
content: Well, I downloaded the DS out of curiosity. It looks like no though of security went into the design of that device.It looks like it is impossible to reliably protect your firmware.

author: AndyC_772
author_rank: Super Contributor
timestamp: February 19, 2016, 07:54:31 am
content: How interesting or difficult to re-invent is your product?Is the code you're looking to protect difficult to simply re-write from scratch?You could encrypt your Flash using a key that's stored in the MCU, provided the MCU has some internal storage that can be blocked from external read access by a debugger. You could spend a lot of time and effort researching available algorithms, code, licences, and best practice in implementation of security systems.Or, you could invest the time and effort into marketing, selling and supporting your product, which might have a much greater commercial benefit than protecting firmware that could - even if your security is effective - be "cloned" by re-writing from scratch.

author: ataradov
author_rank: Super Contributor
timestamp: February 19, 2016, 08:00:25 am
content: Quote from: AndyC_772 on February 19, 2016, 07:54:31 amIt does not. That MCU lacks any non-volatile storage or security features.It is also a Cortex-A9, so "re-writing from scratch" may be hard. Especially given that there is no way to protect the firmware in a first place.

author: tszaboo
author_rank: Super Contributor
timestamp: February 19, 2016, 11:31:39 am
content: I guess the proper way of doing it is to burn an unique ID to your micro, and scramble the data with it when you are loading it to the RAM. Even if they copy it, it has to be unique for every given ID, which of course should be stored in a non accessible location.Maybe it is enough just to physically sign the Flash content with the ID, and refuse to execute if it is not a match. Then again, they might remove this code, if they spend enough time cracking your gadget.

author: wraper
author_rank: Unknown
timestamp: February 19, 2016, 11:43:39 am
content: Given that cloners want to pay the money, they can read the key from the "read protected" MCU if you use the encryption. Certain companies offer memory dumping of virtually all off the shelf MCUs. So the question is if it is worth to clone your device rather than if it can be cloned.

author: abyrvalg
author_rank: Frequent Contributor
timestamp: February 20, 2016, 07:48:08 am
content: RZ/A1H boots from SPI directly, so any protection/decryption code will reside in the same SPI flash in plain form - no way to hide it. You can try adding some additional secure MCU/smartcard and moving some critical computations into it, but this requires additional time/learning

author: Boomerang
author_rank: Regular Contributor
timestamp: February 20, 2016, 12:47:41 pm
content: Quote from: wraper on February 19, 2016, 11:43:39 amThis is interesting... can you give me some website or contacts to such a company!

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 06:43:44 pm
content: Quote from: Boomerang on February 20, 2016, 12:47:41 pmThat's mostly stories from the past. All MCU's from major vendors have been pretty pretty secure for the past 10 years.

author: AndyC_772
author_rank: Super Contributor
timestamp: February 20, 2016, 06:50:10 pm
content: Concrete evidence?

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 06:52:54 pm
content: Quote from: AndyC_772 on February 20, 2016, 06:50:10 pmThe fact that everyone repeats that story from the past, but no evidence is ever produced. Also, no evidence of actually copied devices. There bound to be some, if this is such an easy task.Plus I have good knowledge of how AVRs were "opened" before and what was done to prevent this. There is still a known issue with some Atmel SAM7 devices, but those are very old, and I don't think they are of interest to anyone.

author: wraper
author_rank: Unknown
timestamp: February 20, 2016, 07:04:51 pm
content: Quote from: ataradov on February 20, 2016, 06:43:44 pmThey were not at all.http://www.break-ic.com/http://russiansemiresearch.com/en/service/For example STM32F10x $2000Even extra secure IC's can be read (those with extra security layers on top, self erase sensors if tampering detected). They get decapped and the secure bits erased by focused light, die probed directly, and so on.http://www.bunniestudios.com/blog/?page_id=40

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 07:14:19 pm
content: russiansemiresearch is a scam and their activity is illegal in Russia, so you can't really complain to authorities. It would be like complaining that you've been sold bad drugsThey only accept untraceable money transfer methods.I'm not sure about the other one.In all modern AVRs fuses (what was most often altered by a laser) are under a layer of metal. On specifically secured devices (ARMs), entire boot ROMs are covered with a layer of metal.I'm not saying that it is totally impossible, but the evidence that this is actually happening is just not there.Also, russiansemiresearch are nasty spammers, from time to time they will flood Russian forums with their "offers".

author: wraper
author_rank: Unknown
timestamp: February 20, 2016, 07:31:08 pm
content: Quote from: ataradov on February 20, 2016, 07:14:19 pmDo you have any link/info where they were exposed to be a scam. I don't know if particularly they are valid. But protected ICs are being hacked and cloned in huge amounts. For example, all those crypto ICs for printer cartridges are hacked/cloned in less than a year.

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 07:39:02 pm
content: Quote from: wraper on February 20, 2016, 07:31:08 pmI won't be able to find that info right now. I've known about them for a while. They stir up conversation every time they spam forums, then it slowly dies out.As far as I remember their tactics is based on this quote from their site "Note: We are not responsible for the wrong reading. After reading chip becomes unusable and can not be returned to the customer."You can't return money (since it is transfered via Western Union), even if the reading is "wrong".

author: wraper
author_rank: Unknown
timestamp: February 20, 2016, 07:41:36 pm
content: Quote from: ataradov on February 20, 2016, 07:14:19 pm

author: wraper
author_rank: Unknown
timestamp: February 20, 2016, 07:56:51 pm
content: Quote from: ataradov on February 20, 2016, 07:14:19 pmThat metal layer is not a so big issue for crackers. They just make a hole in it.

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 09:43:17 pm
content: Quote from: wraper on February 20, 2016, 07:31:08 pmAnd come to think about it, given the nature of the service, people may be reluctant to give positive reviews on public forums.So I would soften my statement to "potential scam". Since I've never seen any success stories, but have seen complaints. But again, those may be competitors, so who knows. There is not a whole lot of transparency on that market.

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 09:50:02 pm
content: Quote from: wraper on February 20, 2016, 07:56:51 pmI don't know exact details, I think it is more than just metal. I can see there being a track going right over the fuse - you blow the track, no reading the device out, even if fuse is now switched.And as far as probing the traces goes, it is only viable for really old MCUs (just like shown in the videos). In modern ones, you can realistically probe actual pads, but not the arbitrary trace.

author: wraper
author_rank: Unknown
timestamp: February 20, 2016, 10:28:23 pm
content: http://users.sec.t-labs.tu-berlin.de/~nedos/ccs2013.pdfThere is also such a thing as digging from the bottom.Quotenope, modern MCUs can be probed too.With a FIB they can make a hole and then deposit a material to the tiny trace, so the probing becomes possible.

author: autobot
author_rank: Regular Contributor
timestamp: February 20, 2016, 11:53:00 pm
content: Actually the description says "Encryption engine (requires nondisclosure agreement)" .Which seems like the feature you'll need.http://am.renesas.com/products/mpumcu/rz/rza/rza1h/index.jspYou should talk with renesas.

author: ataradov
author_rank: Super Contributor
timestamp: February 20, 2016, 11:57:17 pm
content: Quote from: wraper on February 20, 2016, 10:28:23 pmThis is legitimately cool stuff!

author: marshallh
author_rank: Unknown
timestamp: February 21, 2016, 12:00:45 am
content: Chris, Dmitry, Andrew et al can do that type of thing. But it gets very annoying and tedious. Can it be cracked? Of course. Can it be done cheaply? Not really. The overhead involved in running those machines is substantial, they use consumables. The operator must be pretty skilled, and understand why it works.What is your threat model? Are you worried about an ecosystem worth hundreds of millions of dollars getting popped? Or are you worried about your little MCU widget being copied?Just make it inconvenient for the Chinese. You can use an 80 cent crypto chip and make them jump through many extra hoops to clone it - at which point they will pick an easier target or simply design their own.BTW, I presented last year about this type of thing which you may find it interesting:

author: ataradov
author_rank: Super Contributor
timestamp: February 21, 2016, 12:04:54 am
content: Quote from: marshallh on February 21, 2016, 12:00:45 amThere is no question that it is totally impractical. Still cool that there is technology to do this kind of stuff.And I'm sure all that tech exists not only for cracking. I can see a lot of uses for debugging silicon issues.

author: marshallh
author_rank: Unknown
timestamp: February 21, 2016, 12:08:15 am
content: Quote from: ataradov on February 21, 2016, 12:04:54 amExactly, all those tools were designed for the chip industry. They are a staple of fab and sometimes design houses. That's how Chris got his (there is always a resale market, no matter what it is!)Not many folks using them to exclusively crack stuff instead of troubleshooting a faulty design, though.

author: wraper
author_rank: Unknown
timestamp: February 21, 2016, 09:53:33 am
content: Quote from: ataradov on February 21, 2016, 12:04:54 amDepends on the gains obtained, it can be very practical. Like crack some apple security chip in the cable and then make ten millions clones later. Or pirated sat tv. Of course hacking it is not worth if it can be made from a scratch in a few days.

author: Ian.M
author_rank: Super Contributor
timestamp: February 21, 2016, 10:38:40 am
content: If your production and final assembly is in China, all the wannabe cloners have to do is find out who makes it and persuade the line manager to run a ghost shift. If you get case, board etc. made in widely separated locations, with only test firmware preloaded on the board, then do the final assembly and firmware load in-house, it means they will have to work a bit harder and invest more capitol.However, last time I checked $5000, and three identical programmed MCUs would get you a firmware dump of most MCUs. The more reputable companies would offer you a new MCU programmed with the firmware so you could confirm successful cloning, before you made the final funds transfer to get the hex file. There are even USA based companies offering this sort of service, though I assume they'd be fairly fussy about you signing a contract that stated you were either the I.P. owner or were legitimately reverse engineering it for protocol compatibility. That sort of pricing and availability means cloning your product is well within the range of even small players with a workshop in their garage and a cousin in Shenzhen.That means that if you decide you need to control cloning, if your product needs to interact with proprietary PC software, you need to control the licensing and use of that by means other than just checking if compatible hardware is connected. If you get it wrong, you get a mess like FTDI has. Alternatively, if your product has network or USB connectivity, you will need to implement some form of secure registration to unlock its full feature set. If its entirely standalone you are probably FUBARed as it could be cloned in its registered state.Back to the O.P.s problem: Just about the only hope is to stick a secure FPGA between the QSPI flash and the MCU to manage encryption. The bootloader would be transferred in clear, and subsequent data blocks transferred over the MCU interface would be encrypted with a persistent rolling code so a direct decrypted firmware image dumped from the MCU's RAM wouldn't help. As much as possible of the processing should be offloaded to the FPGA to make it harder to reverse engineer from a firmware dump. That's a lot of work and even so, if your market is valuable enough and your product is unique enough and in high demand, someone will probably invest the time and money required to crack it.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: February 21, 2016, 11:19:22 pm
content: If the CPU can read it then so can anyone else.If you need security, either use a micro that has sufficient intrinsic security features, or use additional hardware.There is no such thing as total security - you need to assess the risks and work out how much it's worth spending to mitigate them sufficiently.There are QSPI devices with security features, like OTP areas and unique serial numbers, which can be used in conjunction with your software to prevent simple cloning.You could load in a small bootloader and have the rest of your code encrypted, using keys stored elsewhere - OTP area in QSPI, MCU unique serial number if it has it, or one of the various secure memory products out there.

author: tszaboo
author_rank: Super Contributor
timestamp: February 22, 2016, 09:36:01 am
content: Quote from: Ian.M on February 21, 2016, 10:38:40 amSo probably the best way to avoid this, is to order preprogrammed ICs from the proper vendors/suppliers, and trace the batches, and require strict handling of the scrap boards.