#62794 closed defect (bug) (fixed)
Fatal error from wp-login.php if password is an array
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | 6.7.1 |
Component: | Login and Registration | Keywords: | |
Focuses: | Cc: |
Description
If "pwd" is given as an array, it will generate a 500 error due to the use of trim()
$ curl http://localhost/wp-login.php -X POST -d 'log=example&pwd[1]=example' -s -D - -o /dev/null | grep ^HTTP HTTP/1.1 500 Internal Server Error
"PHP message: PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /var/www/html/wp-includes/pluggable.php:602
Attachments (1)
Change History (8)
#1
@
2 months ago
- Component changed from General to Login and Registration
- Milestone changed from Awaiting Review to 6.8
#3
follow-up:
↓ 5
@
2 months ago
Hello and thanks for the ticket and patch,
This is a good point and a good workaround, however the is_string
conditional will fail if the value provided is an integer, for example.
#4
@
2 months ago
In this context, I don't know that the value of $_POST['pwd']
, if set, can be anything except a string or an array. It should fail for anything other than a string.
#5
in reply to:
↑ 3
;
follow-up:
↓ 7
@
2 months ago
Replying to audrasjb:
This is a good point and a good workaround, however the
is_string
conditional will fail if the value provided is an integer, for example.
That's good to note, however values passed via $_POST
can only ever be a string or an array, per the PHP manual:
HTTP being a text protocol, most, if not all, content that comes in Superglobal arrays, like
$_POST
and$_GET
will remain as strings. PHP will not try to convert values to a specific type. In the example below,$_GET["var1"]
will contain the string "null" and$_GET["var2"]
, the string "123".
/index.php?var1=null&var2=123
So I think this is ready to go, I would just add a similar check for $_POST['log']
for consistency.
#7
in reply to:
↑ 5
@
2 months ago
Replying to SergeyBiryukov:
That's good to note, however values passed via
$_POST
can only ever be a string or an array, per the PHP manual:
Oh, you're right, it doesn't apply on this case. Thanks.
patch for user.php to check $_POSTpwd? is a string