Stack-buffer-overflow in sc_path_print in opensc

opensc Updated 02 Oct 2025

Summary

14/05/2023
MEDIUM
No i
Medium
Not published

OSV-2023-395: Stack-buffer-overflow in sc_path_print. Affects opensc versions >= bec4f63c5b8308d7fdca842c5c0b62c3491d106a. No fix is published. 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 Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

OpenSC is an open-source smart card library that provides a set of cryptographic functions and smart card drivers. It is used to interact with smart cards and perform operations such as authentication and data encryption. The sc_path_print function in OpenSC is responsible for printing the path of a file on a smart card. However, a stack-buffer-overflow vulnerability has been discovered in this function.

Vulnerability Detail

The stack-buffer-overflow vulnerability in sc_path_print can be triggered when a file path exceeds the size of the buffer allocated for it. This can lead to a read overflow, potentially allowing an attacker to read sensitive information from the stack or cause a denial-of-service condition. The vulnerability was reported through the OSS-Fuzz project and has a medium severity rating.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary workaround, users can avoid triggering the vulnerability by ensuring that file paths passed to the sc_path_print function do not exceed the allocated buffer size. This can be achieved by validating and truncating file paths before passing them to the function. Here is an example of how to truncate a file path in C:

#include <string.h>

void truncateFilePath(char* filePath, size_t bufferSize) {
  if (strlen(filePath) >= bufferSize) {
    filePath[bufferSize - 1] = '\0';
  }
}

Conclusion

In conclusion, a stack-buffer-overflow vulnerability has been discovered in the sc_path_print function of the OpenSC library. This vulnerability can potentially be exploited to read sensitive information or cause a denial-of-service condition. It is crucial for users to update their OpenSC installations to the latest patched version and stay vigilant for future security updates. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for opensc →

Share this vulnerability

FAQ

OpenSC is an open-source smart card library that provides cryptographic functions and smart card drivers.

The sc_path_print function in OpenSC is responsible for printing the path of a file on a smart card.

The stack-buffer-overflow vulnerability occurs when a file path exceeds the size of the buffer allocated for it in the sc_path_print function.

The vulnerability can allow an attacker to read sensitive information from the stack or cause a denial-of-service condition.

To protect yourself, make sure to update your OpenSC installation to the latest patched version once it becomes available. Regularly updating the OpenSC library is also recommended.

Related vulnerabilities

Recent vulnerabilities recorded for opensc.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. 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