Protecting files on littlefs

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lutecki
Posts: 6
Joined: Wed Apr 14, 2021 8:56 pm

Protecting files on littlefs

Post by lutecki » Mon Apr 19, 2021 10:00 pm

Hi,
Is there a way to protect littlefs files from USB access? I don't want to allow py and mpy files to be copied.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Protecting files on littlefs

Post by dhylands » Mon Apr 19, 2021 11:29 pm

You can disable MSC access by turning it off in your boot.py file. However, you'll still be able to access the files using a tool like rshell. You'd need to disable the REPL in order to fully disable file access that way.

That can all be circumvented by booting in safe mode: http://docs.micropython.org/en/latest/p ... #safe-mode so you'd need to disable that too.

You'd also want to disable sdcard booting, otherwise I could just write a little script which copies the contents of the internal flash onto the sdcard.

And unless you also turn off flash reading you can just download the filesystem using dfu-util:
viewtopic.php?f=3&t=5877#p33694

lutecki
Posts: 6
Joined: Wed Apr 14, 2021 8:56 pm

Re: Protecting files on littlefs

Post by lutecki » Tue Apr 20, 2021 8:33 am

Hi Dave,
Thank you for your reply. I forgot to mention that I'm using a ESP32-wroom module, so I don't have a problem with sdcard, mass storage etc ;-) My issue is the possibility of copying through like uPycraft, pyboard.py etc. A some semi-solution is to obfuscate the code via mpy-cross but I don't know why, one module (tinyweb) not working after conversion to .mpy.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Protecting files on littlefs

Post by Roberthh » Tue Apr 20, 2021 9:49 am

Generally the ESP32 supports flash encryption, and the Pycom variant has a build option for it. Only that Pycom supports only it's own hardware. Modified their scripts supporting generic ESP32 too. Using that required you to build your own images. And the Pycom MP version lags behind the the genuine one. But it also has few benefits, like built-in ftp and telnet.
Edit: My Pycom firmware ESP32 variant: https://github.com/robert-hh/pycom-micr ... e/homebrew
compile & load with:

make BOARD=ESP32 FLASH_SIZE=4MB flash

You need the pycom build environment which includes a special copy of ESP-IDF (still 3.x).

Post Reply