Author Topic: 32F417 security question (disabling SWD etc)  (Read 2170 times)

0 Members and 1 Guest are viewing this topic.

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 6146
  • Country: gb
  • Doing electronics since the 1960s...
32F417 security question (disabling SWD etc)
« on: August 24, 2022, 03:39:17 pm »
I've been reading the various ST appnotes on this, but I can't find clear answers on whether one can achieve this

1) Disable SWD, so the only way to reload firmware would be with some form of firmware loader (which I have done, via USB MSC FatFS or file upload via HTTP server) and there one can put a secure hash etc on the file being uploaded

2) Prevent bottom 32k of FLASH being read out

3) The secure status being reversible so if a customer returns a unit it doesn't have to go in the rubbish bin (with various heavy political implications if the customer is a big company with lots of power, and ready to withold payments, etc). ST deny warranty on Level 2 fused devices, which is completely understandable, but they are bigger than anybody else :)

4) A RAM based boot loader (copied from bottom 32k block to the RAM, for rewriting the whole FLASH) needs to work even when above security features have been set.

AFAICS only Level 2 security is not reversible by uploading suitably written software.

Item 2) is a bit of an odd one because if you disable SWD, it cannot be read with a debugger anyway, but it needs to be accessible by code executing on the CPU, including the RAM based boot loader. So maybe that bit is pointless.

I've also read that all the time BOOT0/BOOT1 are accessible, somebody can use them to activate ST's boot loader and inject code via e.g. a UART. The method to disable these, by remapping with AF, can apparently be easily bypassed with a carefully timed reset.

I think disabling SWD will be the biggest gain. But it needs to be software-reversible.
« Last Edit: August 24, 2022, 03:57:15 pm by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: sk
Re: 32F417 security question (disabling SWD etc)
« Reply #1 on: August 24, 2022, 04:13:29 pm »
We can stop here:

> 1) Disable SWD

Only through setting Level 2 lock.

But let's discuss also other points.

> 2) Prevent bottom 32k of FLASH being read out

Not in 'F405/407/415/417. In newer STM32 - including 'F42x/43x - maybe, keyword is PCROP, read related chapters of RM.

> 3) The secure status being reversible

That's only Level 1, in 'F417.

> 4) A RAM based boot loader

That should work with Level 1.


You are surely aware of existing "unlocking services" and the publicly known vulnerabilities.

JW
 
The following users thanked this post: voltsandjolts

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 6146
  • Country: gb
  • Doing electronics since the 1960s...
Re: 32F417 security question (disabling SWD etc)
« Reply #2 on: August 24, 2022, 04:47:48 pm »
Thank you :)

If disabling SWD needs Level 2, that kills this whole idea, because I won't ship out such a product unless it contains absolutely finished and debugged code and the customer has signed off on the functionality.

My board has even got the 10-pin ARM SWD/JTAG connector on it, clearly marked ;)

I could use the 437 instead of 417 if that helped.

Yes I've read various things, and there are many attacks e.g. measuring the supply current which have been used to crack even dedicated "secure" smartcard chips. These attacks go back decades, as do the countermeasures like "encrypting" the supply current! I would just want to p1ss off somebody who thinks it is a 5 minute job :)
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 591
  • Country: sk
Re: 32F417 security question (disabling SWD etc)
« Reply #3 on: August 24, 2022, 05:42:13 pm »
Quote
I could use the 437 instead of 417 if that helped.

That might help point 2) but not 1).

JW
 

Offline darkspr1te

  • Frequent Contributor
  • **
  • Posts: 545
  • Country: zm
Re: 32F417 security question (disabling SWD etc)
« Reply #4 on: August 24, 2022, 06:02:50 pm »
Thank you :)

If disabling SWD needs Level 2, that kills this whole idea, because I won't ship out such a product unless it contains absolutely finished and debugged code and the customer has signed off on the functionality.

My board has even got the 10-pin ARM SWD/JTAG connector on it, clearly marked ;)

I could use the 437 instead of 417 if that helped.

Yes I've read various things, and there are many attacks e.g. measuring the supply current which have been used to crack even dedicated "secure" smartcard chips. These attacks go back decades, as do the countermeasures like "encrypting" the supply current! I would just want to p1ss off somebody who thinks it is a 5 minute job :)
You can disable swd in boot code if you patch the load to ram routine in most dev env's. but that still falls to the connect on reset  and irq dump routine.
you can hinder realtime debugging with calls to the pins for the swd system so make it a patch nightmare , place secure code around  irq 13 and such , use rtc for crc storage like factory boot, real time, tamper and many more tricks so your code does lock up the test the heck out of it.
You can also use irq's a lot more, the jump is just another cash/cost/day delay for them but it not much extra code.
depending on the stm clone too have larger storage in areas like rtc which is where sram code is hidden so when a device is opened it mis-behaves, something i'll write up at some point   


darkspr1te



 

Offline peter-hTopic starter

  • Super Contributor
  • ***
  • Posts: 6146
  • Country: gb
  • Doing electronics since the 1960s...
Re: 32F417 security question (disabling SWD etc)
« Reply #5 on: August 25, 2022, 06:27:10 am »
You mean setting up an interrupt to do stuff with the SWD pins? But surely the debugger resets the CPU and stops all that?

In the days of dongles, software used timers to detect single stepping, to make it harder to discover where the dongle code is. But on the arm32 you can freeze timers (and the watchdog) while stepping.
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->