OP-TEE PKCS#11 TA Out-of-Bounds Heap Write via `C_GetAttributeValue` (CVE-2026-33317)
by qianfei11 · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-33317 (GHSA-8cqw-mg7v-c9p9)
- Category
- binary
- Affected product
- OP-TEE OS — PKCS#11 Trusted Application (optee_os, ta/pkcs11)
- Affected versions
- OP-TEE >= 3.13.0, fixed in 4.11 and later
- Disclosed
- 2026-07-05
- Patch status
- patched
References
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-04 |
| Author / Researcher | qianfei11 |
| CVE / Advisory | CVE-2026-33317 (GHSA-8cqw-mg7v-c9p9) |
| Category | binary |
| Severity | High |
| CVSS Score | 8.7 (CVSS v3.1, per source advisory) |
| Status | PoC |
| Tags | optee, trustzone, pkcs11, secure-world, heap-corruption, oob-write, qemu, trusted-application |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | OP-TEE OS — PKCS#11 Trusted Application (optee_os, ta/pkcs11) |
| Versions Affected | OP-TEE >= 3.13.0, fixed in 4.11 and later |
| Language / Platform | C (AArch64 Normal World client via libteec), targeting the OP-TEE Secure World TA under QEMUv8 |
| Authentication Required | Local-only (requires ability to issue TEE Client API calls to the PKCS#11 TA) |
| Network Access Required | No |
Summary
CVE-2026-33317 is missing bounds validation in entry_get_attribute_value() in the OP-TEE PKCS#11 Trusted Application, reachable via the PKCS11_CMD_GET_ATTRIBUTE_VALUE command. The TA does not verify that each attribute header and its associated data region lie fully within the client-supplied serialized attribute template buffer, which allows a crafted request to make get_attribute() write past the end of a heap allocation inside the Secure World. The included PoC creates a PKCS#11 session object with a 16-byte CKA_LABEL, then sends a malformed C_GetAttributeValue request with attrs_size = 8 (an 8-byte header with no trailing data), causing the TA to compute a data pointer one byte past the 16-byte allocation and copy the 16-byte label there, corrupting PKCS#11 TA heap metadata and triggering a TA panic in the OP-TEE bget allocator.
Vulnerability Details
Root Cause
ta/pkcs11/src/object.c iterates over a client-supplied serialized attribute template without proving that each attribute header and its data area are fully contained within the allocated template buffer; get_attribute() in ta/pkcs11/src/attributes.c then trusts the caller-supplied size and copies data to a pointer that can land outside the allocation.
Attack Vector
- Open a TEEC session with the PKCS#11 TA (UUID
fd02c9da-306c-48c7-a49c-bbd827ae86ee) and initialize a token slot. - Open a read/write PKCS#11 session and create an AES session object with a 16-byte
CKA_LABEL(e.g."AAAAAAAAAAAAAAAA"). - Send a crafted
PKCS11_CMD_GET_ATTRIBUTE_VALUErequest withattrs_size = 8(one bare attribute header, no data bytes) andcli_head.size = 16matching the object’s label size. - The TA computes the 16-byte template allocation as
sizeof(pkcs11_object_head) + attrs_size = 16bytes, thenget_attribute()writes the 16-byte label starting one byte past the end of that allocation, corrupting adjacent heap metadata. - The OP-TEE
bgetallocator detects the corrupted block metadata on a subsequent free and the PKCS#11 TA panics (Secure World crash).
Impact
Out-of-bounds heap write inside the OP-TEE Secure World PKCS#11 Trusted Application, causing TA heap corruption and a Secure World TA panic/crash; the disclosed PoC demonstrates the corruption and crash primitive (memory corruption), which is a plausible starting point for further Secure World exploitation.
Environment / Lab Setup
Target: OP-TEE OS QEMUv8 (aarch64) workspace with PKCS#11 TA (optee_os >= 3.13.0, < 4.11)
Attacker: Linux x86-64 host, `expect`, AArch64 cross-compiler/sysroot, prebuilt OP-TEE qemu_v8 build (bl1.bin, Image, rootfs.cpio.gz)
Proof of Concept
PoC Script
See
c01_poc.c(Normal World PoC),build_poc.sh,run_c01.sh, andc01_check.expin this folder. Reproduction notes inreproduction-log.mdandqemu-v8-setup.md; captured logs inout/bin/c01_nw.logandout/bin/c01_sw.log.
| |
build_poc.sh cross-compiles c01_poc.c into out/bin/c01_poc against an OP-TEE qemu_v8 toolchain/sysroot; run_c01.sh boots QEMUv8, shares the PoC binary into the guest over virtio-9p via c01_check.exp, runs it against the PKCS#11 TA, and captures Normal World and Secure World logs showing the malformed request and resulting TA panic.
Detection & Indicators of Compromise
Signs of compromise:
- OP-TEE Secure World logs showing PKCS#11 TA (
fd02c9da-306c-48c7-a49c-bbd827ae86ee) panics orbgetallocator assertion failures - Repeated
CMD_GET_ATTRIBUTE_VALUEcalls with attribute template sizes inconsistent with the requested attribute’s actual size - Unexpected TA crashes/restarts correlating with PKCS#11 client activity on the Normal World side
Remediation
| Action | Detail |
|---|---|
| Primary fix | Upgrade OP-TEE OS to 4.11 or later, which adds bounds validation for PKCS#11 attribute templates |
| Interim mitigation | Restrict which Normal World clients/processes may open sessions with the PKCS#11 TA until patched |
References
Notes
Mirrored from https://github.com/qianfei11/CVE-2026-33317 on 2026-07-05. The upstream repository intentionally excludes the bulky OP-TEE/QEMU source trees, toolchains, and build outputs — only the PoC source, build/run scripts, setup notes, and captured reproduction logs are mirrored here; a working OP-TEE qemu_v8 build root is required to actually run the PoC.
| |