VYPR
Critical severity9.8NVD Advisory· Published May 17, 2026· Updated May 18, 2026

CVE-2026-8507

CVE-2026-8507

Description

Crypt::OpenSSL::PKCS12 versions through 1.94 for Perl have out-of-bounds (OOB) write flaws.

When parsing a PKCS12 file, with a >= 1 GiB OCTET STRING (or BIT STRING) attribute on a SAFEBAG, via info() or info_as_hash(), a heap out-of-bounds write would be triggered with remote-code-execution potential (RCE) due to a signed integer overflow in the size calculation passed to Renew().

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Heap OOB write in Crypt::OpenSSL::PKCS12 ≤1.94 via integer overflow when parsing large OCTET/BIT STRING attributes, enabling RCE.

Vulnerability

A heap out-of-bounds write vulnerability exists in the print_attribute function of PKCS12.xs in Crypt::OpenSSL::PKCS12 versions through 1.94 [1][2]. When parsing a PKCS12 file containing a SAFEBAG with an OCTET STRING or BIT STRING attribute whose length is at least 1 GiB (≥ 0x40000000), the multiplication length * 4 overflows a signed int, producing a near-zero value. This causes Renew() to allocate a tiny buffer, after which get_hex() writes approximately 3 GiB of data past the allocated region [3]. The bug is reachable via the info() and info_as_hash() methods [2].

Exploitation

An attacker must supply a crafted PKCS12 file with a malicious attribute length field. No authentication or special privileges are required; the victim triggers the vulnerability by calling info() or info_as_hash() on the file. The attack can be delivered remotely (e.g., via email attachment, web upload, or any mechanism that causes a Perl application to parse the file). The integer overflow occurs during the size calculation, leading to a heap buffer under-allocation and subsequent OOB write [2][3].

Impact

Successful exploitation can result in remote code execution (RCE) with the privileges of the Perl process. The out-of-bounds write can corrupt heap metadata or overwrite function pointers, allowing arbitrary code execution. The CVSS v3 score of 9.8 (Critical) reflects the high impact on confidentiality, integrity, and availability [1][2].

Mitigation

The vulnerability is fixed in version 1.95, released on 2026-05-17 [1]. The patch adds explicit length checks: if the attribute length is negative or exceeds INT_MAX/4, the function croaks with a diagnostic message. The multiplication is also promoted to size_t to prevent overflow [3]. Users should upgrade to version 1.95 immediately. No workaround is available [1][2].

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

1

Patches

1
b9d0469c6d8f

Fix CVE-2026-8507: integer overflow in print_attribute leading to heap OOB write

1 file changed · +10 2
  • PKCS12.xs+10 2 modified
    @@ -679,7 +679,11 @@ void print_attribute(pTHX_ BIO *out, CONST_ASN1_TYPE *av, char **attribute)
     
       case V_ASN1_OCTET_STRING:
         if(*attribute != NULL) {
    -      Renew(*attribute, av->value.octet_string->length * 4, char);
    +      if (av->value.octet_string->length < 0 ||
    +          av->value.octet_string->length > INT_MAX / 4)
    +        croak("OCTET STRING attribute length out of range (got %d)",
    +              av->value.octet_string->length);
    +      Renew(*attribute, (size_t)av->value.octet_string->length * 4, char);
           get_hex(*attribute, av->value.octet_string->data, av->value.octet_string->length);
         } else {
           hex_prin(out, av->value.octet_string->data,
    @@ -690,7 +694,11 @@ void print_attribute(pTHX_ BIO *out, CONST_ASN1_TYPE *av, char **attribute)
     
       case V_ASN1_BIT_STRING:
         if(*attribute != NULL) {
    -      Renew(*attribute, av->value.bit_string->length *4, char);
    +      if (av->value.bit_string->length < 0 ||
    +          av->value.bit_string->length > INT_MAX / 4)
    +        croak("BIT STRING attribute length out of range (got %d)",
    +              av->value.bit_string->length);
    +      Renew(*attribute, (size_t)av->value.bit_string->length * 4, char);
           get_hex(*attribute, av->value.bit_string->data, av->value.bit_string->length);
         } else {
           hex_prin(out, av->value.bit_string->data,
    

Vulnerability mechanics

Root cause

"Signed integer overflow in the size calculation passed to Renew() when multiplying an ASN1_STRING.length (declared as int) by 4, causing a near-empty buffer allocation while get_hex writes ~3 GiB past it."

Attack vector

An attacker supplies a crafted PKCS12 file containing a SAFEBAG with an OCTET STRING or BIT STRING attribute whose length is >= 1 GiB (0x40000000 or greater). When the application calls info() or info_as_hash() on this file, print_attribute multiplies the signed int length by 4; the multiplication overflows to a small value (or zero), causing Renew() to allocate a tiny buffer. The subsequent get_hex() call then writes the full hex-encoded representation of the attribute data far past the end of that buffer, resulting in a heap out-of-bounds write [CWE-787]. No authentication is required and the attack is network-triggered via any application that parses a PKCS12 blob from an untrusted source.

Affected code

The vulnerability resides in the print_attribute function within PKCS12.xs. The two vulnerable code paths are the V_ASN1_OCTET_STRING case (line 682) and the V_ASN1_BIT_STRING case (line 693), where av->value.octet_string->length and av->value.bit_string->length (both declared as int) are multiplied by 4 without overflow checking or promotion to size_t before being passed to Renew().

What the fix does

The patch adds two guards before each Renew() call [patch_id=424446]. First, it rejects negative lengths and lengths exceeding INT_MAX/4, which would cause the multiplication to overflow. Second, it casts the length operand to size_t before the multiplication, ensuring the arithmetic is performed at unsigned (size_t) precision rather than signed int precision. Together these changes prevent the integer overflow that led to undersized buffer allocation and the subsequent heap OOB write.

Preconditions

  • inputThe application must call info() or info_as_hash() on a PKCS12 file containing a SAFEBAG with an OCTET STRING or BIT STRING attribute whose length is >= 0x40000000 (1 GiB).
  • authNo authentication or special privileges required; the attacker only needs to supply the crafted PKCS12 file to a parser.
  • networkThe attack is network-triggerable; the PKCS12 file can be delivered over any network protocol the application accepts.

Generated on May 19, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.