CVE-2025-66038: 
NixOS vulnerability analysis and mitigation

Overview

CVE-2025-66038 is a buffer over-read vulnerability in OpenSC's sc_compacttlv_find_tag function that can return out-of-bounds pointers when parsing maliciously crafted compact-TLV data, such as that found in smart card Answer to Reset (ATR) historical bytes. It affects all OpenSC versions prior to 0.27.0 (including 0.26.1 and earlier). The vulnerability was disclosed on March 30, 2026, and was originally discovered by Harrison Green from CMU via the STITCH autonomous fuzzing system. The CVSS v3.1 base score is 6.8 (Medium/High) per NVD, though the OpenSC advisory assigns a lower score of 3.9 (Low) reflecting the physical attack vector and high complexity (GitHub Advisory, OpenSC Wiki).

Technical details

The root cause is insufficient bounds validation in the sc_compacttlv_find_tag function (CWE-126: Buffer Over-read; CWE-805: Buffer Access with Incorrect Length Value). In compact-TLV encoding, a single byte encodes both the tag (high nibble) and value length (low nibble). When given a 1-byte buffer {0x0A}, the function interprets tag=0 and length=10, but does not verify that the claimed 10-byte value fits within the remaining buffer — which contains zero bytes. As a result, the function returns a pointer to buf+1 with outlen=10, pointing beyond the buffer boundary. When downstream code dereferences this out-of-bounds pointer, memory corruption can occur. The vulnerability is reachable via untrusted data from smart cards or files, specifically through the PIV driver's parsing of historical bytes in ATR responses (GitHub Advisory, OpenSC Wiki).

Impact

Successful exploitation can result in memory corruption, application crashes (denial of service), and potentially unauthorized reads of memory contents (confidentiality impact). Because the vulnerability resides in the libopensc library, it is accessible from OpenSC tools, the PKCS#11 module, the minidriver, and the Cryptographic Token Kit (CTK), broadening the attack surface across all consumers of the library. Integrity and availability impacts are possible if downstream code writes to the out-of-bounds pointer, though the practical severity is constrained by the physical access requirement (OpenSC Wiki, GitHub Advisory).

Exploitability

A proof-of-concept (PoC) C++ testcase with a complete Dockerfile and build instructions is publicly available in the GitHub Security Advisory, demonstrating the out-of-bounds pointer condition (GitHub Advisory). Exploitation requires physical access to the target system — an attacker must present a crafted USB smart card or device that returns malicious ATR data. There is no evidence of in-the-wild exploitation, no known threat actor attribution, and the vulnerability is not listed in the CISA KEV catalog. The EPSS score is approximately 0.015% (0.000150), reflecting very low probability of automated exploitation (Feedly).

Exploitation steps

  1. Prepare a malicious smart card or USB device: Craft a smart card or USB token that returns a specially crafted Answer to Reset (ATR) with invalid compact-TLV encoding in the historical bytes — specifically, a 1-byte value {0x0A} that claims tag=0 and length=10 with no following value bytes.
  2. Gain physical access: Insert the malicious smart card or USB device into a target system running a vulnerable version of OpenSC (< 0.27.0).
  3. Trigger ATR parsing: Initiate any operation that causes OpenSC to read and parse the card's ATR historical bytes via the PIV driver, such as connecting to the card reader or running an OpenSC tool (e.g., opensc-tool, pkcs11-tool).
  4. Trigger out-of-bounds pointer return: The sc_compacttlv_find_tag function processes the crafted buffer and returns a pointer to buf+1 with outlen=10, pointing beyond the allocated buffer.
  5. Achieve memory corruption: Downstream code that dereferences the returned out-of-bounds pointer reads or writes beyond the buffer, potentially causing a crash or unexpected behavior that could be leveraged for further exploitation (GitHub Advisory, OpenSC Wiki).

Indicators of compromise

  • Physical: Unrecognized or unusual smart cards or USB tokens inserted into systems running OpenSC.
  • Logs: Application crashes or segmentation faults in OpenSC tools (opensc-tool, pkcs11-tool, piv-tool) or PKCS#11-consuming applications (e.g., Firefox, SSH agents) logged in system logs (/var/log/syslog, journalctl).
  • Process: Unexpected termination of processes using the OpenSC PKCS#11 module or minidriver, particularly during card insertion or ATR parsing events.
  • File System: Core dump files generated by OpenSC tools or applications linking against libopensc, potentially in /var/crash/ or the working directory of the affected process.

Mitigation and workarounds

The primary remediation is to upgrade OpenSC to version 0.27.0 or later, which includes the fix applied in commit a20b91adc2fc66785c0df98abc8ef456c0eaab9d (OpenSC Wiki). As a workaround where patching is not immediately possible, restrict physical access to systems to trusted personnel only and prohibit the use of smart cards or USB tokens from untrusted sources. Organizations using OpenSC in sensitive environments (e.g., PIV/CAC authentication) should prioritize patching given the library's broad exposure through PKCS#11, minidriver, and CTK interfaces (GitHub Advisory).

Community reactions

The vulnerability was reported by Harrison Green from Carnegie Mellon University and discovered via the STITCH autonomous fuzzing system, with patches provided by Jakub Jelen of the OpenSC project (OpenSC Wiki). Red Hat, Microsoft (Azure Linux), openSUSE, and Fedora have all issued advisories or package updates addressing this CVE, indicating broad downstream distribution response (Red Hat, Microsoft MSRC). Community reaction has been measured given the low severity rating and physical access requirement, with no significant social media controversy observed.

Additional resources

Linux Distribution fix status

Fix availability across major Linux distributions and their releases.

Debian

Fixed

bookworm

opensc

Affected

sid

opensc: 0.27.0~rc1-1

Fixed

trixie

opensc

Affected

Ubuntu

Unknown

bionic (esm-apps)

opensc

Unknown

devel

opensc

Unknown

focal (esm-apps)

opensc

Unknown

jammy

opensc

Unknown

jammy (esm-apps)

opensc

Unknown

noble

opensc

Unknown

noble (esm-apps)

opensc

Unknown

resolute

opensc

Unknown

RHEL / CentOS

Affected

RHEL 8

opensc.src

Affected

RHEL 9

opensc.src

Affected

RHEL 10

opensc.src

Affected

Alpine

Fixed

edge

opensc: 0.27.1-r0

Fixed

Source: This report was generated using AI

Related NixOS vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-112940HIGH7.1
  • Python logoPython
  • py3-filelock
NoYesOct 20, 2026
CVE-2026-112937MEDIUM6.1
  • Python logoPython
  • python-filelock
NoYesOct 20, 2026
CVE-2026-112936MEDIUM6.1
  • Python logoPython
  • python-filelock
NoYesOct 20, 2026
CVE-2026-112939MEDIUM4.7
  • Python logoPython
  • python-filelock
NoYesOct 20, 2026
CVE-2026-112941LOW3.3
  • Python logoPython
  • filelock
NoYesOct 20, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management