Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce TLV protected entries #1938

Merged
merged 3 commits into from
Apr 18, 2024
Merged

Conversation

d3zd3z
Copy link
Member

@d3zd3z d3zd3z commented Apr 10, 2024

Add an additional check to the image validation to ensure that TLV entries that need to be protected are actually in the protected section. This works with a whitelist of entries that are allowed to be unprotected. There is a define ALLOW_ROGUE_TLVS that can be set to bypass this check.

@d3zd3z d3zd3z marked this pull request as draft April 11, 2024 05:40
@d3zd3z d3zd3z changed the title Fix check tlv Enforce TLV protected entries Apr 11, 2024
@d3zd3z d3zd3z marked this pull request as ready for review April 11, 2024 20:48
Copy link
Collaborator

@davidvincze davidvincze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few minor comments, otherwise it looks good to me.

boot/bootutil/src/tlv.c Outdated Show resolved Hide resolved
boot/bootutil/src/image_validate.c Outdated Show resolved Hide resolved
Comment on lines +358 to +370
IMAGE_TLV_KEYHASH,
IMAGE_TLV_PUBKEY,
IMAGE_TLV_SHA256,
IMAGE_TLV_SHA384,
IMAGE_TLV_RSA2048_PSS,
IMAGE_TLV_ECDSA224,
IMAGE_TLV_ECDSA_SIG,
IMAGE_TLV_RSA3072_PSS,
IMAGE_TLV_ED25519,
IMAGE_TLV_ENC_RSA2048,
IMAGE_TLV_ENC_KW,
IMAGE_TLV_ENC_EC256,
IMAGE_TLV_ENC_X25519,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the current situation - considering how imgtool works.
In theory the keyhash/pubkey and encryption TLVs could be in the protected area.
Do you think it would make sense to move these TLVs in the future?
As for the keyhash/pubkey TLV, I prefer to have it together with the signature TLV to make re-signing of an image more convenient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the keyhash/pubhash can stay in the unprotected. The things directly related to signature verification make sense to keep there. It probably makes sense to move the enc ones, but it isn't urgent.

I'll fix the whitespace.

Add a query to the TLV iterator that will indicate if the currently iterated TLV
entry was found in the protected region or not.

Signed-off-by: David Brown <david.brown@linaro.org>
Only allow TLV entries that are needed for signature verification to be placed
in the unprotected area of the TLV.

Signed-off-by: David Brown <david.brown@linaro.org>
Add a release not stub for the TLV check.

Signed-off-by: David Brown <david.brown@linaro.org>
@davidvincze davidvincze self-requested a review April 18, 2024 09:08
@davidvincze davidvincze merged commit 69858eb into mcu-tools:main Apr 18, 2024
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants