CVE-2016-9964: CRLF Attack in bottle
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 bottle across 2 version ranges.
>= 0.10.1, < 0.12.11
< 6d7e13da0f998820800ecb3fe9ccee4189aefb54
Fixed in 6d7e13da0f998820800ecb3fe9ccee4189aefb54. How to fix ↓
Also tracked for
- python-bottle · Debian:11
The same CVE-2016-9964 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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
Bottle is a lightweight Python web framework that allows developers to build web applications. It provides a simple and intuitive API for handling HTTP requests and responses. The vulnerability identified as CVE-2016-9964 affects versions 0.12.10 and earlier of the Bottle package. This vulnerability arises from the lack of filtering of a "\r\n" sequence in the redirect() function of bottle.py. An attacker can exploit this vulnerability by making a redirect() call with a malicious payload that includes a CRLF sequence. This can lead to a CRLF attack, allowing the attacker to inject arbitrary HTTP headers or perform other malicious actions.
Vulnerability Detail
The vulnerability in bottle.py allows for a CRLF attack, which occurs when an attacker can inject CRLF sequences into an HTTP response. This can have several consequences, including HTTP response splitting, cache poisoning, cross-site scripting (XSS), session hijacking, and other attacks. In the case of bottle.py, the redirect() function is vulnerable to this attack because it does not properly filter out the "\r\n" sequence from the redirect URL. An attacker can exploit this by crafting a redirect URL that includes a CRLF sequence followed by arbitrary HTTP headers. When the redirect is performed, the malicious headers will be included in the response, potentially leading to further exploitation.
How To Fix
Minimum fixed version
6d7e13da0f998820800ecb3fe9ccee4189aefb54
This is the first release that contains the fix.
pip install --upgrade "bottle==6d7e13da0f998820800ecb3fe9ccee4189aefb54"
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to a fixed version of Bottle is not immediately feasible, a temporary workaround can be implemented by manually filtering out the "\r\n" sequence from the redirect URL before passing it to the redirect() function. This can be done by using a regular expression or string manipulation to remove any occurrences of "\r\n" from the URL. Here's an example of how this can be done in Python:
import re
def sanitize_redirect_url(url):
sanitized_url = re.sub(r'\r\n', '', url)
return sanitized_url
redirect(sanitize_redirect_url('233\r\nSet-Cookie: name=salt'))
Conclusion
The CRLF vulnerability in bottle.py (CVE-2016-9964) allows for a CRLF attack, which can have serious consequences for web applications. It is crucial to upgrade to a fixed version of the Bottle package (0.12.11 or later) to mitigate this vulnerability. If immediate upgrade is not possible, implementing a workaround to filter out the "\r\n" sequence from redirect URLs can provide temporary protection. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for bottle →
FAQ
A CRLF attack is a type of web application vulnerability where an attacker can inject CRLF sequences into an HTTP response. This can lead to various attacks, such as HTTP response splitting, cache poisoning, cross-site scripting (XSS), and session hijacking.
The CRLF attack in bottle.py is possible due to the lack of filtering of the "\r\n" sequence in the redirect() function. An attacker can craft a redirect URL that includes a CRLF sequence followed by arbitrary HTTP headers. When the redirect is performed, the malicious headers will be included in the response, potentially leading to further exploitation.
A CRLF attack can have several consequences, including HTTP response splitting, cache poisoning, cross-site scripting (XSS), session hijacking, and other attacks. These attacks can allow an attacker to manipulate the behavior of the web application, inject malicious content, or hijack user sessions.
To fix the CRLF vulnerability in a Bottle application, it is recommended to upgrade to a fixed version of the Bottle package. The vulnerability has been addressed in version 0.12.11 and later. Update your project's dependencies to use the latest version of Bottle to ensure the vulnerability is mitigated.
Yes, if upgrading to a fixed version of Bottle is not immediately feasible, you can implement a temporary workaround by manually filtering out the "\r\n" sequence from the redirect URL before passing it to the redirect() function. This can be done using regular expressions or string manipulation to remove any occurrences of "\r\n" from the URL.
Related vulnerabilities
Recent vulnerabilities recorded for bottle.