ARM-software / psa-firmware-update-spec

The PSA Firmware Update API specification, and discussion of future versions of this API.
Other
4 stars 2 forks source link

Do we need precise verification error codes? #19

Open athoelke opened 2 years ago

athoelke commented 2 years ago

The v0.7 API defines a set of API-specific error codes that are documented to be used with the psa_fwu_install() function, and psa_fwu_set_manifest(), that report specific verification failure conditions. The separately reported errors are as follows (see psa_fwu_install() and psa_fwu_set_manifest()):

Error Reason
PSA_ERROR_NOT_PERMITTED The image/manifest is too old to be installed. If the image metadata contains a timestamp, and it has expired, then this error is also returned.
PSA_ERROR_WRONG_DEVICE The image/manifest is not intended for this device.
PSA_ERROR_INVALID_SIGNATURE The image/manifest signature is not valid.
PSA_ERROR_DATA_CORRUPT The image is corrupt.
PSA_ERROR_INSUFFICIENT_DATA The image is smaller than expected.
PSA_ERROR_DECRYPTION_FAILURE The key used to decrypt the data is unknown or decryption failed.
PSA_ERROR_ALREADY_INSTALLED The storage item associated with image ID has already been installed.
PSA_ERROR_DEPENDENCY_NEEDED A different manifest/image is needed first.
PSA_SUCCESS_DEPENDENCY_NEEDED Another image needs to be installed to finish installation.

Proposal

d3zd3z commented 2 years ago

I'm a little worried about the possibility of having too much detail about why an image fails (invalid signature vs some of the other data) and that being able to be used for an oracle attack. In other words, I like the idea of simplifying the error messages, and to collapse most down to invalid signature). We would want to make sure there isn't any advantage given to an attacker from being able to distinguish INVALID_SIGNATURE from INVALID_ARGUMENT.

athoelke commented 2 years ago

I have the same concern - the historical precedent being providing a distinction between invalid padding and invalid content. I am not sure that this extends to INVALID_SIGNATURE vs INVALID_ARGUMENT. We could tighten up the use of these. For example:

This way, until an image passes the integrity check the call will only return INVALID_SIGNATURE. We assume that the signature/integrity check is cryptographically hard enough.

If the Update Service is a secure implementation (inside a Root of Trust), then reducing the information in the failure code reduces the benefit to an attacker - but makes diagnostic of a problem much harder. I would expect this kind of implementation to have some kind of secure audit log that might record the update attempt and failure?

If the implementation is purely a HAL, then it is unlikely to diagnose different failure conditions - it expects that the Client is responsible for most of that.