Make WordPress Core

Opened 8 months ago

Last modified 8 days ago

#62147 reviewing enhancement

Revealed passwords should change back to password type when submitting the form

Reported by: jamieburchell's profile jamieburchell Owned by: johnbillion's profile johnbillion
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Login and Registration Keywords: good-first-bug has-patch has-screenshots has-test-info
Focuses: javascript, administration Cc:

Description

Taking the lead from the UK gov recommendations on implementing password reveal option, they say:

When the form is submitted, the password input should automatically change its type to password, if it has not already done so. This is to prevent browsers from remembering it as a previously-provided value and potentially displaying it as an autofill option on non-password inputs.

Source: https://design-system.service.gov.uk/components/password-input/#define-the-inputs-type-as-password

Currently, the input type remains as text (plain) when submitting a form that has a revealed password.

Change History (18)

This ticket was mentioned in Slack in #core by jamieburchell. View the logs.


8 months ago

#2 @sabernhardt
8 months ago

  • Version 6.6.2 deleted

#3 @johnbillion
4 months ago

  • Focuses javascript administration added
  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

This ticket was mentioned in PR #8223 on WordPress/wordpress-develop by @sukhendu2002.


4 months ago
#4

  • Keywords has-patch added; needs-patch removed

#5 @vgnavada
2 months ago

  • Keywords has-screenshots added

Test Report

Description

I've tested the patch on WordPress Playground, and it's functioning as expected. ✅

When I enter the password in the field, the input type initially will be 'text'
https://i.ibb.co/gL6wByX2/image.png

And once I toggle the eye icon or click the login button, the input type automatically changes to 'password'.
https://i.ibb.co/WW8rWG3j/image.png

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8223

Environment

  • WordPress: 6.8-alpha-20250130.101504
  • PHP: 7.4.31-dev
  • Server: PHP.wasm
  • Database: WP_SQLite_Translator (Server: 5.5 / Client: 3.40.1)
  • Browser: Chrome 134.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.0
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

Supplemental Artifacts

Added Inline

This ticket was mentioned in Slack in #core-test by vgnavada. View the logs.


2 months ago

#7 @johnbillion
2 months ago

  • Milestone changed from Future Release to 6.9
  • Owner set to johnbillion
  • Status changed from new to reviewing

#8 @narenin
2 months ago

  • Keywords has-testing-info added

Test Report

This report validates that the indicated patch addresses the issue.

Patch tested:

https://github.com/WordPress/wordpress-develop/pull/8223

Environment

OS: macOS 14.6.1
Web Server: PHP.wasm
PHP: 7.4.31-dev
WordPress: 6.8-alpha-20250130.101504
Browser: Chrome Version 133.0.6943.142
Theme: Minimal Child Theme Version 1.0.2

Actual Results

When I have entered the password in the field, the input type initially will be 'text'.

https://i.ibb.co/yBYNCD7C/image-1.png

And once I have toggled the eye icon or click the login button, the input type automatically changes to 'password'.

https://i.ibb.co/zW8HJz5V/image-2.png

✅ Issue resolved with patch.

Last edited 2 months ago by narenin (previous) (diff)

#9 @jamieburchell
2 months ago

Does the patch apply to ALL password fields, or just the login page? It would also need to apply to the edit user page, change password, etc?

#10 @vgnavada
2 months ago

Hi @jamieburchell ,

Good point, Thanks for this.

Well, yes, I just checked the same PR for the ADD USER, EDIT USER pages, it's working as expected.

More details here:

Test Report

Description

I've tested the patch on WordPress Playground, and it's functioning as expected in ADD NEW USER and EDIT USER pages also. ✅

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8223

Environment

  • WordPress: 6.8-alpha-20250130.101504
  • PHP: 7.4.31-dev
  • Server: PHP.wasm
  • Database: WP_SQLite_Translator (Server: 5.5 / Client: 3.40.1)
  • Browser: Chrome 134.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.0
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Issue resolved with patch.

ADD NEW USER:

  • When Password is Visible:

https://img001.prntscr.com/file/img001/RBrPwislTZqKCjhn9lW0hA.png

  • When Password is Hidden:

https://img001.prntscr.com/file/img001/TnokhA33T9KCikfsAO3I5w.png

EDIT EXITING USER:

  • When Password is Visible:

https://img001.prntscr.com/file/img001/8bfCW4HATh2-aMo_jAAa2g.png

  • When Password is Hidden:

https://img001.prntscr.com/file/img001/TpucIBPZQoucN7jJq4S9Eg.png

Supplemental Artifacts

Added Inline

#11 @narenin
2 months ago

Actual Results

✅ Issue resolved with patch.

ADD NEW USER:

When Password is Visible:

https://i.ibb.co/5gBc8v4b/when-password-is-visible.png

When Password is Hidden:

https://i.ibb.co/n83NbFRB/when-password-hidden.png

EDIT EXITING USER:

When Password is Visible:

https://i.ibb.co/TBH5sK08/edit-exsisting-user-when-password-is-visible.png

When Password is Hidden:

https://i.ibb.co/nNg92V0q/when-password-is-Hidden.png

This ticket was mentioned in Slack in #core-test by vgnavada. View the logs.


2 months ago

#13 @audrasjb
8 weeks ago

@narenin yes I can confirm the patch works fine on each admin password input.
Question: Should we have a similar implementation for Post Password fields?

#14 follow-up: @audrasjb
8 weeks ago

Answer: not necessary as Post Password field doesn't allow the user to convert it to a text input :)

#15 in reply to: ↑ 14 @vgnavada
8 weeks ago

Replying to audrasjb:

Answer: not necessary as Post Password field doesn't allow the user to convert it to a text input :)

Exactly 😀✅

#16 @devsahadat
8 weeks ago

Thank you for reporting this issue and for the proposed fix.

I’ve thoroughly reviewed the bug report and analyzed the patch provided in PR #8223. The issue stems from password fields remaining in text mode when a form is submitted, which could lead to unintended password autofill behavior. The proposed fix correctly resets the input type to password upon submission, mitigating this risk.

Testing & Verification

I have tested the patch in the following scenarios:

  • Login Page ✅
  • Add New User Page ✅
  • Edit User Page ✅

In all cases, the password field correctly reverts to password upon form submission. This aligns with best practices, such as those recommended by the UK Government Design System.

#17 @logicrays
4 weeks ago

Hello

I've reviewed Ticket and tested the patch from PR #8223. The fix ensures that password fields revert to type="password" upon form submission, aligning with best practices to prevent unintended autofill behavior. This enhancement functions correctly across the login, add user, and edit user pages.​

form.addEventListener('submit', function () {
    const passwordFields = form.querySelectorAll('input[type="text"][data-pw]');
    passwordFields.forEach(function (field) {
        field.type = 'password';
    });
});

#18 @wordpressdotorg
8 days ago

  • Keywords has-test-info added; has-testing-info removed
Note: See TracTickets for help on using tickets.