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

Warn developers when they use unsafe hashers/encoders #20071

Closed
javiereguiluz opened this issue Sep 28, 2016 · 3 comments
Closed

Warn developers when they use unsafe hashers/encoders #20071

javiereguiluz opened this issue Sep 28, 2016 · 3 comments

Comments

@javiereguiluz
Copy link
Member

javiereguiluz commented Sep 28, 2016

Somewhat related to #20045 discussion, we could warn developers when they use unsafe encoder types. I'm thinking about something like this:

if (null !== $this->logger && 'plaintext' === $encoderType) {
    $this->logger->warning('Storing user passwords in plain text is considered a critical security error. Consider configuring a password encoder for the "%s" entity.');
}

if (null !== $this->logger && in_array($encoderType, array('sha512', 'sha384', 'sha256', 'sha1', 'md5'))) {
    $this->logger->warning('Encoding user passwords with "%s" algorithm is considered a bad security practice. Consider using "bcrypt" as the password encoder for the "%s" entity.');
}

If you like this idea, how and where could we log those warning messages? Thanks!

@Nicofuma
Copy link
Contributor

Nicofuma commented Sep 28, 2016

Honestly I wouldn't like to see a warning like that in all my logs in production when I explicitly made the choice to use a such encoder. If it is tied to the debug flag of the environment why not, but it can't be enabled all the time.

To be more precise, a such feature in production would prevent me from using the warning log level at all (or at least without a dedicated log configuration). I'll have to silence it because a warning shouldn't happen and all warning must be investigate (not immediately unlike an error or a critical but it still have to)

@javiereguiluz
Copy link
Member Author

Yes, it would only be for the dev environment.

@javiereguiluz
Copy link
Member Author

Closing it because I no longer consider this a good idea. Our developers are not idiots (so they'll never use plaintext for real users) and if they use bad hashers (sha*) it's probably for a good reason (legacy apps, etc.) and anyway, we explain things well in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants