# CVE-2022-46152: OP-TEE Trusted OS vulnerable to Improper Validation of Array Index in the cleanup_shm_refs function

> A normal-world attacker can exploit an array index validation flaw in OP-TEE to achieve local privilege escalation into the secure world.

- **Severity:** High 8.2 (`CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** No
- **Published:** 29 Nov 2022
- **Updated:** 22 Apr 2025
- **Also known as:** GHSA-65w8-6mrg-52g7

## What is CVE-2022-46152?

CVE-2022-46152 is a high-severity memory corruption vulnerability in OP-TEE optee_os, published on 29 Nov 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

OP-TEE Trusted OS is the secure side implementation of OP-TEE project, a Trusted Execution Environment. Versions prior to 3.19.0, contain an Improper Validation of Array Index vulnerability. The function `cleanup_shm_refs()` is called by both `entry_invoke_command()` and `entry_open_session()`. The commands `OPTEE_MSG_CMD_OPEN_SESSION` and `OPTEE_MSG_CMD_INVOKE_COMMAND` can be executed from the normal world via an OP-TEE SMC. This function is not validating the `num_params` argument, which is only limited to `OPTEE_MSG_MAX_NUM_PARAMS` (127) in the function `get_cmd_buffer()`. Therefore, an attacker in the normal world can craft an SMC call that will cause out-of-bounds reading in `cleanup_shm_refs` and potentially freeing of fake-objects in the function `mobj_put()`. A normal-world attacker with permission to execute SMC instructions may exploit this flaw. Maintainers believe this problem permits local privilege escalation from the normal world to the secure world. Version 3.19.0 contains a fix for this issue. There are no known workarounds.

Weakness: CWE-129 (Improper Validation of Array Index)

## Which versions are affected by CVE-2022-46152?

It affects 1 product.


Products: Trustedfirmware Op-Tee.

## How do I fix CVE-2022-46152?

No fix has been published for CVE-2022-46152 yet. Limit exposure of the affected software until one is available.

## Is CVE-2022-46152 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-46152 exists.

Public exploit code:

- CVE-2022-46152: Improper Validation of Array Index in the `cleanup_shm_refs' function. (github_poc): https://github.com/0xbbdd/CVE-2022-46152

## Other vulnerabilities in OP-TEE optee_os

- [CVE-2019-1010292](https://insights.sbomify.com/CVE-2019-1010292/): Memory corruption in OP-TEE (critical 9.8)
- [CVE-2019-1010293](https://insights.sbomify.com/CVE-2019-1010293/): Memory corruption in OP-TEE (critical 9.8)
- [CVE-2019-1010295](https://insights.sbomify.com/CVE-2019-1010295/): Linaro/OP-TEE OP-TEE 3.3.0 and earlier is affected by: Buffer Overflow. (critical 9.8)
- [CVE-2019-1010296](https://insights.sbomify.com/CVE-2019-1010296/): Memory corruption in OP-TEE (critical 9.8)
- [CVE-2019-1010297](https://insights.sbomify.com/CVE-2019-1010297/): Memory corruption in OP-TEE (critical 9.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-46152 and fix it if it is affected.

What it is: CVE-2022-46152 is a high-severity memory corruption vulnerability in OP-TEE optee_os, published on 29 Nov 2022. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2022-46152 exists.

Affected product: OP-TEE optee_os. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-46152/ (Markdown: https://insights.sbomify.com/CVE-2022-46152/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-46152
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-46152
- OSV: https://osv.dev/vulnerability/CVE-2022-46152

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-46152/
Summaries are generated and may contain mistakes; the official description above is the record.
