CVE-2021-40839: Infinite Loop in rencode

rencode Updated 02 Oct 2025

Summary

13/09/2021
No i
High
7.5

CVE-2021-40839: Infinite Loop in rencode. Affects rencode versions < 1.0.6. No fix is published. How to fix ↓

Also tracked for

The same CVE-2021-40839 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The rencode package is a Python library that provides encoding and decoding functions for a custom serialization format. It is commonly used for data serialization and deserialization in various Python applications. The vulnerability identified as CVE-2021-40839 allows an attacker to trigger an infinite loop in the typecode decoding process, leading to excessive consumption of CPU and memory resources. This vulnerability affects versions up to 1.0.6 of the rencode package.

Vulnerability Detail

The vulnerability arises from a flaw in the typecode decoding functionality of the rencode package. By providing a specially crafted typecode (e.g., ;\x2f\x7f), an attacker can cause the decoding process to enter an infinite loop. This can be exploited remotely, resulting in a denial-of-service (DoS) attack that consumes significant CPU and memory resources on the target system. The impact of this vulnerability can lead to system instability, performance degradation, and potential service disruption.

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, users can avoid using the vulnerable functionality by refraining from decoding typecodes that may trigger the infinite loop. It is advisable to review the codebase and identify any instances where the vulnerable function 'rencode.dumps' is used. If possible, consider using alternative serialization libraries until the rencode package is updated.

Conclusion

In conclusion, the CVE-2021-40839 vulnerability in the rencode package allows for an infinite loop in typecode decoding, leading to excessive CPU and memory consumption. It is crucial to update the rencode package to version 1.0.7 or later to mitigate this vulnerability. Users can also use Vulert's playground at https://vulert.com/scanner to check if their application is affected by this vulnerability. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for rencode →

Share this vulnerability

FAQ

The vulnerability allows an attacker to trigger an infinite loop in the rencode package, leading to excessive consumption of CPU and memory resources. This can result in system instability, performance degradation, and potential service disruption.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using only the Pipfile.lock file.

Yes, the maintainers of the rencode package have released a fix in version 1.0.7. It is recommended to upgrade to this version or later to mitigate the vulnerability.

As a temporary workaround, users can avoid using the vulnerable functionality by refraining from decoding typecodes that may trigger the infinite loop. It is also advisable to review the codebase and consider using alternative serialization libraries.

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