CVE-2021-3177: Buffer Overflow

Published Jan 19, 2021
·
Updated

A flaw was found in python. A stack-based buffer overflow was discovered in the ctypes module provided within Python. Applications that use ctypes without carefully validating the input passed to it may be vulnerable to this flaw, which would allow an attacker to overflow a buffer on the stack and crash the application. The highest threat from this vulnerability is to system availability.

Other sources

Python 3.x through 3.9.1 has a buffer overflow in PyCArgrepr in ctypes/callproc.c, which may lead to remote code execution in certain Python applications that accept floating-point numbers as untrusted input, as demonstrated by a 1e300 argument to cdouble.fromparam. This occurs because sprintf is used unsafely.

Python 3.x through 3.9.1 has a buffer overflow in PyCArgrepr in ctypes/callproc.c, which may lead to remote code execution in certain Python applications that accept floating-point numbers as untrusted input.

Reference:

https://bugs.python.org/issue42938 https://github.com/python/cpython/pull/24239

— Red Hat

Python is vulnerable to a buffer overflow, caused by improper bounds checking by the PyCArgrepr function in ctypes/callproc.c. By sending specially-crafted arguments to cdouble.fromparam, a remote attacker could overflow a buffer and execute arbitrary code on the system.

— IBM

Affected Software

52 affected componentsFixes available
redhat/python<0:2.7.5-92.el7_9
0:2.7.5-92.el7_9
redhat/python3<0:3.6.8-37.el8
0:3.6.8-37.el8
redhat/python27-babel<0:0.9.6-10.el7
0:0.9.6-10.el7
redhat/python27-python<0:2.7.18-3.el7
0:2.7.18-3.el7
redhat/python27-python-jinja2<0:2.6-16.el7
0:2.6-16.el7
redhat/python27-python-pygments<0:1.5-5.el7
0:1.5-5.el7
redhat/rh-python38-babel<0:2.7.0-12.el7
0:2.7.0-12.el7
redhat/rh-python38-python<0:3.8.11-2.el7
0:3.8.11-2.el7
redhat/rh-python38-python-cryptography<0:2.8-5.el7
0:2.8-5.el7
redhat/rh-python38-python-jinja2<0:2.10.3-6.el7
0:2.10.3-6.el7
redhat/rh-python38-python-lxml<0:4.4.1-7.el7
0:4.4.1-7.el7
redhat/rh-python38-python-pip<0:19.3.1-2.el7
0:19.3.1-2.el7
redhat/rh-python38-python-urllib3<0:1.25.7-7.el7
0:1.25.7-7.el7
Python Python>=3.6.0<=3.6.12
Python Python>=3.7.0<=3.7.9
Python Python>=3.8.0<=3.8.7
Python Python>=3.9.0<=3.9.1
Fedoraproject Fedora=32
Fedoraproject Fedora=33
NetApp Active Iq Unified Manager Vmware Vsphere
NetApp Active Iq Unified Manager Windows
NetApp ONTAP Select Deploy administration utility
Debian Debian Linux=9.0
Oracle Communications Cloud Native Core Network Function Cloud Native Environment=22.2.0
Oracle Communications Offline Mediation Controller=12.0.0.3.0
Oracle Communications Pricing Design Center=12.0.0.3.0
Oracle Enterprise Manager Ops Center=12.4.0.0
Oracle ZFS Storage Appliance Kit=8.8
alpine/python2<2.7.18-r1
2.7.18-r1
alpine/python2<2.7.18-r1
2.7.18-r1
alpine/python3<3.7.7-r2
3.7.7-r2
alpine/python3<3.8.2-r2
3.8.2-r2
alpine/python3<3.8.5-r1
3.8.5-r1
alpine/python3<3.8.7-r1
3.8.7-r1
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
alpine/python3<3.8.7-r2
3.8.7-r2
debian/python2.7<2.7.18-2
2.7.18-2
debian/python3.9<3.9.1-3
3.9.1-3
debian/python2.7
2.7.13-2+deb9u62.7.16-2+deb10u22.7.18-2
debian/python3.5
3.5.3-1+deb9u4
debian/python3.7
3.7.3-2+deb10u3
debian/python3.8
debian/python3.9
3.9.1-3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/python to a version that resolves this vulnerability.

    Fixed in 0:2.7.5-92.el7_9
  2. Upgrade

    Upgrade redhat/python3 to a version that resolves this vulnerability.

    Fixed in 0:3.6.8-37.el8
  3. Upgrade

    Upgrade redhat/python27-babel to a version that resolves this vulnerability.

    Fixed in 0:0.9.6-10.el7
  4. Upgrade

    Upgrade redhat/python27-python to a version that resolves this vulnerability.

    Fixed in 0:2.7.18-3.el7
  5. Upgrade

    Upgrade redhat/python27-python-jinja2 to a version that resolves this vulnerability.

    Fixed in 0:2.6-16.el7
  6. Upgrade

    Upgrade redhat/python27-python-pygments to a version that resolves this vulnerability.

    Fixed in 0:1.5-5.el7
  7. Upgrade

    Upgrade redhat/rh-python38-babel to a version that resolves this vulnerability.

    Fixed in 0:2.7.0-12.el7
  8. Upgrade

    Upgrade redhat/rh-python38-python to a version that resolves this vulnerability.

    Fixed in 0:3.8.11-2.el7
  9. Upgrade

    Upgrade redhat/rh-python38-python-cryptography to a version that resolves this vulnerability.

    Fixed in 0:2.8-5.el7
  10. Upgrade

    Upgrade redhat/rh-python38-python-jinja2 to a version that resolves this vulnerability.

    Fixed in 0:2.10.3-6.el7
  11. Upgrade

    Upgrade redhat/rh-python38-python-lxml to a version that resolves this vulnerability.

    Fixed in 0:4.4.1-7.el7
  12. Upgrade

    Upgrade redhat/rh-python38-python-pip to a version that resolves this vulnerability.

    Fixed in 0:19.3.1-2.el7
  13. Upgrade

    Upgrade redhat/rh-python38-python-urllib3 to a version that resolves this vulnerability.

    Fixed in 0:1.25.7-7.el7
  14. Upgrade

    Upgrade alpine/python2 to a version that resolves this vulnerability.

    Fixed in 2.7.18-r1
  15. Upgrade

    Upgrade alpine/python3 to a version that resolves this vulnerability.

    Fixed in 3.7.7-r2
  16. Upgrade

    Upgrade alpine/python3 to a version that resolves this vulnerability.

    Fixed in 3.8.2-r2
  17. Upgrade

    Upgrade alpine/python3 to a version that resolves this vulnerability.

    Fixed in 3.8.5-r1
  18. Upgrade

    Upgrade alpine/python3 to a version that resolves this vulnerability.

    Fixed in 3.8.7-r1
  19. Upgrade

    Upgrade alpine/python3 to a version that resolves this vulnerability.

    Fixed in 3.8.7-r2
  20. Upgrade

    Upgrade debian/python2.7 to a version that resolves this vulnerability.

    Fixed in 2.7.18-2
  21. Upgrade

    Upgrade debian/python3.9 to a version that resolves this vulnerability.

    Fixed in 3.9.1-3
  22. Upgrade

    Upgrade debian/python2.7 to a version that resolves this vulnerability.

    Fixed in 2.7.13-2+deb9u6Fixed in 2.7.16-2+deb10u2Fixed in 2.7.18-2
  23. Upgrade

    Upgrade debian/python3.5 to a version that resolves this vulnerability.

    Fixed in 3.5.3-1+deb9u4
  24. Upgrade

    Upgrade debian/python3.7 to a version that resolves this vulnerability.

    Fixed in 3.7.3-2+deb10u3

