Skip to content

NumPy 1.16.6+security.2: backport CVE-2021-41496 (f2py array_from_pyobj)#9

Open
icanhasmath wants to merge 2 commits into
v1.16.6.xfrom
v1.16.6.2
Open

NumPy 1.16.6+security.2: backport CVE-2021-41496 (f2py array_from_pyobj)#9
icanhasmath wants to merge 2 commits into
v1.16.6.xfrom
v1.16.6.2

Conversation

@icanhasmath

Copy link
Copy Markdown

ActiveState security release on the 1.16.6 line (DE-8118).

Fixed

Assessed — not applicable (table-only)

  • CVE-2021-33430 (GHSA-6p56-wp2h-9hxr) — already mitigated here: the nd > NPY_MAXDIMS guard is present at ctors.c:934, ahead of the descr->subarray memcpy.
  • CVE-2021-34141 (GHSA-fpfv-jqm9-f5jm) — disputed; the deprecated Numeric-style typecode strncmp only affects a DeprecationWarning, not the resolved dtype. No upstream security fix.

Release

  • Version bumped to the PEP 440 local form 1.16.6+security.2 in setup.py so the installed package self-reports the security level (1.16.6.1 == security.1).
  • Added doc/release/1.16.6+security.2-notes.rst + changelog.

Validation

C89 syntax-checked (incl. -Wdeclaration-after-statement); setup.py compiles and reports 1.16.6+security.2; NumpyVersion() tolerates the +local label. The f2py change is not runnable in this environment (build-generated _numpyconfig.h); it relies on the build pipeline (upstream shipped the same change without an added test).

icanhasmath and others added 2 commits June 8, 2026 16:07
array_from_pyobj() built its "must have defined dimensions" error string by
strcpy-ing a fixed prefix into a 200-byte stack buffer `mess` and then
sprintf-ing each of up to F2PY_MAX_DIMS (40) dimension values into it in a
loop, followed by a strcat. With enough negative dimensions this overflows
the fixed stack buffer (CVE-2021-41496 / GHSA-f7c7-j99h-c22f; local DoS).

Port the upstream fix (numpy/numpy 271010f, PR numpy#20630, closes
numpygh-19000): replace count_negative_dimensions() with
find_first_negative_dimension() and emit the error via a single bounded
PyErr_Format() reporting the first offending dimension, removing the
unbounded strcpy/sprintf-loop/strcat.

Kept a C89-style loop-variable declaration (this fork targets older MSVC; cf.
the CVE-2021-41495 compiler-compat fixups) and verified declaration-after-
statement clean. PyErr_Format and NPY_INTP_FMT are available in 1.16.6.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ActiveState security release on the 1.16.6 line, backporting the
CVE-2021-41496 fix in f2py array_from_pyobj.

- Bump the version to the PEP 440 local form 1.16.6+security.2 in setup.py so
  the installed package self-reports the security level (N counts AS security
  releases on this line; 1.16.6.1 == security.1). Verified NumpyVersion()
  tolerates the +local label (its leading-version regex is unanchored).
- Add doc/release/1.16.6+security.2-notes.rst and the matching changelog,
  recording the CVE-2021-41496 fix plus the two advisories assessed as not
  applicable (CVE-2021-33430 already mitigated here; CVE-2021-34141 disputed,
  no security impact / no upstream fix).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@martinPavesio martinPavesio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants