Skip to content

Security: Hash wp_signups.activation_key (Trac #38474, CVE-2017-14990)#12235

Open
bor0 wants to merge 2 commits into
WordPress:trunkfrom
bor0:fix/38474-hash-signup-activation-keys
Open

Security: Hash wp_signups.activation_key (Trac #38474, CVE-2017-14990)#12235
bor0 wants to merge 2 commits into
WordPress:trunkfrom
bor0:fix/38474-hash-signup-activation-keys

Conversation

@bor0

@bor0 bor0 commented Jun 19, 2026

Copy link
Copy Markdown
Member

Fixes https://core.trac.wordpress.org/ticket/38474

Summary

  • wp_signups.activation_key stored activation keys as plain text. This patches it to use the same timestamp:phpass_hash format already used by wp_users.user_activation_key (introduced in [25696]).
  • Activation URLs gain a signup_id parameter so the correct row can be fetched for hash verification without a table scan.
  • Legacy plain-text keys (pre-upgrade pending activations) continue to work for backwards compatibility.
  • A new activate_signup_expiration filter (default: DAY_IN_SECONDS) controls key expiry.
  • 9 new PHPUnit tests; one existing test fixed to work with hashed keys.

Fixes #38474. See also: https://core.trac.wordpress.org/ticket/38474

Props bor0, tomdxw, jeremyfelt, SergeyBiryukov, SirLouen, dmsnell.

Test plan

Automated (PHPUnit)

npm install
# edit .env: set LOCAL_MULTISITE=true
npm run env:start
npm run env:install

# New tests:
npm run test:php -- -c tests/phpunit/multisite.xml   --filter Tests_Multisite_wpmuActivateSignup

# Fixed regression test:
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

  1. Hashed key in DB — Register at /wp-signup.php as a logged-out user. Check wp_signups.activation_key: should be 1700000000:$P$Bxxx…, not a plain hex string.

  2. Activation link works — The email link contains 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 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.

  5. Legacy key BC — Insert a row into wp_signups with a plain-text activation_key (simulates a pre-upgrade pending activation). Visiting the activation URL with that key and its signup_id should still succeed — existing pending activations must not break after upgrade.

  6. 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

`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>
@github-actions

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

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 WordPress Project

@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props bor0.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

- 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>
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.

1 participant