Every CVESearch/Get API key

CVE-2026-141548

pymonocypher: argon2i_32 can overflow the heap on 32-bit builds when nb_blocks >= 2**22 (work area size wraps) (PyPI)

Explain with AI
ChatGPTClaudeGoogle AI
Severity
3.3Low
Local attack, no privileges, needs user interactionCVSS 3.1, CVE List
Exploitation
Proof of concept
CISA reports one, no source links it
Exploit chance
0.21% in 30 days
Percentile11th
EPSS, scored
Listed fix
4.0.3.6 for pymonocypher
From GitHub Advisories

Overview

pymonocypher uses cython to wrap the Monocypher C library. From 4.0.2.4 until 4.0.3.6, argon2i_32 in c_monocypher.pyx multiplies nb_blocks by 1024 in a 32-bit size_t, causing the allocated work-area size to wrap when nb_blocks is at least 222. When the smaller allocation succeeds, crypto_argon2 fills 1024-byte blocks up to nb_blocks rounded down to a multiple of four, causing an out-of-bounds heap write that can crash the calling process. If the allocation fails, the call instead raises MemoryError. An affected application must run a 32-bit build and pass an attacker-influenced nb_blocks value without bounding it below 222; 64-bit builds and callers enforcing that bound are not affected. This issue is fixed in version 4.0.3.6.

CVSS 3.1 vector

Exploitability

Attack vector
Local
Complexity
Low
Privileges needed
None
User interaction
Required

Impact

Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
Low
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L

Exploit chance over time

Unchanged since Dec 3, 2026
EPSS score 0.21% every day from Dec 3, 2026 to Dec 4, 2026.

Affected

Packages 1

Affected packages
PackageAffectedFixed
pymonocypher
PyPI
4.0.2.4 up to 4.0.3.6
4.0.3.6

Products 1

Sources

CVE List Score usedCVSS 3.13.3

pymonocypher: argon2i_32 can overflow the heap on 32-bit builds when nb_blocks >= 2**22 (work area size wraps)

pymonocypher uses cython to wrap the Monocypher C library. From 4.0.2.4 until 4.0.3.6, argon2i_32 in c_monocypher.pyx multiplies nb_blocks by 1024 in a 32-bit size_t, causing the allocated work-area size to wrap when nb_blocks is at least 222. When the smaller allocation succeeds, crypto_argon2 fills 1024-byte blocks up to nb_blocks rounded down to a multiple of four, causing an out-of-bounds heap write that can crash the calling process. If the allocation fails, the call instead raises MemoryError. An affected application must run a 32-bit build and pass an attacker-influenced nb_blocks value without bounding it below 222; 64-bit builds and callers enforcing that bound are not affected. This issue is fixed in version 4.0.3.6.

Record
CVE-2026-141548
CVSS 3.1
3.3 LowCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
Weakness
CWE-190, CWE-787
Updated
2026-12-05
EUVDEUVD-2026-141857CVSS 3.13.3

pymonocypher uses cython to wrap the Monocypher C library. From 4.0.2.4 until 4.0.3.6, argon2i_32 in c_monocypher.pyx multiplies nb_blocks by 1024 in a 32-bit size_t, causing the allocated work-area size to wrap when nb_blocks is at least 222. When the smaller allocation succeeds, crypto_argon2 fills 1024-byte blocks up to nb_blocks rounded down to a multiple of four, causing an out-of-bounds heap write that can crash the calling process. If the allocation fails, the call instead raises MemoryError. An affected application must run a 32-bit build and pass an attacker-influenced nb_blocks value without bounding it below 222; 64-bit builds and callers enforcing that bound are not affected. This issue is fixed in version 4.0.3.6.

Record
EUVD-2026-141857
CVSS 3.1
3.3 LowCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
Updated
2026-12-02
GitHub AdvisoriesGHSA-q7gf-2v9f-xq2pCVSS 3.13.3

pymonocypher: argon2i_32 can overflow the heap on 32-bit builds when nb_blocks >= 2**22 (work area size wraps)

Summary

On builds where size_t is 32 bits, argon2i_32() computes the size of the Argon2 work area as nb_blocks * 1024 in size_t, and the product wraps for nb_blocks >= 2**22. malloc is then asked for a much smaller buffer (8 KiB for nb_blocks = 2**22 + 8), while crypto_argon2() still fills about nb_blocks blocks of 1 KiB (it rounds the count down to a multiple of 4). Whenever that small allocation succeeds, the result is a heap buffer overflow (write). The three such cases I ran ended in a segmentation fault, where a caller would expect MemoryError. For some values the wrapped size is itself too large (for example nb_blocks = 2**32 - 1); then malloc fails and the call raises MemoryError.

The scope is narrow:

  • Only 32-bit builds are affected. Every wheel on PyPI for the affected releases is 64-bit, and there the product cannot wrap. A 32-bit build comes from the sdist (for example on i386 or armhf) or from piwheels, which publishes linux_armv6l and linux_armv7l wheels for the affected releases.
  • nb_blocks is normally a constant chosen by the developer, and a request for 4 GiB or more cannot succeed on a 32-bit platform anyway. An application is exposed only if it passes an nb_blocks value that it does not control (for example a cost parameter read from a stored record or a file header) without capping it below 2**22. I did not find a public project that does this. Without such a caller this is a robustness fix, and the severity below is conditional on one existing.

