# CVE-2023-2977: Memory corruption in OpenSC

> A heap-based buffer over-read in OpenSC allows attackers to cause crashes or leak information via a malformed smart card package.

- **Severity:** High 7.1 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 1 Jun 2023
- **Updated:** 3 Nov 2025
- **Also known as:** ALSA-2023:6587, ALSA-2023:7160, AZL-27012, AZL-35073, BELL-CVE-2023-2977, CLSA-2025-1760022476, DEBIAN-CVE-2023-2977, GHSA-p22r-5f28-437x, MGASA-2023-0222, OESA-2023-1678, OESA-2023-1679, RHSA-2023:6587, RHSA-2023:7160, SUSE-SU-2023:2466-1, SUSE-SU-2023:2508-1, SUSE-SU-2023:2516-1, UBUNTU-CVE-2023-2977, openSUSE-SU-2024:12968-1

## What is CVE-2023-2977?

CVE-2023-2977 is a high-severity memory corruption vulnerability in Opensc Project Opensc, published on 1 Jun 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

A vulnerbility was found in OpenSC. This security flaw cause a buffer overrun vulnerability in pkcs15 cardos_have_verifyrc_package. The attacker can supply a smart card package with malformed ASN1 context. The cardos_have_verifyrc_package function scans the ASN1 buffer for 2 tags, where remaining length is wrongly caculated due to moved starting pointer. This leads to possible heap-based buffer oob read. In cases where ASAN is enabled while compiling this causes a crash. Further info leak or more damage is possible.

Weakness: CWE-125 (Out-of-bounds Read), CWE-119 (Improper Restriction of Operations within the Bounds of a Memory Buffer)

## Which versions are affected by CVE-2023-2977?

It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `opensc` | AlmaLinux:8 | All versions | 0.20.0-6.el8 |
| `opensc` | AlmaLinux:9 | All versions | 0.23.0-2.el9 |
| `opensc` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.20.0-6.el8 |
| `opensc-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.20.0-6.el8 |
| `opensc-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:0.20.0-6.el8 |
| `opensc` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.23.0-2.el9 |
| `opensc-debuginfo` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.23.0-2.el9 |
| `opensc-debugsource` | Red Hat:enterprise_linux:9::baseos | All versions | 0:0.23.0-2.el9 |
| `opensc` | SUSE:Linux Enterprise Micro 5.1 | All versions | 0.19.0-150100.3.22.1 |
| `opensc` | SUSE:Linux Enterprise Micro 5.2 | All versions | 0.19.0-150100.3.22.1 |
| `opensc` | SUSE:Linux Enterprise Micro 5.3 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | SUSE:Linux Enterprise Micro 5.4 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | SUSE:Linux Enterprise Module for Basesystem 15 SP4 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | SUSE:Linux Enterprise Module for Basesystem 15 SP5 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | SUSE:Linux Enterprise Real Time 15 SP3 | All versions | 0.19.0-150100.3.22.1 |
| `opensc` | SUSE:Linux Enterprise Server 12 SP5 | All versions | 0.13.0-3.22.1 |
| `opensc` | SUSE:Linux Enterprise Server for SAP Applications 12 SP5 | All versions | 0.13.0-3.22.1 |
| `opensc` | openSUSE:Leap 15.4 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | openSUSE:Leap 15.5 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | openSUSE:Leap Micro 5.3 | All versions | 0.22.0-150400.3.3.1 |
| `opensc` | openSUSE:Tumbleweed | All versions | 0.23.0-2.1 |

Products: Opensc Project Opensc, Redhat Enterprise Linux.

## How do I fix CVE-2023-2977?

Apply the vendor's patch.

## Is CVE-2023-2977 being exploited?

There is no known exploitation of CVE-2023-2977 in the wild and no public exploit code.

## Other vulnerabilities in Opensc Project Opensc

- [CVE-2021-34193](https://insights.sbomify.com/CVE-2021-34193/): Memory corruption in n/a (high 7.5)
- [CVE-2019-16058](https://insights.sbomify.com/CVE-2019-16058/): Memory corruption in n/a (high 7.5)
- [CVE-2019-6502](https://insights.sbomify.com/CVE-2019-6502/): Denial of service in n/a (high 7.5)
- [CVE-2019-20792](https://insights.sbomify.com/CVE-2019-20792/): Use after free in n/a (medium 6.8)
- [CVE-2018-16391](https://insights.sbomify.com/CVE-2018-16391/): Memory corruption in n/a (medium 6.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-2977 and fix it if it is affected.

What it is: CVE-2023-2977 is a high-severity memory corruption vulnerability in Opensc Project Opensc, published on 1 Jun 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-2977 in the wild and no public exploit code.

Affected product: Opensc Project Opensc. 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-2023-2977/ (Markdown: https://insights.sbomify.com/CVE-2023-2977/index.md)
```

## Sources

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

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