Django 重定向响应中的一个拒绝服务(DoS)问题,允许攻击者在构造重定向响应时,触发 URL 规范化期间过量的 CPU 消耗。在 Windows 平台上,Python 的 Unicode NFKC 规范化尤其缓慢。因此,使用攻击者控制的超大 Unicode URL 创建 HttpResponseRedirect/HttpResponsePermanentRedirect(或使用 django.shortcuts.redirect())会导致异常的处理时间,进而造成请求线程耗尽以及服务变慢/中断。
该问题是 CVE-2025-27556 的后续问题,由于 unicodedata.normalize() 在该平台上的性能特性,该问题专门影响 Windows。
next/return_to 参数,或应用逻辑使用不可信输入返回重定向)。HttpResponseRedirect (302) 和 HttpResponsePermanentRedirect (301),以及 django.shortcuts.redirect()。poc.py)演示的内容A)来构造超长 URL,例如 https://AA…/。HttpResponseRedirect(url),从而触发 URL 规范化(iri_to_uri())和分割(urlsplit()),在 Windows 上执行慢路径。DisallowedRedirect 被拒绝(参见补丁摘要),从而避免昂贵的规范化工作。HttpResponseRedirectBase.__init__ 中为重定向目标添加长度防护:
django.utils.http 导入 MAX_URL_LENGTH。str,并在调用 urlsplit() 之前,如果 len(redirect_to_str) > MAX_URL_LENGTH 则抛出 DisallowedRedirect。DisallowedRedirect。