L4TLauncher: buffer overrun / crash in ReadAndroidStyleKernelPartition with encrypted images and 2KB signatures
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 145
- Forks
- 66
- PR merge metrics
- No merged PRs in 30d
Description
Mostly caused by e6fd382 "fix: verify signature with alignment 4KB and 2KB" (first included in L4T R36.5.0) but originally sourced to 21ff46f "L4T Launcher: enable UEFI to load encrypted payloads from partition". These are the buggy lines:
https://github.com/NVIDIA/edk2-nvidia/blob/fd77facdc6252a394f66b9c8dbd35d7f0166fa73/Silicon/NVIDIA/Application/L4TLauncher/L4TLauncher.c#L2057-L2059
SignatureOffsetis aligned up to 4KB, which may be beyondDecryptedImageBufferSizewhen 2KB alignment was used to produce the imageSignatureSizeunderflows and becomes extremely largeCopyMemcrashes due to a very large length parameter
There are also other issues here:
ImageBufferSizeshould ideally be checked to ensure it is not larger thanDecryptedImageBufferSizebefore any of this code runs. That could cause a similar buffer overrun just with a corrupted image.- If there is even more than 4KB of padding at the end of the image,
SignatureSizecan become larger than the actual size ofSignatureBufferand cause a heap overrun.
Basically, SignatureSize should be clamped between 0 and the previous value of SignatureSize (4KB) on this line to resolve all issues.
The same issue exists in ReadAndroidStyleDtbPartition too, where SignatureSize can underflow:
https://github.com/NVIDIA/edk2-nvidia/blob/fd77facdc6252a394f66b9c8dbd35d7f0166fa73/Silicon/NVIDIA/Application/L4TLauncher/L4TLauncher.c#L2314
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Silicon/NVIDIA/Application/L4TLauncher/L4TLauncher.c at ReadAndroidStyleKernelPartition around lines 2057-2059, then inspect ReadAndroidStyleDtbPartition around line 2314. Exercise encrypted images using 2KB signatures, plus corrupted images and images with extra padding; done means SignatureSize cannot underflow or exceed its buffer and neither path overruns or crashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100