CRLF Injection Vulnerability in Python Bottle Package
Summary
CVE-2016-9964: redirect() in bottle.py in bottle 0.12.10 doesn't filter a "\r\n" sequence, which leads to a CRLF attack, as demonstrated by a redirect("233\r\nSet-Cookie: name=salt") call. Affects python-bottle across 2 version ranges.
< 0.12.11-1
< 6d7e13da0f998820800ecb3fe9ccee4189aefb54
Fixed in 0.12.11-1. 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
The Python Bottle package is a lightweight WSGI micro web framework for Python, designed for building small web applications. It is known for its simplicity and ease of use, making it a popular choice among developers. However, the package has a vulnerability that allows for CRLF (Carriage Return Line Feed) injection, which can lead to security issues such as HTTP response splitting and cookie manipulation.
Vulnerability Detail
The vulnerability, identified as CVE-2016-9964, arises from the redirect() function in bottle.py version 0.12.10, which fails to properly filter out a '\r\n' sequence. This oversight enables attackers to craft malicious redirect calls, such as redirect('233\r\nSet-Cookie: name=salt'), potentially allowing them to inject arbitrary HTTP headers. The implications of this vulnerability can be severe, as it may lead to session hijacking, data leakage, or other forms of exploitation that compromise the integrity and confidentiality of user data.
How To Fix
Minimum fixed version
0.12.11-1
This is the first release that contains the fix.
sudo apt-get install --only-upgrade python-bottle
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading is not immediately possible, a temporary workaround is to manually sanitize any input that may be passed to the redirect() function to prevent the inclusion of '\r\n' sequences. For example, you can implement a check before calling the redirect function:
if '\r\n' not in user_input: redirect(user_input) else: # Handle the error or sanitize the input
Conclusion
The CRLF injection vulnerability in the Python Bottle package poses significant security risks. It is crucial for developers using this framework to upgrade to the patched version to safeguard their applications. Additionally, utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.
See every vulnerability recorded for python-bottle →
FAQ
CRLF injection is a type of attack that involves injecting carriage return and line feed characters into HTTP headers, potentially allowing attackers to manipulate the response sent to the client.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.
The risks include session hijacking, data leakage, and unauthorized access to user information, which can severely compromise application security.
Yes, upgrading to version 0.12.11-1 or later of the Python Bottle package mitigates this vulnerability.
If an immediate upgrade is not feasible, implement input sanitization as a temporary workaround to prevent CRLF sequences from being processed.
Related vulnerabilities
Recent vulnerabilities recorded for python-bottle.