-
Notifications
You must be signed in to change notification settings - Fork 18.5k
feat: add configurable password hash iterations for enhanced security #28374
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
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @BenjaminX, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the application's security posture by making the password hashing process configurable. It replaces a fixed, potentially outdated iteration count for PBKDF2-HMAC-SHA256 with a dynamic value sourced from application configuration. This change allows for easy updates to the hashing cost in response to new security recommendations and advancements in hardware, thereby strengthening protection against brute-force attacks on user passwords. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a configurable number of iterations for password hashing to enhance security, which is a great improvement. The implementation correctly replaces the hardcoded value with the new configuration. However, the chosen default value of 10,000 iterations is too low for modern security standards and contradicts the recommendations mentioned in both the pull request description and the field's own description. I've recommended increasing this default to a more secure value to ensure the application is secure by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a configurable PASSWORD_HASH_ITERATIONS parameter to address outdated password hashing security standards. While the motivation is sound (10,000 PBKDF2 iterations is insufficient by 2025 standards), the implementation has a critical backward compatibility flaw that will break existing user logins.
Key Changes:
- Adds
PASSWORD_HASH_ITERATIONSconfiguration field toSecurityConfigwith a default of 10,000 iterations - Updates
hash_password()to use the configurable iteration count instead of hardcoded 10,000 - Enables operators to increase PBKDF2 iterations to meet modern security recommendations (600,000+)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| api/configs/feature/init.py | Adds PASSWORD_HASH_ITERATIONS configuration field to SecurityConfig class with documentation about security recommendations |
| api/libs/password.py | Updates hash_password() function to use configurable iteration count from dify_config instead of hardcoded value |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BenjaminX
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reformatting code style.
|
Thanks for the PR :)
|
Summary
Risk
Hardware Evolution: Modern GPUs and specialized hardware (such as ASICs) can compute billions of hashes per second. 10,000 iterations provide insufficient cost for brute-force attacks.
Industry Standard Changes:
OWASP recommended at least 600,000 iterations for PBKDF2-SHA256 in 2023
NIST SP 800-63B recommends at least 10,000 iterations (this is a 2017 standard, now considered outdated)
Some security experts suggest 1,000,000+ iterations should be used in 2025
Real-World Impact: If a database is breached, attackers using modern hardware can rapidly test common passwords and dictionary attacks. The time cost provided by 10,000 iterations is nearly negligible.