Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's difficult to work out what protections a Single Page Application communicating via an API requires. A lot of the documentation out there expects the server to generate an HTML form that can be submitted without JS.
However, these documents are good:
I'm not an expert though.
The Editor API only accepts incoming requests with a
Content-Type
ofapplication/json
. Other requests are rejected. Requests which have noContent-Type
(likeGET
requests) are always allowed. This protects against HTML-only forms submitted by the browser which will have aapplication/x-www-form-urlencoded
MIME type.We implemented a whitelist of allowed domains to
*.p5js.org
in #324 so this should protect against some XSS attacks.A CSRF token is sent as the cookie 'XSRF-TOKEN' on all HTML page requests. This token is picked up automatically by axios and sent to the API with all requests as an 'X-XSRF-TOKEN' header. The middleware runs on all routes and verifies that the token matches what's stored in the session.
I've clicked around the site and tested everything I can think of and things seem to work as intended. Changing some of the client API actions to send
Content-Type: text/plain
fails as expected. Altering the CSRF token in the console and then trying to sign in also fails with a CSRF error.