Security: Hash wp_signups.activation_key (Trac #38474, CVE-2017-14990)#12235
Security: Hash wp_signups.activation_key (Trac #38474, CVE-2017-14990)#12235bor0 wants to merge 2 commits into
Conversation
`wp_signups.activation_key` stored activation keys as plain text (e.g. `7259c714857ef009`), unlike `wp_users.user_activation_key` which already stores a `timestamp:hash` pair. This was assigned CVE-2017-14990. This patch brings `wp_signups` into line with `wp_users`: - `wpmu_signup_blog()` and `wpmu_signup_user()` now hash the key with phpass before storing it (`timestamp:phpass_hash` format), mirroring the approach used for password-reset keys in [25696]. - `wpmu_activate_signup()` verifies the submitted key against the stored hash and enforces a 24-hour expiry via the new `activate_signup_expiration` filter. - Legacy plain-text keys (rows created before the upgrade) continue to work for backwards compatibility so no pending activations are broken by the upgrade. - Activation URLs now include `&signup_id=N` so the correct row can be fetched for hash verification without a full-table scan. - `wp-activate.php` gains a Signup ID field on the manual activation form. - Unit tests cover: hashed storage, successful activation, wrong key rejection, wrong signup_id rejection, legacy key BC, expiry, and the `activate_signup_expiration` filter. Props bor0, tomdxw, jeremyfelt, SergeyBiryukov, SirLouen, dmsnell. Fixes #38474. == Testing Instructions == === Automated (PHPUnit) === Requires the Docker-based local environment: npm install # edit .env: set LOCAL_MULTISITE=true npm run env:start npm run env:install # New tests for this ticket: npm run test:php -- -c tests/phpunit/multisite.xml \ --filter Tests_Multisite_wpmuActivateSignup # Regression: existing test that was updated: npm run test:php -- -c tests/phpunit/multisite.xml \ --filter test_should_not_fail_for_data_used_by_a_deleted_user All 9 tests should pass. === Manual (browser) === 1. HASHED KEY IN DB - Go to /wp-signup.php as a logged-out user and register. - Check wp_signups: activation_key should look like "1700000000:$P$Bxxx..." not a plain 16-char hex string. 2. ACTIVATION LINK WORKS - The confirmation email link includes both key= and signup_id=. - Clicking it shows "Your account is now active!" 3. SIGNUP ID FIELD ON FORM - Visit /wp-activate.php with no params. - The manual entry form should show both "Activation Key" and "Signup ID" fields. 4. WRONG KEY REJECTED - Visit /wp-activate.php?key=WRONGKEY&signup_id=<valid_id> - Activation must fail (no "now active" message). 5. LEGACY KEY BACKWARDS COMPAT - Insert a row with a plain-text activation_key directly into wp_signups (simulating a pre-upgrade pending activation). - Visit /wp-activate.php?key=<plain_key>&signup_id=<id> - Activation should succeed -- pre-upgrade pending activations must not be broken by the upgrade. 6. EXPIRY - Add add_filter('activate_signup_expiration', fn() => -1) to an mu-plugin, sign up, try to activate. - Activation should fail with an expired-key error. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Hi there! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
- Multi-item associative arrays: each value on its own line - Space after function keyword in anonymous/arrow functions - Inline closure expanded to multi-line (brace must be last content on line) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Fixes https://core.trac.wordpress.org/ticket/38474
Summary
wp_signups.activation_keystored activation keys as plain text. This patches it to use the sametimestamp:phpass_hashformat already used bywp_users.user_activation_key(introduced in [25696]).signup_idparameter so the correct row can be fetched for hash verification without a table scan.activate_signup_expirationfilter (default:DAY_IN_SECONDS) controls key expiry.Fixes #38474. See also: https://core.trac.wordpress.org/ticket/38474
Props bor0, tomdxw, jeremyfelt, SergeyBiryukov, SirLouen, dmsnell.
Test plan
Automated (PHPUnit)
All 9 tests should pass.
Manual
Hashed key in DB — Register at
/wp-signup.phpas a logged-out user. Checkwp_signups.activation_key: should be1700000000:$P$Bxxx…, not a plain hex string.Activation link works — The email link contains both
key=andsignup_id=. Clicking it shows "Your account is now active!"Signup ID field on form — Visit
/wp-activate.phpwith no params. The form should show both "Activation Key" and "Signup ID" fields.Wrong key rejected — Visit
/wp-activate.php?key=WRONGKEY&signup_id=<valid_id>. Activation must fail.Legacy key BC — Insert a row into
wp_signupswith a plain-textactivation_key(simulates a pre-upgrade pending activation). Visiting the activation URL with that key and itssignup_idshould still succeed — existing pending activations must not break after upgrade.Expiry — Add
add_filter('activate_signup_expiration', fn() => -1)to an mu-plugin, sign up, try to activate. Must fail with an expired-key error.🤖 Generated with Claude Code