gristlabs_grist-core/app/client
Paul Fitzpatrick bd6a54e901 (core) mitigate csrf by requiring custom header for unsafe methods
Summary:
For methods other than `GET`, `HEAD`, and `OPTIONS`, allow cookie-based authentication only if a certain custom header is present.

Specifically, we check that `X-Requested-With` is set to `XMLHttpRequest`. This is somewhat arbitrary, but allows us to use https://expressjs.com/en/api.html#req.xhr.

A request send from a browser that sets a custom header will prompt a preflight check, giving us a chance to check if the origin is trusted.

This diff deals with getting the header in place. There will be more work to do after this:
 * Make sure that all important endpoints are checking origin.  Skimming code, /api endpoint check origin, and some but not all others.
 * Add tests spot-testing origin checks.
 * Check on cases that authenticate differently.
    - Check the websocket endpoint - it can be connected to from an arbitrary site; there is per-doc access control but probably better to lock it down more.
    - There may be old endpoints that authenticate based on knowledge of a client id rather than cookies.

Test Plan: added a test

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2631
2020-10-08 14:19:25 -04:00
..
components (core) Fix CustomView css to take full height of widget on all browsers including Safari 2020-10-06 13:18:50 -04:00
lib (core) mitigate csrf by requiring custom header for unsafe methods 2020-10-08 14:19:25 -04:00
models (core) mitigate csrf by requiring custom header for unsafe methods 2020-10-08 14:19:25 -04:00
ui (core) mitigate csrf by requiring custom header for unsafe methods 2020-10-08 14:19:25 -04:00
ui2018 (core) Improve focus and keyboard shortcuts in modals. 2020-10-03 22:56:00 -04:00
widgets (core) move client code to core 2020-10-02 13:24:21 -04:00
app.css (core) move client code to core 2020-10-02 13:24:21 -04:00
app.js (core) move client code to core 2020-10-02 13:24:21 -04:00
declarations.d.ts (core) move client code to core 2020-10-02 13:24:21 -04:00
exposeModulesForTests.js (core) move client code to core 2020-10-02 13:24:21 -04:00
tsconfig.json freshen app/client/ui2018/cssVars.ts 2020-06-23 16:16:38 -04:00