Infinite Loop Vulnerability in Python rencode Package: CVE-2021-40839

python-rencode Updated 02 Oct 2025

Summary

10/09/2021
N/A
No i
High
7.5

CVE-2021-40839: The rencode package through 1.0.6 for Python allows an infinite loop in typecode decoding (such as via ;\x2f\x7f), enabling a remote attack that consumes CPU and memory. Affects python-rencode versions < 572ff74586d9b1daab904c6f7f7009ce0143bb75. 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The rencode package is a Python library designed for efficient encoding and decoding of data structures. It is commonly used for serialization, allowing Python objects to be converted into a format that can be easily stored or transmitted. The package is known for its performance and simplicity, making it a popular choice among developers. However, a critical vulnerability has been identified that allows for an infinite loop during typecode decoding, which can lead to significant resource consumption.

Vulnerability Detail

CVE-2021-40839 is a vulnerability found in the rencode package versions up to 1.0.6. It allows an attacker to exploit typecode decoding, specifically through crafted input such as ';\x2f\x7f'. This can trigger an infinite loop, leading to excessive CPU and memory usage. The vulnerability poses a risk of denial-of-service attacks, where legitimate users may be unable to access services due to resource exhaustion. The issue originates from improper handling of specific input types, making it critical for developers to address.

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

If immediate updating is not feasible, consider implementing input validation to sanitize and restrict the typecode inputs processed by the rencode package. This can help mitigate the risk of triggering the infinite loop. Additionally, monitor system resources to detect unusual spikes in CPU and memory usage.

Conclusion

CVE-2021-40839 represents a significant risk for applications using the rencode package, allowing for potential denial-of-service attacks through an infinite loop vulnerability. It is crucial for developers to update to the latest version of the package and consider implementing additional safeguards to protect their applications.

See every vulnerability recorded for python-rencode →

Share this vulnerability

FAQ

CVE-2021-40839 is a vulnerability in the rencode package that allows for an infinite loop during typecode decoding, potentially leading to denial-of-service attacks.

You can use the Vulert platform to monitor and alert for open-source vulnerabilities. Check your application against CVE-2021-40839 using the Vulert playground at Vulert Scanner.

The vulnerability can lead to excessive CPU and memory consumption, resulting in denial-of-service conditions where legitimate users cannot access the affected service.

Yes, updating to version 1.0.6-2 or later will resolve the vulnerability and ensure that your application is secure.

Implement input validation to sanitize typecode inputs and monitor system resources for unusual activity until you can apply the update.

Related vulnerabilities

Recent vulnerabilities recorded for python-rencode.

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