Skip to content

Memory corruption when reading public key modulus from SPI flash to RAM #3

@jeremyncc

Description

@jeremyncc

In the following function, a 16-bit key_length value is read from SPI flash, and is then used as the size argument to a subsequent pfr_spi_read() call.

https://github.com/opencomputeproject/Tektagon-OpenEdition/blob/f7350a3a175373532f2ecafc82745a827397d4a8/zephyr/FunctionalBlocks/Pfr/cerberus/cerberus_pfr_common.c#L381-L388

If a physical attacker has tampered with the contents of SPI flash, they could replace the key_length field with an excessively large value. If this value was larger than RSA_KEY_LENGTH_4K (512 bytes), then memory corruption will occur when copying the public key modulus from flash into RAM.

Between the first and second calls to pfr_spi_read() check key_length to ensure it is not larger than sizeof(public_key->modulus).

Edited to add: I noticed that the AST1060 uses internal flash, so it may not be possible for an adversary to tamper with the public key as described in this report. Are there other platform configurations that use external flash?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions