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 algorithm-option, set default hash algorithm to sha256 #45

Merged
merged 3 commits into from
Sep 23, 2022

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 22, 2022

Motivated by the latest csurf sec. vuln.

snyk writes regarding csurf:

In particular, it doesn’t properly validate cookie values for the double submit cookie pattern, which results in attackers being able to spoof the CSRF token. Adding to the problem, it relies on a deprecated encryption algorithm (SHA1) for hashing CSRF tokens.

https://snyk.io/blog/explaining-the-csurf-vulnerability-csrf-attacks-on-all-versions/

I personally think sha1 or sha256 or whatever does not make a big difference as csrf is actually shortlived so there is no time to crack it actually. But this PR adds anyway the algorithm option.

It sets sha256 as default hash algorithm. It would be a breaking change, but people could upgrade and set the algorithm back to sha1 if they still want to use sha1.

It this gets merged, there would be a follow up PR for the csrf-protection package.

Checklist

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 22, 2022

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with making the default sha256

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 22, 2022

@mcollina

Changed to use sha256 by defaultl

README.md Outdated Show resolved Hide resolved
types/index.d.ts Outdated Show resolved Hide resolved
Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>
@Uzlopak Uzlopak changed the title add algorithm-option add algorithm-option, set default hash algorithm to sha256 Sep 22, 2022
@Uzlopak Uzlopak requested a review from Eomm September 22, 2022 12:59
@Eomm Eomm merged commit 3e18fdf into fastify:master Sep 23, 2022
@Uzlopak Uzlopak deleted the algorithm branch September 23, 2022 07:30
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.

3 participants