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

Issue 6269 - RFE - Add nsslapd-pwdPBKDF2Rounds configuration to PBKDF2-* plugins #6447

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

droideck
Copy link
Member

Description: Add nsslapd-pwdPBKDF2Rounds attribute that can be configured in
PBKDF2-* password storage plugin entries. This was password hashing round value can be adjusted.
Certain compliance requirements (like from BSI) require specific hashing round values greater than
what we currently provide.

Fixes: #6269

Reviewed by: ?

@droideck droideck marked this pull request as draft December 12, 2024 01:50
@droideck droideck added the work in progress Work in Progress - can be reviewed, but not ready for merge. label Dec 12, 2024
Copy link
Contributor

@Firstyear Firstyear left a comment

Choose a reason for hiding this comment

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

Looks really good, nice to see you looking at the rust side :)

src/slapi_r_plugin/src/error.rs Outdated Show resolved Hide resolved
const MAX_PBKDF2_ROUNDS: usize = 1_000_000;

const PBKDF2_ROUNDS_ATTR: &str = "nsslapd-pwdPBKDF2Rounds";
static PBKDF2_ROUNDS: Lazy<RwLock<usize>> = Lazy::new(|| RwLock::new(DEFAULT_PBKDF2_ROUNDS));
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized we need to make the PBKDF2_ROUNDS a HashMap, as we might use different values in different schemes.

Do you know what the best option for our case is?

I found dashmap option Lazy<DashMap<MessageDigest, usize>> or we can make a RwLock HashMap like this RwLock<HashMap<MessageDigest, usize>>...
And I think there can be more...

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I tried a few approaches (even Rust's generics...), and I think the one in the last commit will work the best.
It's the simple AtomicUsize variables - one for each digest.

Copy link
Contributor

@tbordaz tbordaz left a comment

Choose a reason for hiding this comment

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

C/template part of the patch LGTM. A minor question

Copy link
Contributor

@tbordaz tbordaz left a comment

Choose a reason for hiding this comment

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

oppss forgot to add my questions ;)

ldap/schema/01core389.ldif Outdated Show resolved Hide resolved
ldap/schema/01core389.ldif Outdated Show resolved Hide resolved
@droideck droideck force-pushed the rust-pbkdf2-add-param branch 3 times, most recently from d1025bd to 2f0db06 Compare December 19, 2024 23:51
…2-* plugins

Description: Add nsslapd-pwdPBKDF2Rounds attribute that can be configured in
PBKDF2-* password storage plugin entries. This was password hashing round value can be adjusted.
Certain compliance requirements (like from BSI) require specific hashing round values greater than what we currently provide.
Add CLI, Web UI option, and CI tests.

Fixes: 389ds#6269

Reviewed by: ?
@droideck droideck force-pushed the rust-pbkdf2-add-param branch from 2f0db06 to 3603e54 Compare December 20, 2024 00:43
@droideck
Copy link
Member Author

Okay, it's ready for the final review!
I additionally covered UI, CLI, and tests.

Design doc: 389ds/389ds.github.io#17

Please check! Thank you!

@droideck droideck removed the work in progress Work in Progress - can be reviewed, but not ready for merge. label Dec 20, 2024
@droideck droideck marked this pull request as ready for review December 20, 2024 00:46
@@ -106,27 +389,27 @@ def test_check_two_scheme(topo):
user.delete()

@pytest.mark.skipif(ds_is_older('1.4'), reason="Not implemented")
def test_check_pbkdf2_sha256(topo):
"""Check password scheme PBKDF2_SHA256.
def test_check_pbkdf2_sha512(topo):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we really remove the test about the old scheme ?
IMHO it should be better to keep it and add a similar test for the new scheme

Copy link
Member Author

Choose a reason for hiding this comment

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

Same here, agreed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, first of all, the initial test case was invalid (it removed the PBKDF2-SHA256 plugin, but it checked for PBKDF2_SHA256).

I tried to make the test about both PBKDF2-SHA256 first and then about PBKDF2_SHA256 consistently. And if we set the password scheme to it and restart it, the plugin entry will not be bootstraped.

It seems intentional, as only the latest recommended password plugin is bootstrapped correctly: https://github.com/389ds/389-ds-base/blob/main/ldap/servers/slapd/config.c#L42-L50

So, I changed the test to PBKDF2-SHA512.

P.S. the test in dirsrvtests/tests/suites/password/pbkdf2_upgrade_plugin_test.py checks for PBKDF2-SHA256, though and it is restored if it's not set to password storage scheme in cn=config

ldap/ldif/template-dse-minimal.ldif.in Show resolved Hide resolved
@droideck
Copy link
Member Author

Changes are made, please, review

@droideck droideck force-pushed the rust-pbkdf2-add-param branch from 6496b99 to 802fb91 Compare December 23, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFE] pbkdf2 hardcoded parameters should be turned into configuration options
4 participants