Opened 10 years ago

Closed 10 years ago

#11061 closed (fixed)

Malformed POST request cause TypeError in AdminSite.login()

Reported by: Vladimir Dmitriev Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: admin login
Cc: vldmit@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I found that any visitor can cause a TypeError on Django site with enabled contrib.admin application. This can be done by sending malformed authentication POST request without username parameter but with LOGIN_FORM_KEY. This will cause following exception in AdminSite.login() function:

Traceback (most recent call last):

 File "/usr/local/lib/python2.5/site-packages/django/core/handlers/", line 86, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/usr/local/lib/python2.5/site-packages/django/contrib/admin/", line 141, in root
   return self.login(request)

 File "/usr/local/lib/python2.5/site-packages/django/views/decorators/", line 44, in _wrapped_view_func
   response = view_func(request, *args, **kwargs)

 File "/usr/local/lib/python2.5/site-packages/django/contrib/admin/", line 244, in login
   if u'@' in username:

TypeError: argument of type 'NoneType' is not iterable

Although there is no security threat with this error, it makes Django incompatible with McAfee SECURE service. McAfee performs a sort of stress testing by generating a lot of random requests with different URLs and form parameters which cause ~20 Django error messages to appear in mailbox each day.

I've created tiny patch with fix and test. Affected versions: both trunk and 1.0.2

Attachments (1)

adminsite.patch (1.9 KB) - added by Vladimir Dmitriev 10 years ago.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Vladimir Dmitriev

Attachment: adminsite.patch added

comment:1 Changed 10 years ago by Chris Beaven

Triage Stage: UnreviewedReady for checkin

comment:2 Changed 10 years ago by Luke Plant

Resolution: fixed
Status: newclosed

Fixed in r11493, thanks.

Note: See TracTickets for help on using tickets.
Back to Top