Skip to content

[#2421] bugfix: restored ability to match passwords from Shiro 1.x that have …#2475

Merged
fpapon merged 7 commits intoapache:mainfrom
lprimak:fix-private-salt-compat
Jan 31, 2026
Merged

[#2421] bugfix: restored ability to match passwords from Shiro 1.x that have …#2475
fpapon merged 7 commits intoapache:mainfrom
lprimak:fix-private-salt-compat

Conversation

@lprimak
Copy link
Contributor

@lprimak lprimak commented Jan 25, 2026

…private salt

fixes #2421

Following this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GitHub issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a GitHub issue. Your pull request should address just this issue, without pulling in other changes.
  • Format the pull request title like [#XXX] - Fixes bug in SessionManager,
    where you replace #XXX with the appropriate GitHub issue. Best practice
    is to use the GitHub issue title in the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • add fixes #XXX if merging the PR should close a related issue.
  • Run mvn verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • Committers: Make sure a milestone is set on the PR
  • Committers: Use "Squash and Merge" to combine all commits into one when merging a PR when appropriate.

Trivial changes like typos do not require a GitHub issue (javadoc, comments...).
In this case, just format the pull request title like [DOC] - Add javadoc in SessionManager.

If this is your first contribution, you have to read the Contribution Guidelines

If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement
if you are unsure please ask on the developers list.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@lprimak lprimak added this to the 2.1.0 milestone Jan 25, 2026
@github-actions github-actions bot added the java Pull requests that update Java code label Jan 25, 2026
@lprimak lprimak self-assigned this Jan 25, 2026
@lprimak lprimak requested a review from bmarwell January 25, 2026 20:55
@lprimak lprimak changed the title bugfix: restored ability to match passwords from Shiro 1.x that have … [#2421] bugfix: restored ability to match passwords from Shiro 1.x that have … Jan 25, 2026
@lprimak
Copy link
Contributor Author

lprimak commented Jan 25, 2026

@bmarwell is it true that Argon and BCrypt do not use private salt? Or is private salt needs to be added to the new algorithms as well?

@bmarwell
Copy link
Contributor

Hi, no salt needs to be nor can be supplied by the user. See:
https://security.stackexchange.com/a/222746

The reason: argon2 and bcrypt and scrypt are NOT general purpose hashes. Hashes are meant to be fast, eg for checking data integrity. They were never meant to be used for passwords. This and adding a salt was always some kind of misuse and workaround.

General purpose hashes: meant to be fast. Adding a salt protects against rainbow tables when misused for passwords. And that's why they need so many rounds.

Password hashing algorithms (like scrypt, argon 2): meant to be memory hard or CPU hard or both, slow. Specifically for protecting passwords. Usually creating a random hash internally.

So, yeah, don't supply user hashes. For the API, just ignore them. Add to the Java doc that they will be ignored for modern functions. sha1, md5 etc are to be removed in the future for this reason.

@lprimak
Copy link
Contributor Author

lprimak commented Jan 26, 2026

Thanks!
Since salt was removed from the API, I think we are good there.

@lprimak
Copy link
Contributor Author

lprimak commented Jan 26, 2026

@bmarwell great feedback, I will make it so

@lprimak lprimak requested a review from bmarwell January 26, 2026 19:26
@lprimak lprimak dismissed bmarwell’s stale review January 27, 2026 21:21

All feedback has been incorporated into the PR now.
Thanks Ben!

@steinarb
Copy link
Contributor

Hm... this one might actually affect both my own usage and the JDBC realm....?

I will dig into both my own code and the changes I made to the JDBC realm (both are very old) and see if I can remember, but too sleepy tonight to think clearly.

@lprimak
Copy link
Contributor Author

lprimak commented Jan 27, 2026

Wonderful. Looking forward to your feedback in the next few days :)
No need to be sleepy

@steinarb
Copy link
Contributor

@lprimak A question about tests: I note no tests on this PR, is there a policy for tests in shiro?

@lprimak
Copy link
Contributor Author

lprimak commented Jan 28, 2026

@steinarb There is no policy currently, but you are right, there probably should be a test added.
The only reason I didn't consider it a must-do is because this is a 1.x backward-compatibility,
but you are making me reconsider. Thank you

@github-actions github-actions bot added the tests label Jan 28, 2026
@lprimak
Copy link
Contributor Author

lprimak commented Jan 28, 2026

@steinarb I have now added a test

Copy link
Contributor

@steinarb steinarb left a comment

Choose a reason for hiding this comment

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

LGTM!

@fpapon fpapon merged commit 9266bfa into apache:main Jan 31, 2026
31 checks passed
@lprimak lprimak deleted the fix-private-salt-compat branch January 31, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Stored Shiro1 passwords can not be correctly matched when private salts are used

5 participants

Comments