Skip to content

Add upper limit to PBKDF iteration count#10050

Merged
dgarske merged 14 commits into
wolfSSL:masterfrom
anhu:pbkdf_max
May 12, 2026
Merged

Add upper limit to PBKDF iteration count#10050
dgarske merged 14 commits into
wolfSSL:masterfrom
anhu:pbkdf_max

Conversation

@anhu

@anhu anhu commented Mar 23, 2026

Copy link
Copy Markdown
Member

Fixes ZD 21402

@anhu anhu requested a review from wolfSSL-Bot March 23, 2026 20:07
@anhu anhu self-assigned this Mar 23, 2026
@anhu

anhu commented Mar 26, 2026

Copy link
Copy Markdown
Member Author

Jenkins retest this please.

@anhu anhu force-pushed the pbkdf_max branch 2 times, most recently from 1bcbddc to fca6e23 Compare March 26, 2026 12:40
@anhu

anhu commented Mar 26, 2026

Copy link
Copy Markdown
Member Author

jenkins retest this please

@anhu

anhu commented Mar 30, 2026

Copy link
Copy Markdown
Member Author

jenkins retest this please.

1 similar comment
@anhu

anhu commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

jenkins retest this please.

@anhu

anhu commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

jenkins retest this please

Aborted

@anhu

anhu commented Apr 1, 2026

Copy link
Copy Markdown
Member Author

jenkins retest this please

@anhu anhu added the Not For This Release Not for release 5.9.2 label Apr 2, 2026
@anhu anhu assigned wolfSSL-Bot and unassigned anhu Apr 6, 2026
@anhu anhu added For This Release Release version 5.9.2 and removed Not For This Release Not for release 5.9.2 labels Apr 6, 2026

@douzzer douzzer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This limit is far too low.

Aside from that, the limit should not be imposed in the crypto layer, it should be imposed by the caller. Only the caller knows the provenance of the iteration count, so only the caller can impose limits that are appropriate.

Here is an AI summary of real world PBKDF iterations:

The highest PBKDF2 iteration count found in widespread/mainstream usage is 10,000,000 (10 million).

This comes from Apple’s iOS/macOS data protection system. It’s used to derive keys from backup passwords (or similar passcodes) to protect keybags—the encrypted containers holding Data Protection class keys, Keychain items, and related secrets in iTunes/iCloud backups and on-device protection. It has been documented since around iOS 10.2 (with PBKDF2-SHA256) and is still referenced in Apple’s security documentation as using a “large iteration count” of PBKDF2. This is extremely mainstream (billions of devices).

Other notable mainstream examples (all PBKDF2 unless noted)

Password managers (very common real-world use):

Keeper: Defaults to 1,000,000 iterations (PBKDF2-HMAC-SHA256) for master password key derivation on the client.

1Password: ~650,000 iterations.

Bitwarden: Default 600,000 (aligned with OWASP); users can (and do) configure up to the enforced cap of 2,000,000.

LastPass: Defaults in the 100k–600k range historically/recently (varies by account age).

Disk encryption / volume tools:

VeraCrypt (successor to TrueCrypt): Defaults to 200,000–500,000 depending on volume type/hash (e.g., 500k for non-system containers with most hashes). Higher values are possible via the PIM (Personal Iterations Multiplier) setting (e.g., PIM 485 yields the 500k default; users can go higher), but the defaults are the mainstream baseline.

Frameworks / libraries (common in web/server apps):

Django (recent versions, e.g., 5.x): Defaults increased to 1,000,000 iterations for PBKDF2-SHA256.

Standards / recommendations (not usage, but influential):

OWASP Password Storage Cheat Sheet (current): Minimum 600,000 for PBKDF2-HMAC-SHA256 (or ~1.4M for SHA-1, 210k–220k for SHA-512). This is a floor for new deployments, not a ceiling.

@douzzer douzzer removed the For This Release Release version 5.9.2 label Apr 6, 2026
@anhu anhu assigned anhu and unassigned wolfSSL-Bot Apr 6, 2026
@anhu anhu added the Not For This Release Not for release 5.9.2 label Apr 6, 2026
@anhu anhu removed the Not For This Release Not for release 5.9.2 label Apr 8, 2026

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🐺 Skoll Code Review

Overall recommendation: REQUEST_CHANGES
Findings: 2 total — 2 posted, 1 skipped

Posted findings

  • [High] Missing WC_PBKDF_MAX_ITERATIONS check in non-MP-API wc_PKCS12_PBKDF_exwolfcrypt/src/pwdbased.c:625-627
  • [Medium] No test coverage for WC_PBKDF_MAX_ITERATIONS enforcementwolfcrypt/test/test.c
Skipped findings
  • [Medium] No test coverage for WC_PBKDF_MAX_ITERATIONS enforcement

Review generated by Skoll via openclaw

Comment thread wolfcrypt/src/pwdbased.c
@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@anhu anhu assigned wolfSSL-Bot and unassigned anhu Apr 17, 2026
@dgarske dgarske requested review from dgarske and douzzer April 17, 2026 16:33

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🐺 Skoll Code Review

Overall recommendation: APPROVE
Findings: 4 total — 2 posted, 3 skipped

Posted findings

  • [Medium] No test coverage for new upper-bound iteration checkwolfcrypt/src/pwdbased.c:82-85,223-226,416-420,630-634
  • [Medium] Backward-compatibility / behavior change not documentedwolfssl/wolfcrypt/pwdbased.h:38-45
Skipped findings
  • [Low] Duplicated bounds-check block could be a small helper/macro
  • [Low] Check placed after iteration clamp; consider ordering
  • [Medium] No test coverage for new upper-bound iteration check

Review generated by Skoll via openclaw

Comment thread wolfssl/wolfcrypt/pwdbased.h
dgarske
dgarske previously approved these changes Apr 29, 2026
Comment thread wolfcrypt/src/pwdbased.c Outdated
Comment thread wolfcrypt/src/pwdbased.c
Comment thread wolfcrypt/src/pwdbased.c
@dgarske dgarske removed the request for review from wolfSSL-Bot May 5, 2026 19:55
@douzzer

douzzer commented May 11, 2026

Copy link
Copy Markdown
Contributor

retest this please
(logs lost)

anhu and others added 14 commits May 11, 2026 15:57
Add WC_PBKDF_MAX_ITERATIONS (default 100000) to cap the iteration
count in wc_PBKDF1_ex(), wc_PBKDF2_ex(), and wc_PKCS12_PBKDF_ex().
…ise it to 10000000, add wc_PBKDF_max_iterations_set() and wc_PBKDF_max_iterations_get(), and restore new negative tests in pwdbased_test().
* add correct gating around pbkdf1_test(), pkcs12_pbkdf_test(), and scrypt_test() prototypes;
* add unit tests for wc_PBKDF_max_iterations_set() and wc_PBKDF_max_iterations_get() in pbkdf2_test();
* fix pkcs12_test() to skip the evilPkcs12 test if evil_p12 can't be parsed for any reason, mirroring the new stanza around evil_p12 in pwdbased_test().
* fix typography of wc_PBKDF_max_iterations_set() and wc_PBKDF_max_iterations_get() (peer review).
* refactor overflow prevention in wc_PKCS12_PBKDF_ex() to use WC_SAFE_SUM_UNSIGNED().

wolfcrypt/test/test.c: in pwdbased_test(), omit "INT_MAX MAC iterations" test if WOLFSSL_NO_MALLOC (uses wc_PKCS12_new_ex()).
@douzzer

douzzer commented May 11, 2026

Copy link
Copy Markdown
Contributor

retest this please

FAIL: scripts/ocsp-stapling2.test

@douzzer douzzer requested a review from dgarske May 11, 2026 23:59
Comment thread wolfcrypt/src/pwdbased.c
@dgarske dgarske merged commit 33efd8c into wolfSSL:master May 12, 2026
444 of 445 checks passed
douzzer added a commit to douzzer/wolfssl that referenced this pull request May 13, 2026
  * in pbkdf2_test(), pwdbased_test(), and pkcs12_test(), add missing FIPS v7+
    gates around stanzas that use wc_PBKDF_max_iterations_set() and
    wc_PBKDF_max_iterations_get() or depend on erroring for excessive PBKDF
    iterations (fixes wolfSSL#10050);

  * in ecc_test_buffers(), omit new corrupt HMAC tag test on FIPS <v6 (fixes
    8f2a3f9).

tests/api/test_dtls.c: add FIPS v7+ gate to test_dtls13_frag_ch2_with_ch1_rtx().

wolfssl/wolfcrypt/memory.h: #include "../../linuxkm/linuxkm_memory.h" rather than "linuxkm/linuxkm_memory.h", following pattern in wc_port.h.
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.

5 participants