Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebars API - XSS or not XSS? #24863

Closed
adamziel opened this issue Aug 27, 2020 · 6 comments
Closed

Sidebars API - XSS or not XSS? #24863

adamziel opened this issue Aug 27, 2020 · 6 comments
Assignees
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] New API New API to be used by plugin developers or package users.

Comments

@adamziel
Copy link
Contributor

adamziel commented Aug 27, 2020

Let's talk about the experimental /__experimental/sidebars API endpoint.

As initially discovered in an unrelated issue, it is possible to send a POST request like:

$request = new WP_REST_Request( 'POST', '/__experimental/sidebars/sidebar-1' );
$request->set_body_params(
	array(
		'widgets' => array(
			array(
				'id'           => 'text-1',
				'settings'     => array(
					'text' => '<script>alert(1)</script>',
				),
			),
		),
	)
);

And store a script that will be executed when the widget is rendered.

Initially I considered it to be a vulnerability, but then I tested widgets.php and discovered it exhibits the exact same behavior. That's perhaps unsurprising, considering that experimental endpoint reuses the exact same code:

	$_POST[ $field ][ $number ] = wp_slash( $input_widget['settings'] );
	call_user_func( $update_control['callback'] );

The endpoint access is restricted to administrators and editors who, by design, are allowed to use custom scripts. Therefore it seems to me like it's not a bug, it's a feature. What do you think @draganescu @noisysocks @TimothyBJacobs ?

@adamziel adamziel added [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] New API New API to be used by plugin developers or package users. labels Aug 27, 2020
@adamziel adamziel added this to Inbox in Block-based Widgets Editor via automation Aug 27, 2020
@aristath
Copy link
Member

The endpoint access is restricted to administrators and authors who, by design, are allowed to use custom scripts. Therefore it seems to me like it's not a bug, it's a feature

I'd have to agree with that assessment... The people that can use this are the people than should be able to use it.

@TimothyBJacobs
Copy link
Member

Is this the built in text widget?

@adamziel
Copy link
Contributor Author

@TimothyBJacobs it is

@draganescu
Copy link
Contributor

Looks like a feature :)

@adamziel
Copy link
Contributor Author

adamziel commented Aug 27, 2020

Before concluding this issue I will confirm whether or not unfiltered_html has an effect here.

@draganescu draganescu moved this from Inbox to Issues in progress in Block-based Widgets Editor Sep 6, 2020
@adamziel
Copy link
Contributor Author

It does, we're good to close this issue. I prepared some related unit tests in #24886

Block-based Widgets Editor automation moved this from Issues in progress to Done Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Type] New API New API to be used by plugin developers or package users.
Projects
No open projects
Development

No branches or pull requests

4 participants