Skip to content

[JENKINS-75533] Remove jbcrypt mindrot, use Spring Security instead #10604

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

Merged
merged 3 commits into from
Apr 30, 2025

Conversation

daniel-beck
Copy link
Member

@daniel-beck daniel-beck commented Apr 28, 2025

See JENKINS-75533.

During development of this change, Spring Security added the backward compatibility I considered here, but without exposing the potential problem to users. I considered doing that for Jenkins, but there's no great way built-in to expose that information to users and ask them to change the password. I can do that if required, basically all of the code is written but I think unnecessary.

As a side effect of moving the validation into the PasswordHashEncoder this would address JENKINS-74918 as well, as demonstrated by the necessary test changes (password is shorter than 14 chars).

Depends on jenkinsci/active-directory-plugin#241 which would break.

Testing done

Screenshots

Regular

Setup wizard

User profile

Create user

FIPS-140

Setup wizard

User profile

Proposed changelog entries

  • Improvement: Jenkins' own user database no longer accepts new passwords longer than supported by bcrypt (72 bytes). Users with longer passwords are advised to change their password.
  • Internal: Switch jbcrypt implementation used for Jenkins' own user database from jbcrypt to Spring Security.
  • Remove jbcrypt library. If you're using Active Directory plugin, make sure to update to version 2.40 at the same time as updating Jenkins.
  • Developer: Remove org.connectbot:jbcrypt library from core BOM.

Proposed changelog category

/label developer,dependencies,internal,rfe,removed

Proposed upgrade guidelines

Unless operating in FIPS-140 mode, Jenkins' own user database no longer supports creating passwords longer than 72 bytes (UTF-8), which is the maximum length supported by the bcrypt password hashing function it uses. This length corresponds to 72 basic ASCII characters, 24-36 CJK characters, or 18 emoji 🤠.

Existing passwords longer than 72 bytes can still be used to log in.

Users with longer passwords are advised to change their password to be at most 72 bytes (and, e.g., choose from a larger character set to achieve the same complexity).

Submitter checklist

  • The Jira issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • New or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@comment-ops-bot comment-ops-bot bot added developer Changes which impact plugin developers dependencies Pull requests that update a dependency file internal rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted removed This PR removes a feature or a public API labels Apr 28, 2025
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

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

LGTM, but one comment should be updated.

Co-authored-by: James Nord <[email protected]>
@daniel-beck daniel-beck requested a review from jtnord April 29, 2025 15:03
@basil basil self-assigned this Apr 29, 2025
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

This PR is now ready for merge. We will merge it after approximately 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process. Thanks!

@basil basil added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Apr 29, 2025
@basil basil merged commit 5e36565 into jenkinsci:master Apr 30, 2025
18 checks passed
@daniel-beck daniel-beck deleted the JENKINS-75533 branch May 6, 2025 08:05
@@ -37,6 +37,7 @@ HudsonPrivateSecurityRealm.ManageUserLinks.Description=Create/delete/modify user
HudsonPrivateSecurityRealm.CreateAccount.TextNotMatchWordInImage=Text didn''t match the word shown in the image
HudsonPrivateSecurityRealm.CreateAccount.PasswordNotMatch=Password didn''t match
HudsonPrivateSecurityRealm.CreateAccount.FIPS.PasswordLengthInvalid=Password must be at least 14 characters long
HudsonPrivateSecurityRealm.CreateAccount.BCrypt.PasswordTooLong=Jenkins’ own user database currently only supports passwords of up to 72 bytes UTF-8 (72 basic ASCII characters, 24-36 CJK characters, or 18 emoji). Please use a shorter password.
Copy link
Member

@timja timja May 6, 2025

Choose a reason for hiding this comment

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

This is an example of a developer error message and not a user message.

For a user I would suggest something more like:

  • Option 1

Jenkins’ own user database only supports passwords up to 72 characters

  • Option 2

Maximum password length is 72 characters

  • Option 3

Password is too long

If you really want to tweak for UTF-8 or emoji you could put a more specific error message in there only when one of these is detected.

Copy link
Member Author

@daniel-beck daniel-beck May 6, 2025

Choose a reason for hiding this comment

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

Thanks for the feedback. I acknowledge the problem in the Jira issue when I wrote

longer than 72 bytes (UTF-8, so good luck explaining this requirement to users)

but I couldn't think of a great alternative, other than providing examples what this means (and why "72 characters" isn't it -- option 1 and 2 are simply wrong).

Something more vague like the following might work, as it captures the important parts while being overall less technical.

usually 72 characters, fewer when using other characters, like Chinese characters or emoji

I like

put a more specific error message in there only when one of these is detected.

though, will take a stab at it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file developer Changes which impact plugin developers internal ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback removed This PR removes a feature or a public API rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants