Skip to content

Conversation

@BenjaminX
Copy link
Contributor

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.

Copilot AI review requested due to automatic review settings November 19, 2025 02:55
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 19, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Configurable Password Hashing: Introduced a new configuration setting, PASSWORD_HASH_ITERATIONS, to allow dynamic adjustment of the number of iterations used for PBKDF2 password hashing.
  • Enhanced Security Recommendations: The new configuration includes a description recommending 600,000+ iterations for 2025 standards, highlighting the need for increased security against modern brute-force attacks.
  • Dynamic Iteration Count: The hash_password function now retrieves the iteration count from the dify_config instead of using a hardcoded value, making the system more adaptable to evolving security requirements.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the 💪 enhancement New feature or request label Nov 19, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Copilot finished reviewing on behalf of BenjaminX November 19, 2025 02:57
Copy link
Contributor

Copilot AI left a 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_ITERATIONS configuration field to SecurityConfig with 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.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Nov 19, 2025
Copy link
Contributor Author

@BenjaminX BenjaminX left a comment

Choose a reason for hiding this comment

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

reformatting code style.

@crazywoola crazywoola requested a review from laipz8200 November 20, 2025 03:35
@crazywoola
Copy link
Member

Thanks for the PR :)

  • Please link an existing issue or create a new issue and link it in the description.
  • Please add some tests for the changes as well.

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

Labels

💪 enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants