Leading Null Byte Vulnerability in Python-RSA: Security Risks and Mitigation
Summary
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 ↓
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.
No signup required · Results in about 60 seconds
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 →
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.