Skip to content
Memory corruption Write-up Advanced

Huawei TrustZone CHINADRM_KEY_TA Vulnerability

The TZ_CDRM_KeyPrivateKeyDecrypt function in Huawei's TrustZone trusted application sets the output buffer size to 0x100 without checking the actual buffer size, allowing a buffer overflow. An attacker could potentially overflow the output buffer, but the impact is limited because each TEE_Param is on separate memory pages, so no visible effect such as a crash was observed.

blog.impalabs.com

Published on blog.impalabs.com

Alexandre Adamski](https://blog.impalabs.com/authors/alexandre-adamski.html) [{{media:2}}

The author, on blog.impalabs.com

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 the function sets the output buffer size to a fixed value (0x100) without verifying that the caller-provided buffer is at least that large, only checking an upper bound.

Impact

The overflow could corrupt memory, but because each TEE_Param is on separate memory pages, it may not cause a visible crash or be exploitable; the report rates severity as Low.

What the attacker needed

Access to the TrustZone trusted application

The fix

The vulnerability was fixed according to the patch table.

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.

This is a bug in a secure part of Huawei phones that handles DRM keys. The code sets a fixed size for an output buffer without checking if the buffer is actually that big, so it can write more data than the buffer can hold. That is called a buffer overflow, which can sometimes crash the phone or let an attacker run code, but here the memory layout made it hard to see any effect.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.