Django 1.4.20发行说明

2015年3月18日

Django 1.4.20在1.4.19中修复了一个安全问题。

通过用户提供的重定向URL减轻了可能的XSS攻击

Django在某些情况下依赖于用户输入(例如 django.contrib.auth.views.login() and i18n) to redirect the user to an "on success" URL. The security checks for these redirects (namely django.utils.http.is_safe_url()) accepted URLs with leading control characters and so considered URLs like \x08javascript:... 安全。此问题当前不影响Django,因为我们只将此URL放入 Location 响应头和浏览器似乎忽略了那里的javascript。我们测试的浏览器还处理带有控制字符前缀的URL,例如 %08//example.com 作为相对路径,重定向到不安全的目标也不是问题。

但是,如果开发人员依赖 is_safe_url() 为了提供安全的重定向目标并将此类URL放到链接中,它们可能会受到XSS攻击,因为某些浏览器(如Google Chrome)会忽略锚定中URL开头的控制字符。 href .