A little bit of context
Since you're using MQTT with AWS IoT, you're expected to use X.509 certificates for authentication and security. Amazon have a little bit of guidance about how you should secure your certificates, so I'll quote that here:
Certificates enable asymmetric keys to be used with devices. This means you can burn private keys into secure storage on a device without ever allowing the sensitive cryptographic material to leave the device.
Since you're currently using the STM32's Read Out Protection (RDP), all but the most determined attackers will have trouble accessing your certificates in your current scheme:
The global Read Out Protection allows the embedded firmware code (preloaded in the Flash memory) to protect against reverse engineering, dumping using debug tools or other means of intrusive attack.
- Level 0 - No protection (default)
- Level 1 - Flash memory is protected against reading by debugging or code dumping
by the RAM loaded code
- Level 2 - All debug features are disabled
Is external storage going to be secure?
It probably isn't as secure. If your client's private key is stolen, an attacker can send data that appears to be from your device, when it actually isn't. Although it's not clear what data you're sending, any untrusted data can be a security risk.
Which bits do I need to keep private?
When you create a device certificate on AWS IoT, you should see an image like this:
(source: amazon.com)
Image from the Create and Activate a Device Certificate page of the AWS IoT documentation.
The private key is the thing you really need to keep... private, and should definitely be stored on the read-protected memory if possible. The public key and certificate are designed to be shared, so if you're running out of space, you can safely move those to external storage. You can get a little bit more context on the page How does SSL/TLS work? at Information Security Stack Exchange and Public-key cryptography on Wikipedia. I think I'd be doing you a disservice if I didn't include this image to explain why the private key needs to be secret:
.
Image from Wikipedia, released into the public domain.
Your device's public key is what AWS IoT uses to sign messages to send to your device (but it does not prove who is sending the message). So, really, it's not a huge disaster if someone steals the public key, because it's not meant to be a secret.
The private key is what your device uses to decrypt messages, so it's a slightly bigger problem if an attacker steals this.
You also asked what would happen if the attacker stole the RootCA certificate. If someone stole AWS IoT's private key, it would be disastrous, but the RootCA certificate on your device isn't that. The RootCA.crt
that Amazon give you is completely public, and the purpose is so that you can verify that you're not being attacked in any way (most likely a man-in-the-middle pretending to be AWS IoT's servers).
What damage could a hacked device do?
Your stolen device can only perform the actions listed in the policy. Try to follow the principle of least privilege; only grant your device the privileges it absolutely needs, so if the worst does happen, it can't wreak havoc too much. For your specific case:
The thing is allowed to publish to only 2 channels (its name and a data feed channel) which is connected to a data processor which will ignore any rogue packets coming to it.
That's good. Any attack should be isolated to just the two MQTT topics that the device can publish to, so it won't cause large scale harm.