Event History

Jan 19, 2021
CVE Published
via MITRE·12:00 AM
Data Sourced
12:00 AM
RemedyDescriptionSeverityWeaknessAffected Software
Data Sourced
via Ubuntu·12:00 AM
RemedyDescriptionSeverityAffected Software
Data Sourced
via MITRE·12:00 AM
Description
Updated
via Ubuntu·12:00 AM
Remedy
Updated
via Ubuntu·12:00 AM
Affected Software
Updated
via Ubuntu·12:00 AM
RemedyDescriptionAffected Software
Data Sourced
via OSV·06:15 AM
DescriptionSeverityAffected Software
Jul 30, 2021
Updated
via IBM·12:00 AM
Affected Software
Oct 14, 2021
Updated
12:00 AM
Affected Software
Oct 19, 2021
Data Sourced
via IBM·12:00 AM
DescriptionSeverityAffected Software
Updated
12:00 AM
Affected Software
Sep 26, 2023
Data Sourced
via Red Hat·02:54 PM
DescriptionSeverityAffected Software
Nov 7, 2023
Data Sourced
via NVD·03:37 AM
RemedyDescriptionSeverityWeaknessAffected Software
Updated
03:37 AM
Affected Software
Nov 21, 2024
Updated
via NVD·06:21 AM
RemedyAffected Software
Oct 14, 2026
Updated
via NVD·10:17 AM
SeverityWeaknessAffected Software
Nov 24, 2026
Withdrawn
via OSV·04:28 AM

Parent advisories

This vulnerability appears in the following advisories.

Peer vulnerabilities

Found alongside the following vulnerabilities.

Frequently Asked Questions

1

What is CVE-2021-3177?

CVE-2021-3177 is a vulnerability in Python that allows an attacker to overflow a buffer on the stack and potentially execute arbitrary code.

2

What is the severity of CVE-2021-3177?

The severity of CVE-2021-3177 is critical with a CVSS score of 9.8.

3

Which versions of Python are affected by CVE-2021-3177?

Python versions 2.7.0 to 2.7.18, 3.6.0 to 3.6.12, 3.7.0 to 3.7.9, 3.8.0 to 3.8.7, and 3.9.0 to 3.9.1 are affected by CVE-2021-3177.

4

How can I fix CVE-2021-3177?

To fix CVE-2021-3177, upgrade to Python versions 2.7.19, 3.6.13, 3.7.10, 3.8.8, or 3.9.2 or later.

5

Are there any references for CVE-2021-3177?

Yes, you can find more information about CVE-2021-3177 at the following references: [Link 1](https://bugs.python.org/issue42938), [Link 2](https://github.com/python/cpython/pull/24239), [Link 3](https://bugzilla.redhat.com/show_bug.cgi/show_bug.cgi?id=1918175).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203