Leading Null Byte Vulnerability in Python-RSA: Security Risks and Mitigation

python-rsa Updated 02 Oct 2025

Summary

01/06/2020
N/A
No i
High
7.5

CVE-2020-13757: Python-RSA before 4.1 ignores leading '\0' bytes during decryption of ciphertext. Affects python-rsa versions < c6731b1dda461676b998a18004b23a9879378041. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Python-RSA is a widely used library for implementing RSA encryption in Python applications. It provides essential functionalities for secure data transmission and is often employed in various cryptographic applications. However, the library has a vulnerability that allows it to ignore leading null bytes during the decryption of ciphertext, which can lead to potential security risks.

Vulnerability Detail

The vulnerability, identified as CVE-2020-13757, arises from Python-RSA versions prior to 4.1, which do not properly handle leading '\0' bytes during decryption. This oversight could enable attackers to infer the use of Python-RSA in an application or exploit the length of accepted ciphertext, potentially leading to excessive memory allocation or other unintended behaviors. The CVSS score for this vulnerability is 7.5, indicating a significant risk.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary workaround, you can implement input validation to check for leading null bytes in ciphertext before decryption. This can help mitigate the risk until an upgrade is performed. Example code snippet:

if ciphertext.startswith(b'\0'): raise ValueError('Invalid ciphertext: leading null bytes detected')

Conclusion

The CVE-2020-13757 vulnerability in Python-RSA poses significant security risks due to improper handling of leading null bytes during decryption. Upgrading to version 4.7.2-1 or later is crucial for mitigating these risks. Until an upgrade can be performed, implementing input validation can serve as a temporary measure.

See every vulnerability recorded for python-rsa →

Share this vulnerability

FAQ

CVE-2020-13757 is a vulnerability in the Python-RSA library that allows leading null bytes to be ignored during decryption, posing security risks.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.

The risks include the possibility of attackers inferring the use of Python-RSA in your application and potential excessive memory allocation due to the length of accepted ciphertext.

If an immediate upgrade is not possible, implement input validation to check for leading null bytes in ciphertext as a temporary workaround.

The CVSS score for CVE-2020-13757 is 7.5, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for python-rsa.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback