# CVE-2023-23931: Cipher.update_into can corrupt memory in pyca cryptography

> Attackers can corrupt memory by passing immutable buffers to Cipher.update_into, leading to data modification in applications using the pyca cryptography library.

- **Severity:** Medium 4.8 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 7 Feb 2023
- **Updated:** 3 Nov 2025
- **Also known as:** ALPINE-CVE-2023-23931, ALSA-2023:6615, ALSA-2023:7096, AZL-13353, AZL-35127, DEBIAN-CVE-2023-23931, DLA-3331-1, DLA-3331-2, GHSA-w7pp-m8wf-vj6r, MGASA-2023-0071, MINI-462x-826g-9pr9, OESA-2023-1085, OESA-2023-1088, OESA-2023-1090, OESA-2023-1113, PYSEC-2023-11, RHSA-2023:6615, RHSA-2023:7096, ROOT-APP-PYPI-CVE-2023-23931, SUSE-SU-2023:0722-1, SUSE-SU-2023:0722-2, SUSE-SU-2023:0737-1, SUSE-SU-2023:0837-1, SUSE-SU-2023:0838-1, SUSE-SU-2023:0839-1, SUSE-SU-2023:1763-1, SUSE-SU-2023:1767-1, SUSE-SU-2023:2144-1, SUSE-SU-2023:2218-1, UBUNTU-CVE-2023-23931, openSUSE-SU-2024:12681-1, openSUSE-SU-2024:12820-1, openSUSE-SU-2026:12020-1

## What is CVE-2023-23931?

CVE-2023-23931 is a medium-severity memory corruption vulnerability in pyca cryptography, published on 7 Feb 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

cryptography is a package designed to expose cryptographic primitives and recipes to Python developers. In affected versions `Cipher.update_into` would accept Python objects which implement the buffer protocol, but provide only immutable buffers. This would allow immutable objects (such as `bytes`) to be mutated, thus violating fundamental rules of Python and resulting in corrupted output. This now correctly raises an exception. This issue has been present since `update_into` was originally introduced in cryptography 1.8.

Weakness: CWE-754 (Improper Check for Unusual or Exceptional Conditions)

## Which versions are affected by CVE-2023-23931?

