urllib3 is an HTTP client library for Python. urllib3's streaming API is designed for the efficient handling of large HTTP responses by reading the content in chunks, rather than loading the entire response body into memory at once. urllib3 can perform decoding or decompression based on the HTTP `Content-Encoding` header (e.g., `gzip`, `deflate`, `br`, or `zstd`). When using the streaming API, the library decompresses only the necessary bytes, enabling partial content consumption. Starting in version 1.22 and prior to version 2.6.3, for HTTP redirect responses, the library would read the entire response body to drain the connection and decompress the content unnecessarily. This decompression occurred even before any read methods were called, and configured read limits did not restrict the amount of decompressed data. As a result, there was no safeguard against decompression bombs. A malicious server could exploit this to trigger excessive resource consumption on the client. Applications and libraries are affected when they stream content from untrusted sources by setting `preload_content=False` when they do not disable redirects. Users should upgrade to at least urllib3 v2.6.3, in which the library does not decode content of redirect responses when `preload_content=False`. If upgrading is not immediately possible, disable redirects by setting `redirect=False` for requests to untrusted source.
urllib3 versions 1.22 to 2.6.2 contain a resource exhaustion vulnerability where HTTP redirect responses trigger unnecessary decompression of entire response bodies before read methods are called. This can lead to denial of service through decompression bombs, bypassing configured read limits and consuming excessive memory and CPU resources.
تتيح واجهة البث في مكتبة urllib3 معالجة استجابات HTTP الكبيرة بكفاءة من خلال قراءة المحتوى على دفعات بدلاً من تحميل كامل الاستجابة في الذاكرة. عند معالجة استجابات إعادة التوجيه HTTP، تقوم المكتبة بقراءة وفك ضغط كامل محتوى الاستجابة تلقائياً حتى قبل استدعاء أي طرق قراءة، متجاهلة حدود القراءة المكونة. يمكن استغلال هذا السلوك لشن هجمات قنبلة فك الضغط حيث يرسل المهاجم ملفات مضغوطة صغيرة تتوسع إلى أحجام هائلة عند فك الضغط، مما يستنزف موارد الذاكرة والمعالج ويؤدي إلى حرمان من الخدمة. تؤثر الثغرة على جميع الإصدارات من 1.22 حتى 2.6.2 وتم إصلاحها في الإصدار 2.6.3.
تحتوي مكتبة urllib3 من الإصدار 1.22 إلى 2.6.2 على ثغرة استنزاف الموارد حيث تؤدي استجابات إعادة التوجيه HTTP إلى فك ضغط غير ضروري لكامل محتوى الاستجابة قبل استدعاء طرق القراءة. يمكن أن يؤدي ذلك إلى حرمان من الخدمة عبر قنابل فك الضغط، متجاوزاً حدود القراءة المكونة ومستهلكاً موارد ذاكرة ومعالج مفرطة.
1. Immediately upgrade urllib3 to version 2.6.3 or later across all Python environments, containers, and virtual environments using 'pip install --upgrade urllib3>=2.6.3'
2. Conduct comprehensive inventory of all Python applications and dependencies to identify urllib3 usage, including indirect dependencies through frameworks like requests, boto3, and other HTTP clients
3. Implement network-level protections including rate limiting on HTTP endpoints, response size restrictions at load balancers, and monitoring for abnormal decompression ratios or memory consumption patterns in Python applications
1. الترقية الفورية لمكتبة urllib3 إلى الإصدار 2.6.3 أو أحدث عبر جميع بيئات Python والحاويات والبيئات الافتراضية باستخدام الأمر 'pip install --upgrade urllib3>=2.6.3'
2. إجراء جرد شامل لجميع تطبيقات Python والتبعيات لتحديد استخدام urllib3، بما في ذلك التبعيات غير المباشرة من خلال أطر العمل مثل requests وboto3 وعملاء HTTP الأخرى
3. تطبيق حماية على مستوى الشبكة بما في ذلك تحديد معدل الطلبات على نقاط نهاية HTTP وقيود حجم الاستجابة على موازنات التحميل ومراقبة نسب فك الضغط غير الطبيعية أو أنماط استهلاك الذاكرة في تطبيقات Python