enhancement(settings): hide Subscription Token value on settings page#4324
Open
faisalahammad wants to merge 2 commits into
Open
enhancement(settings): hide Subscription Token value on settings page#4324faisalahammad wants to merge 2 commits into
faisalahammad wants to merge 2 commits into
Conversation
- Change token input from type=text to type=password - Remove token value from HTML, use masked placeholder instead - Preserve existing token in DB when field submitted empty - Update description text to reflect new behavior Fixes 10up#4305
burhandodhy
requested changes
Jul 6, 2026
burhandodhy
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. Please add tests to cover these changes.
- Guard credentials update when EP_CREDENTIALS defined (prevent crafted POST leaking wp-config token to wp_options) - Reuse prev_ep_credentials instead of redundant get_epio_credentials read - Remove dead ternary branch - Add tests for token preserve-on-empty and new-token save - Add CHANGELOG Security entry Refs 10up#4324
faisalahammad
commented
Jul 6, 2026
faisalahammad
left a comment
Author
There was a problem hiding this comment.
Follow-up to address feedback before review. Pushed in 4e0092a:
- Leak guard: when
EP_CREDENTIALSis defined, a crafted POST could persist the wp-config token intowp_optionsin plaintext. The credentials update block now short-circuits when the constant is set, consistent with the field's existingdisabledattribute. - Redundant read removed: reuse
$this->prev_ep_credentials(already fetched at the top ofaction_admin_init) instead of callingget_epio_credentials()again. - Dead ternary branch removed inside the
issetguard. - Tests added (
TestSettings): token preserved on empty POST, new token saved. Both skip whenEP_CREDENTIALSis defined. - CHANGELOG: Security entry under Unreleased.
composer run lint clean, composer run test-single-site -- --filter TestSettings passes (9 tests).
Ready for review.
Author
|
Pushed follow-up addressing feedback before review (commit 4e0092a). Leak guard for EP_CREDENTIALS, redundant read removed, dead branch removed, tests + CHANGELOG added. Lint clean, 9/9 TestSettings pass. Ready for review @felipeelia. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Subscription Token for ElasticPress.io users was displayed in plain text on the Settings page. This change hides the value by using a password field, and it preserves the existing token when the form is submitted without a new value.
Fixes #4305
Changes
includes/partials/settings-page.phpBefore:
After:
Why: Type password alone was not enough because the browser could still expose the value via DevTools. Leaving the value empty and using a placeholder means the token is never sent back to the browser.
includes/classes/Screen/Settings.phpBefore:
After:
Why: Since the token input is always empty on page load, an empty POST value means the user did not change it. This prevents overwriting the stored token with an empty value on every save.
Testing
Test 1: Token is not exposed in the page
value=""and that the actual token is not in the DOM.Result: Token not exposed in page source.
Test 2: Save without changing the token
Result: Existing token is preserved.
Test 3: Update the token
Result: New token is saved correctly.
Screenshots
Before:

After:
