AMD PSP: Firmware TPM Remote Code Execution via Crafted EK Certificate
A stack-based overflow in the fTPM trustlet's EkCheckCurrentCert function, reachable via a crafted DER-encoded endorsement key certificate stored in NV storage, allows an attacker to overwrite the stack and gain control of the program counter. The researcher demonstrated full PC control in an ARM emulator, and notes that common exploit mitigations are absent in the PSP environment.
seclists.org
Published on seclists.org
fTPM is a firmware TPM [3] implementation. It runs as a trustlet application inside the PSP. fTPM exposes a TPM 2.0 interface over MMIO to the host [4].
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely missing bounds checks when parsing a nested TLV structure in the EK certificate, allowing a copy into a fixed-size stack buffer to overflow.
Impact
An attacker could achieve remote code execution on the PSP, and the text notes that general exploit mitigations such as stack cookies, NX stack, and ASLR are not implemented in the PSP environment.
What the attacker needed
Ability to supply a crafted EK certificate; certificate stored in NV storage; TPM2_CreatePrimary invoked
The fix
The text states a fix was ready and the vendor was working on a rollout to affected partners.
How it was found
- Craft a DER-encoded EK certificate containing nested TLV structures with oversized length fields.
- Store the crafted certificate in NV storage so it is processed by TPM2_CreatePrimary.
- Trigger TPM2_CreatePrimary, which calls EkCheckCurrentCert and parses the certificate.
- Observe the stack overflow and program counter control in an ARM emulator.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A security processor inside AMD chips runs a small trusted program called fTPM. It reads a certificate that a user can supply, and because it does not check the certificate's length properly, a specially made certificate can overflow a buffer on the stack. That lets an attacker take over the program's execution flow, which in this case means running their own code on the security processor.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.