GHSA-8f95-v3jq-cj86 was about the same buffer and the same parameter. It covered nb_blocks < 8; this report covers large values. The lower-bound check added for that advisory (90ff5b1) and the NULL check added in 4.0.3.2 (e6b933a) are both present in 4.0.3.5, and neither covers the multiplication.

Affected versions

Everything was run on linux/386 (Docker image i386/python:3.12: CPython 3.12.16, GCC 14.2.0, glibc 2.41, 32-bit userland on an x86_64 kernel). Each release was built from its PyPI sdist with pip install --no-binary pymonocypher pymonocypher==<version>. The call is argon2i_32(2**22 + 8, 1, b'password', b'somesalt').

| Version | How checked | Result | | --- | --- | --- | | 4.0.3.5 (latest release, sdist sha256 b6f96c4fa56212a7c13aee8fc27a89d7531b622ce8aabbd6e82a9d2e93071d71) | run, plain and ASan builds | SIGSEGV; ASan: heap-buffer-overflow, WRITE | | main at fca8485 (4.0.3.6, unreleased) | run | SIGSEGV | | 4.0.3.4, 4.0.3.2, 4.0.2.8 | run | SIGSEGV | | 4.0.2.4 | run, plain and ASan builds | SIGSEGV; ASan: heap-buffer-overflow, WRITE | | 4.0.3.3, 4.0.3.1, 4.0.3.0, 4.0.2.7, 4.0.2.6, 4.0.2.5 | source only, not run | same allocation line in the tag | | 4.0.2.3, 4.0.2.2, 4.0.2.1 | run | not reachable: argon2i_32 raises AttributeError: 'dict' object has no attribute 'nb_block' for every input | | 3.1.3.6 | run | not affected: OverflowError |

That gives >= 4.0.2.4, <= 4.0.3.5. The casts arrived in 3851366 (4.0.2.2). Before that the line was malloc(nb_blocks * 1024), which multiplies Python integers and raises OverflowError when the result does not fit size_t, as 3.1.3.6 still does. ASan confirms the out-of-bounds write on 4.0.3.5 and 4.0.2.4. For the other versions I ran, the evidence is the SIGSEGV together with the identical allocation line.

64-bit builds are not affected: nb_blocks is at most 2**32 - 1, so the product fits.

It was not run a 32-bit ARM build. The piwheels wheel pymonocypher-4.0.3.5-cp313-cp313-linux_armv7l.whl (sha256 3196726fa0ec746d77111c836d04d26a034ab5b2b0564ff3a5775b7fb7e2291b) was the only thing looked at in a disassembler: the extension is a 32-bit ARM ELF, and argon2i_32 has lsl r0, r0, #10 directly before bl malloc.

Root cause

c_monocypher.pyx at fca8485 (the file differs from the v4.0.3.5 tag only in the version string):

418:    config.nb_blocks = nb_blocks
422:    if config.nb_blocks < (config.nb_lanes * 8):
423:      …
Record
GHSA-q7gf-2v9f-xq2p
CVSS 3.1
3.3 LowCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
Weakness
CWE-190, CWE-787
Updated
2026-12-04
NVDCVSS 3.13.3

pymonocypher uses cython to wrap the Monocypher C library. From 4.0.2.4 until 4.0.3.6, argon2i_32 in c_monocypher.pyx multiplies nb_blocks by 1024 in a 32-bit size_t, causing the allocated work-area size to wrap when nb_blocks is at least 222. When the smaller allocation succeeds, crypto_argon2 fills 1024-byte blocks up to nb_blocks rounded down to a multiple of four, causing an out-of-bounds heap write that can crash the calling process. If the allocation fails, the call instead raises MemoryError. An affected application must run a 32-bit build and pass an attacker-influenced nb_blocks value without bounding it below 222; 64-bit builds and callers enforcing that bound are not affected. This issue is fixed in version 4.0.3.6.

Record
CVE-2026-141548
CVSS 3.1
3.3 LowCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
Weakness
CWE-190, CWE-787
Updated
2026-12-05
OSVCVSS 3.13.3

pymonocypher: argon2i_32 can overflow the heap on 32-bit builds when nb_blocks >= 2**22 (work area size wraps)

pymonocypher uses cython to wrap the Monocypher C library. From 4.0.2.4 until 4.0.3.6, argon2i_32 in c_monocypher.pyx multiplies nb_blocks by 1024 in a 32-bit size_t, causing the allocated work-area size to wrap when nb_blocks is at least 222. When the smaller allocation succeeds, crypto_argon2 fills 1024-byte blocks up to nb_blocks rounded down to a multiple of four, causing an out-of-bounds heap write that can crash the calling process. If the allocation fails, the call instead raises MemoryError. An affected application must run a 32-bit build and pass an attacker-influenced nb_blocks value without bounding it below 222; 64-bit builds and callers enforcing that bound are not affected. This issue is fixed in version 4.0.3.6.

Record
CVE-2026-141548
CVSS 3.1
3.3 LowCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L
Weakness
CWE-190, CWE-787
Updated
2026-12-03

The JSON record also has the rest of 1 source description.

History

Recorded by Every CVE

Changes recorded by Every CVE
DayChangedSources
Key facts, referencesCVE List
Affected packages, key facts, referencesGitHub Advisories, OSV
Other IDs, referencesOSV
Other IDs, published dateEUVD, NVD
First indexedCVE List

Upstream dates may differ.

References

MoveEnter Open