3 open source packages ship an affected version, including cryptography. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `cryptography` | PyPI | From 1.8 | 39.0.1 |
| `cryptography` | PyPI | From 1.8 | 39.0.1 |
| `cryptography` | PyPI | From 1.8 | 39.0.1 |
| `python3-cryptography` | AlmaLinux:8 | All versions | 3.2.1-6.el8 |
| `python3-cryptography` | AlmaLinux:9 | All versions | 36.0.1-4.el9 |
| `python-cryptography` | Red Hat:enterprise_linux:8::baseos | All versions | 0:3.2.1-6.el8 |
| `python-cryptography-debugsource` | Red Hat:enterprise_linux:8::baseos | All versions | 0:3.2.1-6.el8 |
| `python3-cryptography` | Red Hat:enterprise_linux:8::baseos | All versions | 0:3.2.1-6.el8 |
| `python3-cryptography-debuginfo` | Red Hat:enterprise_linux:8::baseos | All versions | 0:3.2.1-6.el8 |
| `python-cryptography` | Red Hat:enterprise_linux:9::baseos | All versions | 0:36.0.1-4.el9 |
| `python-cryptography-debugsource` | Red Hat:enterprise_linux:9::baseos | All versions | 0:36.0.1-4.el9 |
| `python3-cryptography` | Red Hat:enterprise_linux:9::baseos | All versions | 0:36.0.1-4.el9 |
| `python3-cryptography-debuginfo` | Red Hat:enterprise_linux:9::baseos | All versions | 0:36.0.1-4.el9 |
| `python-cffi` | SUSE:HPE Helion OpenStack 8 | All versions | 1.10.0-4.3.1 |
| `python-cryptography` | SUSE:HPE Helion OpenStack 8 | All versions | 2.0.3-3.14.2 |
| `venv-openstack-aodh` | SUSE:HPE Helion OpenStack 8 | All versions | 5.1.1~dev7-12.44.1 |
| `venv-openstack-barbican` | SUSE:HPE Helion OpenStack 8 | All versions | 5.0.2~dev3-12.47.1 |
| `venv-openstack-ceilometer` | SUSE:HPE Helion OpenStack 8 | All versions | 9.0.8~dev7-12.42.1 |
| `venv-openstack-cinder` | SUSE:HPE Helion OpenStack 8 | All versions | 11.2.3~dev29-14.46.1 |
| `venv-openstack-designate` | SUSE:HPE Helion OpenStack 8 | All versions | 5.0.3~dev7-12.43.1 |
| `venv-openstack-freezer` | SUSE:HPE Helion OpenStack 8 | All versions | 5.0.0.0~xrc2~dev2-10.40.1 |
| `venv-openstack-glance` | SUSE:HPE Helion OpenStack 8 | All versions | 15.0.3~dev3-12.43.1 |
| `venv-openstack-heat` | SUSE:HPE Helion OpenStack 8 | All versions | 9.0.8~dev22-12.49.1 |
| `venv-openstack-horizon-hpe` | SUSE:HPE Helion OpenStack 8 | All versions | 12.0.5~dev6-14.52.1 |
| `venv-openstack-ironic` | SUSE:HPE Helion OpenStack 8 | All versions | 9.1.8~dev8-12.45.1 |
| `venv-openstack-keystone` | SUSE:HPE Helion OpenStack 8 | All versions | 12.0.4~dev11-11.49.1 |
| `venv-openstack-magnum` | SUSE:HPE Helion OpenStack 8 | All versions | 5.0.2_5.0.2_5.0.2~dev31-11.44.1 |
| `venv-openstack-manila` | SUSE:HPE Helion OpenStack 8 | All versions | 5.1.1~dev5-12.49.1 |
| `venv-openstack-monasca` | SUSE:HPE Helion OpenStack 8 | All versions | 2.2.2~dev1-11.49.1 |
| `venv-openstack-monasca-ceilometer` | SUSE:HPE Helion OpenStack 8 | All versions | 1.5.1_1.5.1_1.5.1~dev3-8.40.1 |
| `venv-openstack-murano` | SUSE:HPE Helion OpenStack 8 | All versions | 4.0.2~dev3-12.42.1 |
| `venv-openstack-neutron` | SUSE:HPE Helion OpenStack 8 | All versions | 11.0.9~dev69-13.50.1 |
| `venv-openstack-nova` | SUSE:HPE Helion OpenStack 8 | All versions | 16.1.9~dev92-11.48.1 |
| `venv-openstack-octavia` | SUSE:HPE Helion OpenStack 8 | All versions | 1.0.6~dev3-12.45.1 |
| `venv-openstack-sahara` | SUSE:HPE Helion OpenStack 8 | All versions | 7.0.5~dev4-11.44.1 |
| `venv-openstack-swift` | SUSE:HPE Helion OpenStack 8 | All versions | 2.15.2_2.15.2_2.15.2~dev32-11.35.1 |
| `venv-openstack-trove` | SUSE:HPE Helion OpenStack 8 | All versions | 8.0.2~dev2-11.44.1 |
| `python-cryptography` | SUSE:Linux Enterprise High Performance Computing 15 SP1-LTSS | All versions | 2.9.2-150100.7.12.1 |
| `python-cryptography` | SUSE:Linux Enterprise Micro 5.1 | All versions | 3.3.2-150200.19.1 |
| `python-cryptography` | SUSE:Linux Enterprise Micro 5.2 | All versions | 3.3.2-150200.19.1 |

Products: Cryptography.io Cryptography.

## How do I fix CVE-2023-23931?

Upgrade cryptography to 39.0.1 or later.

## Is CVE-2023-23931 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-23931 exists.

## Other vulnerabilities in pyca cryptography

- [CVE-2020-36242](https://insights.sbomify.com/CVE-2020-36242/): PyCA Cryptography symmetrically encrypting large values can lead to integer overflow (critical 9.1)
- [CVE-2026-26007](https://insights.sbomify.com/CVE-2026-26007/): cryptography Subgroup Attack Due to Missing Subgroup Validation for SECT Curves (high 8.2)
- [CVE-2024-26130](https://insights.sbomify.com/CVE-2024-26130/): cryptography NULL pointer dereference with pkcs12.serialize_key_and_certificates when called with a non-matching certificate and private key and an hmac_hash override (high 7.5)
- [CVE-2023-38325](https://insights.sbomify.com/CVE-2023-38325/): cryptography mishandles SSH certificates (high 7.5)
- [CVE-2026-39892](https://insights.sbomify.com/CVE-2026-39892/): cryptography has a buffer overflow if non-contiguous buffers were passed to APIs (medium 6.9)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-23931 and fix it if it is affected.

What it is: CVE-2023-23931 is a medium-severity memory corruption vulnerability in pyca cryptography, published on 7 Feb 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-23931 exists.

Affected packages and fixed versions:
- cryptography (PyPI): affected from 1.8; fixed in 39.0.1
- cryptography (PyPI): affected from 1.8; fixed in 39.0.1
- cryptography (PyPI): affected from 1.8; fixed in 39.0.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-23931/ (Markdown: https://insights.sbomify.com/CVE-2023-23931/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-23931
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-23931
- OSV: https://osv.dev/vulnerability/CVE-2023-23931

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-23931/
Summaries are generated and may contain mistakes; the official description above is the record.
