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

Possibility to configure the hashing algorithm for VerifyEmailTokenGenerator #194

Open
PrInStPL opened this issue Sep 2, 2024 · 3 comments

Comments

@PrInStPL
Copy link

PrInStPL commented Sep 2, 2024

Is it possible to add a hashing algorithm configuration for the SymfonyCasts\Bundle\VerifyEmail\Generator\VerifyEmailTokenGenerator ?

@bocharsky-bw
Copy link
Member

bocharsky-bw commented Sep 2, 2024

There's no way. As you can see it's hardcoded inside the createToken(). But I suppose you can override the VerifyEmailTokenGenerator in your app if needed. The question is why would you need that?

@PrInStPL
Copy link
Author

PrInStPL commented Sep 5, 2024

Both VerifyEmailTokenGenerator and UriSigner use hardcoded sha256. I know that in this package this algorithm is less important because it is before UriSigner, but it is worth fighting to avoid hardcoding algorithms in the code as much as possible. And in both cases this can be achieved by throwing the algorithm into the service configuration.

@PrInStPL
Copy link
Author

PrInStPL commented Sep 5, 2024

After analysis... Using the default Symfony and VerifyEmailBundle configuration, if $userId is based on a value provided by the user, e.g. username, then the generated link has two parameters, which are based on the same key, APP_SECRET.

The link signature is calculated from the link and the key. I have the link, but I am missing the key.

The confirmation token is calculated from three values. I have two (username and email), but I am missing the key.

So... There are four variables, and I have three. Additionally, both the link signature and the token have the same hash algorithm... Hence a fairly quick way to calculate APP_SECRET using GPU capabilities.

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

No branches or pull requests

2 participants