77376[BUGFIX] Add `X-Requested-With` by default in AJAX requests
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 8
- Build/Sources/TypeScript/backend/page-tree/page-tree-element.ts+2 −2
- Build/Sources/TypeScript/backend/tree/page-browser.ts+1 −1
- Build/Sources/TypeScript/backend/drag-uploader.ts+1 −0
- Build/Sources/TypeScript/core/ajax/ajax-request.ts+10 −6
- typo3/sysext/backend/Resources/Public/JavaScript/page-tree/page-tree-element.js+2 −2
- typo3/sysext/backend/Resources/Public/JavaScript/tree/page-browser.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/drag-uploader.js+1 −1
- typo3/sysext/core/Resources/Public/JavaScript/ajax/ajax-request.js+1 −1
Review log 912
-
Andreas Kienast uploaded patch set 1 01/13/23, 12:45
-
Andreas Kienast commented on patch set 1 CR -1 01/13/23, 12:48
need to check something -
core-ci voted on patch set 1 V -1 01/13/23, 13:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35760
-
Andreas Kienast uploaded patch set 2
CR -1V -101/13/23, 13:07 -
core-ci voted on patch set 2 V -1 01/13/23, 13:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35765
-
Andreas Kienast uploaded patch set 3
V -101/13/23, 13:29 -
core-ci voted on patch set 3 V +1 01/13/23, 13:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35766
-
Stefan Bürk commented on patch set 3 01/13/23, 13:46
Just had a quick read on the commit message and brief scroll through. `X-Requested-With` may be a problem for cross domain requests, if not explicitly allowed for/by "CORS". Do you think we are issue free here ? https://markitzeroday.com/x-requested-with/cors/2017/06/29/csrf-mitigation-for-ajax-requests.html -
Christian Kuhn commented on patch set 3 01/13/23, 14:56
Reply
this isn't shabby, either: https://stackoverflow.com/questions/17478731/whats-the-point-of-the-x-requested-with-header -
Oliver Hader commented on patch set 3 01/13/23, 14:57
Reply Unresolved
In general, adding the header would not be a security problem for the TYPO3 site, since we have other mechanisms to mitigate CSRF (same-site cookie, request-token, referrer-check). For most of the JavaScript resources in this patch, this won't be a problem in terms of CORS preflight, since most request targets are on the same TYPO3 site (same-origin). However, the change for `AjaxRequest` is indeed a breaking change when used on cross-origin resources (e.g. calling some Google API from the TYPO3 backend) - this would now trigger a preflight request. Example 1) ``` fetch('https://dotmaui.com/my-ip/raw/';); // no additional header ``` → no preflight request, all good Example 2) ``` fetch('https://dotmaui.com/my-ip/raw/';, {headers: {'X-Requested-With': 'XMLHttpRequest'}}); // sending additional header ``` → triggers preflight request → no `Access-Control-Allow-Headers` header in response from dotmaui.com → fetch/XHR fails, since `X-Requested-With` header is not allowed for that resource --- → suggestion: only send `X-Requested-With` header in `AjaxRequest` for same-origin resources, or make that somehow™ configurable/optional -
Oliver Hader commented on patch set 3 CR -1 01/13/23, 15:22
-1 for the breaking behavior in AjaxRequest -
Andreas Kienast abandoned the change 01/15/23, 12:06