Make WordPress Core

Opened 3 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#63320 closed enhancement (fixed)

Sanitize key parameter in activation flow to enhance security

Reported by: khushipatel15's profile khushipatel15 Owned by: flixos90's profile flixos90
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch
Focuses: multisite Cc:

Description

Currently, the key parameter received via $_GET or $_POST is used directly without sanitization in the activation flow. This patch introduces the use of sanitize_text_field() when retrieving the key from user input to ensure the data is cleaned before further processing.

Changes made:
Added sanitize_text_field() for both $_GETkey? and $_POSTkey? when assigning the $key variable.
This ensures that any potentially unsafe characters are stripped out, reducing the risk of unexpected behavior or misuse.

Attachments (2)

63320.patch (1.3 KB) - added by khushipatel15 3 weeks ago.
This Patch file shows enhancement and use of sanitize key and meets coding standards of wordpress.
63320.2.patch (1.3 KB) - added by khushipatel15 3 weeks ago.
Here is the updated patch file.

Download all attachments as: .zip

Change History (11)

@khushipatel15
3 weeks ago

This Patch file shows enhancement and use of sanitize key and meets coding standards of wordpress.

#1 follow-up: @narenin
3 weeks ago

Welcome to the core trac @khushipatel15

The PR looks good to me but we should add space after opening ( and closing of ) as per PHPCS coding standards so

sanitize_text_field($_GET['key'])

Should be

sanitize_text_field( $_GET['key'] )

#2 in reply to: ↑ 1 @khushipatel15
3 weeks ago

Thankyou so much for the suggestion, I'll update it soon.

@khushipatel15
3 weeks ago

Here is the updated patch file.

#3 @narenin
3 weeks ago

Thanks for the changes, looks good to me.

Last edited 3 weeks ago by narenin (previous) (diff)

#4 @flixos90
3 weeks ago

  • Focuses performance privacy coding-standards php-compatibility removed
  • Milestone changed from Awaiting Review to 6.9
  • Owner set to flixos90
  • Status changed from new to reviewing

Thanks @khushipatel15 for reporting this!

It surely looks worth doing, but some of the focus areas here are not really relevant, so I'm going to remove them.

#5 @flixos90
2 weeks ago

  • Version 6.8 deleted

#7 @flixos90
2 weeks ago

  • Component changed from Security to Networks and Sites
  • Focuses multisite added

#8 @flixos90
2 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 60204:

Networks and Sites: Sanitize key parameter in wp-activate.php.

Props khushipatel15.
Fixes #63320.

Note: See TracTickets for help on using tickets.