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

Possible XSS vulnerability #23

Open
enferas opened this issue Nov 11, 2021 · 4 comments
Open

Possible XSS vulnerability #23

enferas opened this issue Nov 11, 2021 · 4 comments

Comments

@enferas
Copy link

enferas commented Nov 11, 2021

Hello,

I would like to report for XSS vulnerability.

In file https://github.com/ZeroDream-CN/SakuraPanel/blob/master/core/PostHandler.php

line 87

$result = $pm->checkRules($_POST);

In function checkRules

public function checkRules($data)
{
                // ....
		if($this->isProxyNameExist($data['proxy_name'])) {
			return Array(false, "隧� {$data['proxy_name']} 已存在,请使用其他�字");
		}
               // ....
}

line 96

$msg = $result[1] ?? "未知错误";
exit($msg);

exit will terminate the script and print the message which have the value $data['proxy_name']. Then there is XSS vulnerability

@enferas
Copy link
Author

enferas commented Dec 2, 2021

CVE-2021-43681 is assigned to this vulnerability.

SakuraPanel v1.0.1.1 is affected by is affected by a Cross Site Scripting (XSS) vulnerability in /master/core/PostHandler.php. The exit function will terminate the script and print the message $data['proxy_name'].

@kasuganosoras
Copy link
Member

Thanks for the report, this vulnerability is fixed in 5272615

@enferas
Copy link
Author

enferas commented Dec 9, 2021

Thank you for the confirmation.

Two similar possible vulnerabilities in the same file

// *** Vulnerability 1
// line 357
exit($markdown->text($_POST['data']));

// *** Vulnerability 2
// line 368
exit("Undefined action {$params['action']}");
// when the source is coming from core/Router.php
// line 10
$phdle->switcher($_GET);

@kasuganosoras
Copy link
Member

The $markdown->text() is safe, it will remove any HTML tags.

The second place is also safe, because it has been filtered by regular expressions:

// https://github.com/ZeroDream-CN/SakuraPanel/blob/master/core/PostHandler.php#L12
if(isset($params['action']) && preg_match("/^[A-Za-z0-9\_\-]{1,20}$/", $params['action'])) {
	switch($params['action']) {
	...
		default:
			exit("Undefined action {$params['action']}");
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants