Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#62828 new defect (bug)

Array should not be passed to get_page_by_path()

Reported by: leedxw's profile leedxw Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.7.1
Component: General Keywords: has-patch
Focuses: Cc:

Description

We have been logging the following, as a result of an unauthorised vulnerability scan on a site we host:

PHP Warning:  urldecode() expects parameter 1 to be string, array given in /var/www/html/wp-includes/post.php on line 6033

This occurs when an array is being passed to get_page_by_path()

I was able to reproduce using

curl -g "http://localhost/?year[1]=1"

This specific instance occurred in wp_resolve_numeric_slug_conflicts() where user-supplied values of "month" "year" etc, are passed to get_page_by_path()

Attachments (1)

rewrite_path.patch (520 bytes) - added by leedxw 2 months ago.
Patch to rewrite.php to check for array

Download all attachments as: .zip

Change History (4)

@leedxw
2 months ago

Patch to rewrite.php to check for array

#1 @sukhendu2002
2 months ago

  • Keywords has-patch added
  • Version set to 6.7.1

Reproduction Report

Description

This report validates whether the issue can be reproduced.

Environment

  • WordPress: 6.7.1
  • PHP: 8.2.27
  • Server: nginx/1.27.3
  • Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.2.27)
  • Browser: Chrome 131.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.0
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Actual Results

  1. ✅ Error condition occurs (reproduced).

Additional Notes

I am able to reproduce the issue in WordPress 6.7.1; however, I am not able to reproduce it in the trunk.

#2 @sainathpoojary
2 months ago

I can confirm that the "Warning: Array to string conversion" warning is occurring in WordPress 6.7.1, when an array is passed to get_page_by_path(). However, this issue does not happen in the current trunk version.

WordPress 6.7.1:
https://rioudcpuyg.ufs.sh/f/PL8E4NiPUWyOM9i9B5hp3F90beESqliHBLy7PKXG5nvmwjAd

Trunk:
https://rioudcpuyg.ufs.sh/f/PL8E4NiPUWyO6qsDFx8XILecyvHwBdbisfSAoq2h5TGkQU0C

#3 @abcd95
2 months ago

Hey @leedxw, Thanks for bringing this up.

As mentioned in the above two comments, the warning is visible in 6.7.1 and not on the trunk. So I upgraded to the nightly build, and I was able to see the warning there too.

And the patch works fine fixing the warning. However, it would be better to further sanitize the variable to make sure it is a string passed.

Note: See TracTickets for help on using tickets.