Cross-site Scripting (XSS) - Stored in helloxz/onenav
Reported on
Feb 14th 2022
Description
Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into websites. An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script.
https://github.com/helloxz/onenav
is vulnerable to XSS as shown below:
Proof of concept
Vuln variable: $category['name']
Snippet:
Onenav stores user input without filtering and then display it, for example in the add_category method.
POST variables are stored
function add_category($api){
//获取token
$token = $_POST['token'];
//获取分类名称
$name = $_POST['name'];
...
And then saved into database:
public function add_category($token,$name,$property = 0,$weight = 0,$description = ''){
$this->auth($token);
$data = [
'name' => $name,
'add_time' => time(),
...
$this->db->insert("on_categorys",$data);
Next the user input are displayed without filtering:
<div class="mdui-list-item-content category-name"><?php echo $category['name']; ?></div>
Payload
Login to onenav and go to add_category section:
http://localhost/index.php?c=admin&page=add_category
In the name field insert the following:
<script>alert`category_xss`</script>
Next go to the onenav root, in this case:
http://localhost/index.php
Observe the XSS
Impact
Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with that site. These scripts can even rewrite the content of the HTML page.
References
https://portswigger.net/web-security/cross-site-scripting
https://owasp.org/www-community/attacks/xss/