Opened 15 months ago
Closed 15 months ago
#63433 closed defect (bug) (fixed)
Fatal error on lostpassword if user_login is given as array
| Reported by: | leedxw | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.9 |
| Component: | Login and Registration | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
We have logged fatal errors from an attacker sending bad POST requests
PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /var/www/html/wp-includes/user.php:3179
Stack trace:
#0 /var/www/html/wp-includes/user.php(3179): trim()
#1 /var/www/html/wp-login.php(839): retrieve_password()
#2 {main}
thrown in /var/www/html/wp-includes/user.php on line 3179
To reproduce
curl -F user_login[]=x "http://localhost/wp-login.php?action=lostpassword"
Suggested patch
--- user.php.dist 2025-05-12 09:32:16.480168551 +0000
+++ user.php 2025-05-12 09:33:40.890850357 +0000
@@ -3173,5 +3173,5 @@
// Use the passed $user_login if available, otherwise use $_POST['user_login'].
- if ( ! $user_login && ! empty( $_POST['user_login'] ) ) {
+ if ( ! $user_login && ! empty( $_POST['user_login'] ) && is_string( $_POST['user_login'] ) ) {
$user_login = $_POST['user_login'];
}
Change History (6)
This ticket was mentioned in PR #8795 on WordPress/wordpress-develop by @dilipbheda.
15 months ago
#1
- Keywords has-patch added
#3
@
15 months ago
Sorry, I think put the wrong value in the title - it's user_login.
To test the value as an array, send the value as an array.
curl -F user_login[]=x "http://localhost/wp-login.php?action=lostpassword"
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there!
Thanks for the ticket @leedxw
Could you share from how to get the
user_nameas array or it's something you just tried with array?