Stack-buffer-overflow in sc_asn1_read_tag in opensc

opensc Updated 02 Oct 2025

Summary

29/05/2022
MEDIUM
Yes i
Medium
Not published

OSV-2022-437: Stack-buffer-overflow in sc_asn1_read_tag. Affects opensc versions >= 74a8f296e0f195916d28e1c928f457e04aa22892, < 972d3292eee44e9b4c61769365a3ec651ec18f39. Fixed in 972d3292eee44e9b4c61769365a3ec651ec18f39. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

OpenSC is an open-source smart card library that provides a set of cryptographic functions and protocols for interacting with smart cards. It is commonly used in various applications that require smart card authentication and encryption. The sc_asn1_read_tag function in OpenSC is responsible for reading ASN.1 tags from smart card data. However, a stack-buffer-overflow vulnerability has been discovered in this function, which could potentially allow an attacker to overwrite adjacent memory and execute arbitrary code.

Vulnerability Detail

The stack-buffer-overflow vulnerability in sc_asn1_read_tag arises from a failure to properly validate the length of ASN.1 tags. By providing a specially crafted ASN.1 tag with a length that exceeds the bounds of the buffer, an attacker can trigger a stack-based buffer overflow. This can lead to various consequences, including remote code execution, denial of service, or information disclosure. The vulnerability was reported through the OSS-Fuzz project, and it has been assigned the identifier OSV-2022-437.

How To Fix

Minimum fixed version

972d3292eee44e9b4c61769365a3ec651ec18f39

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, users can disable or limit the usage of the affected functionality in OpenSC. This can be achieved by modifying the code or configuration to avoid invoking the vulnerable sc_asn1_read_tag function. However, this workaround may impact the functionality or usability of applications relying on the affected functionality.

Conclusion

The stack-buffer-overflow vulnerability in sc_asn1_read_tag in OpenSC can have severe consequences, including remote code execution and information disclosure. It is crucial to update to the latest version of OpenSC that includes the fix for this vulnerability. Additionally, users can leverage Vulert (https://vulert.com) to monitor and receive real-time alerts for open-source vulnerabilities in their software.

See every vulnerability recorded for opensc →

Share this vulnerability

FAQ

OpenSC is an open-source smart card library that provides cryptographic functions and protocols for interacting with smart cards.

The vulnerability can potentially allow an attacker to execute arbitrary code, leading to remote code execution, denial of service, or information disclosure.

The vulnerability was discovered through the OSS-Fuzz project, which performs continuous fuzz testing on open-source software.

Yes, the OpenSC project has released a patch to address the vulnerability. It is recommended to update to the latest version of OpenSC.

A temporary workaround is to disable or limit the usage of the affected functionality in OpenSC. However, this may impact application functionality.

Related vulnerabilities

Recent vulnerabilities recorded for opensc.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

972d3292eee44e9b4c61769365a3ec651ec18f39

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback