Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSRF protection to the Hypervisor API #1604

Merged
merged 2 commits into from
Dec 10, 2023
Merged

Conversation

Senyoret1
Copy link
Contributor

Changes:

  • Now the hypervisor request a CSRF token for the POST, PUT and DELETE operations. If the token is not found or invalid, an error is returned. The code is based on the one used on the Skycoin repo, but with various changes.

How to test this PR:
Try to make a POST, PUT or DELETE operation using the hypervisor API, it will return an error. For getting the token, you must first call the GET /csrf API endpoint.

The CSRF token should be added to the X-CSRF-Token header of the API requests, for the server to check it. The token is valid for 30 seconds only.

If you recompile the UI and make the operations with it, it will get and use the token automatically, so everything should work normally.

NOTE: Maybe a config option should be added to disable the CSRF token protection.

@0pcom
Copy link
Collaborator

0pcom commented Jun 8, 2023

Maybe a config option should be added to disable the CSRF token protection

perhaps not a config option but a flag for the visor that would disable that at runtime.

@Senyoret1
Copy link
Contributor Author

The last commit adds a param for starting the visor without CSRF protection.

@0pcom 0pcom merged commit c4ddd24 into skycoin:develop Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants