Stack-buffer-overflow in sc_asn1_read_tag in opensc
Summary
OSV-2022-437: Stack-buffer-overflow in sc_asn1_read_tag. Affects opensc versions >= 74a8f296e0f195916d28e1c928f457e04aa22892, < 972d3292eee44e9b4c61769365a3ec651ec18f39. Fixed in 972d3292eee44e9b4c61769365a3ec651ec18f39. How to fix ↓
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.
No signup required · Results in about 60 seconds
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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for opensc.