# CVE-2021-45985: Memory corruption in n/a

> An erroneous finalizer during a tail call in Lua causes a heap-based buffer over-read, potentially leading to crashes or information disclosure.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 10 Apr 2023
- **Updated:** 12 Feb 2025
- **Also known as:** AZL-26047, AZL-26155, AZL-26158, AZL-35066, BIT-lua-2021-45985, DEBIAN-CVE-2021-45985, GHSA-pxvf-cp3x-784h, JLSEC-2026-559, OESA-2023-1241, OESA-2023-1242, UBUNTU-CVE-2021-45985

## What is CVE-2021-45985?

CVE-2021-45985 is a high-severity memory corruption vulnerability in n/a, published on 10 Apr 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

In Lua 5.4.3, an erroneous finalizer called during a tail call leads to a heap-based buffer over-read.

Weakness: CWE-787 (Out-of-bounds Write)

## Which versions are affected by CVE-2021-45985?

1 open source package ship an affected version, including lua. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `lua` | Bitnami | From 5.4.0 | 5.4.4 |

Products: Lua Lua.

## How do I fix CVE-2021-45985?

Upgrade lua to 5.4.4 or later.

## Is CVE-2021-45985 being exploited?

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

## Other vulnerabilities in n/a

- [CVE-2020-15889](https://insights.sbomify.com/CVE-2020-15889/): Memory corruption in n/a (critical 9.8)
- [CVE-2020-15888](https://insights.sbomify.com/CVE-2020-15888/): Use after free in n/a (high 8.8)
- [CVE-2020-24369](https://insights.sbomify.com/CVE-2020-24369/): Null dereference in n/a (high 7.5)
- [CVE-2021-44964](https://insights.sbomify.com/CVE-2021-44964/): Use after free in n/a (medium 6.3)
- [CVE-2020-15945](https://insights.sbomify.com/CVE-2020-15945/): Null dereference in n/a (medium 5.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-45985 and fix it if it is affected.

What it is: CVE-2021-45985 is a high-severity memory corruption vulnerability in n/a, published on 10 Apr 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2021-45985 exists.

Affected packages and fixed versions:
- lua (Bitnami): affected from 5.4.0; fixed in 5.4.4

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-2021-45985/ (Markdown: https://insights.sbomify.com/CVE-2021-45985/index.md)
```

## Sources

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

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