Code

Opened 2 years ago

Last modified 7 months ago

#17157 new New feature

CSRF fails in cross-domain iframes on IE

Reported by: akaihola Owned by:
Component: Documentation Version: master
Severity: Normal Keywords: csrf iframe ie
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Internet Explorer >=6
blocks third-party cookies by default.
This causes CSRF to fail
for forms which are in iframes which come from a different domain. The user gets this message:

Forbidden (403)
CSRF verification failed. Request aborted.

When a developer hits this problem,
possible solutions
are

None of the solutions can be made for the developer by Django,
so the best Django can do is to provide a note about this corner case in the
Scenarios section of the CSRF documentation.

Attachments (0)

Change History (6)

comment:1 Changed 2 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 13 months ago by susan

  • Owner changed from nobody to susan
  • Status changed from new to assigned

comment:3 Changed 12 months ago by jedierikb@…

A few questions about this and the proposed workarounds.

  1. Could you elaborate bring the iframed page under the same domain as the main page? When using a javascript library like jQuery File Upload https://github.com/blueimp/jQuery-File-Upload, their javascript dynamically creates an iFrame with a form. How could the use of the library or the library itself be adjusted so as to avoid the problems described in this bug? Does it matter if the library is loaded from another site hosted elsewhere?
  1. Can you pass CSRF credentials as URL parameters? This is suggested by the author of the jQuery File Upload library here https://github.com/blueimp/jQuery-File-Upload/pull/148#issuecomment-4251262. What are the concerns, precautions to take when doing this?

comment:4 Changed 12 months ago by akaihola

Unfortunately I can't recall details of the upload functionality I was implementing when I created this ticket. I would assume that I wasn't using any JavaScript library but made a plain HTML form inside an iframe.

In this case a straightforward solution would have been getting rid of the requirement of serving the iframe contents from a separate subdomain. That's what I probably meant by "bring the iframed page..".

CSRF in query parameters would probably work. I don't seem to have thought of it back then.

comment:5 Changed 11 months ago by anonymous

  • Owner susan deleted
  • Status changed from assigned to new

comment:6 Changed 7 months ago by timo

  • Easy pickings unset

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from (none) to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.