Add Cross-Site-Forgery-Request (CSRF) protection#753
Merged
yannickwurm merged 1 commit intomasterfrom Jun 25, 2024
Merged
Conversation
Cross-Site Request Forgery (CSRF) is a type of malicious exploit of a website where unauthorized commands are transmitted from a user that the web application trusts. Without the user's knowledge, the attacker tricks the victim into performing actions on their behalf. i.e. copy-pasting JS commands to dev tools console or similar. This vulnerability exploits the trust that a site has in a user's browser, allowing attackers to perform actions on behalf of the user without their consent or awareness. To protect from this attack we're adding a crsf token, that is generated randomly, stored in session, and added to each form submission/POST request. Requests fail if the token value submitted does not match the value in the session, significantly reducing the risk of malicious or unintentional requests on behalf of the user. While this is not really necessary for locally running instances or public instances, folks hosting their own private instances or exposing locally hosted instances to the internet will benefit from this.
Contributor
Collaborator
Author
Hi @nathanweeks, very likely yes. Unfortunately this is an undocumented feature that very few users use, so it may take a bit longer to update. If you have any capacity, we'd welcome a PR which either optionally turns on this feature but with CSRF protection disabled for this endpoint, or alternatively allows to configure whitelisted hostnames from where the CSRF token can be fetched (this might need to be in the same domain for the session cookie to be valid). The latter is much more involved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cross-Site Request Forgery (CSRF) is a type of malicious exploit of a website where unauthorized commands are transmitted from a user that the web application trusts. Without the user's knowledge, the attacker tricks the victim into performing actions on their behalf. i.e. copy-pasting JS commands to dev tools console or similar. This vulnerability exploits the trust that a site has in a user's browser, allowing attackers to perform actions on behalf of the user without their consent or awareness.
To protect from this attack we're adding a crsf token, that is generated randomly, stored in session, and added to each form submission/POST request. Requests fail if the token value submitted does not match the value in the session, significantly reducing the risk of malicious or unintentional requests on behalf of the user.
While this is not really necessary for locally running instances or public instances, folks hosting their own private instances or exposing locally hosted instances to the internet will benefit from this.