CVE-2026-40528: OpenSC < 0.27.0 Buffer Overrun in do_key_value() via profile.c
OpenSC before 0.27.0, fixed in commit 0358817, contains a stack and heap buffer overrun vulnerability in the do_key_value() function in src/pkcs15init/profile.c that allows attackers to corrupt memory by supplying a crafted profile configuration file. During pkcs15-init invocation, a key value entry beginning with '=' followed by more than sizeof(keybuf) characters is copied into keybuf via memcpy without a length check, causing both stack and heap buffer overruns.
Security readout for executives and security teams
Plain-English summary
OpenSC before 0.27.0 can mishandle a specially crafted profile configuration file and corrupt memory during pkcs15-init use. The business risk is limited because exploitation requires local or physical access conditions and user interaction, but systems that provision smart cards with shared or externally supplied profiles should prioritize updating.
Executive priority
Treat this as a targeted maintenance fix, not an emergency. Update affected OpenSC deployments during the next security patch cycle, with faster handling for smart-card provisioning systems that process profiles from users, vendors, or shared repositories.
Technical view
The issue is a stack and heap buffer overrun in do_key_value() in src/pkcs15init/profile.c. A key value beginning with '=' and exceeding keybuf length is copied with memcpy without a length check. The CVSS 3.1 score is 3.8, with low confidentiality, integrity, and availability impact.
Likely exposure
Exposure is most likely on endpoints or provisioning systems running OpenSC before 0.27.0 where pkcs15-init processes profile configuration files that could be supplied or influenced by an attacker.
Exploitation context
The provided sources do not show active exploitation, and the CVE is not marked KEV. Exploitation requires a crafted profile configuration file, pkcs15-init invocation, high attack complexity, and user interaction under the published CVSS vector.
Researcher notes
The memory corruption path is tied to profile parsing in pkcs15-init, specifically unchecked copying into keybuf. The sources identify CWE-121 and CWE-122, but do not provide proof of reliable code execution, public exploitation, or broader affected products beyond OpenSC before 0.27.0.
Mitigation direction
Upgrade OpenSC to 0.27.0 or a vendor package containing commit 0358817.
Restrict who can create, modify, or supply OpenSC profile configuration files.
Avoid processing profile files from untrusted sources.
Check operating system vendor advisories for backported OpenSC fixes.
Prioritize smart-card provisioning hosts before general endpoints.
Validation and detection
Inventory systems with OpenSC installed and record package versions.
Confirm whether pkcs15-init is used in provisioning workflows.
Review OpenSC package changelogs for commit 0358817 or equivalent fix.
Audit write access to OpenSC profile configuration locations.
Check whether externally supplied profile files are accepted operationally.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-121: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-121 · source CWE mapping
Stack-based Buffer Overflow
Stack-based Buffer Overflow represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Heap-based Buffer Overflow represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.