The Invitation Nobody Checked: Chamilo LMS CVE-2026–82535
Chamilo LMS's survey invitation code was checked only for existence, not ownership, and one variant was derived from public data while another was minted for anyone. An attacker could submit a survey answer attributed to another user, which was stored unsanitised and rendered unescaped in the admin reporting view, leading to stored XSS and, in the authors' lab, creation of a backdoor admin account.
medium.com
Published on medium.com
Cybersecurity
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 open-source e-learning software. The authors put it at roughly 70,000+ self-hosted deployments and 21M+ user accounts across them. The feature at the centre of this write-up is the survey module: teachers create surveys, and Chamilo deliberately allows surveys to accept responses from visitors who have no account at all. That anonymous answering is a legitimate, intentional feature, not a misconfiguration.
Access to a survey is gated by an "invitation code". The application checks that the submitted code exists in the survey invitation table, but, as the authors show, it never checks that the code belongs to the person presenting it. The stored answer is then rendered in the teacher and administrator reporting views without HTML escaping.
The result is CVE-2026-82535, a stored XSS reachable before authentication, classified as CWE-79 with CWE-639 (authorization bypass through a user-controlled key) as the route in. The authors reported it to VulnCheck, the CNA, and the maintainer has fixed and published it. The bug is patched; nothing in the write-up is a live zero-day.

Key facts as stated in the report:
| Field | Value |
|---|---|
| CVE | CVE-2026-82535 |
| Product | Chamilo LMS |
| Affected | 1.11.0 to 1.11.40 and 2.0.0 to 2.0.3 |
| Fixed in | 1.11.42 and 3.0.0 |
| Weakness | CWE-79 (Stored XSS) via CWE-639 (Authorization Bypass Through User-Controlled Key) |
| Severity | CVSS v4.0 5.3 Medium; v3.1 6.1 Medium |
| CNA | VulnCheck |
In one sentence, as the authors put it: Chamilo's survey feature checks that an invitation code exists, but not that it belongs to the person presenting it, so an attacker can submit an answer attributed to someone else, which is then rendered without escaping to whoever reviews the results.
Setup
The exploitation was reproduced against a from-scratch Chamilo 1.11.40 lab, using a survey with anonymous responses enabled. The authors stress again that anonymous responses are an intentional feature, not a misconfiguration.
The end-to-end proof was run in a real browser. The authors validated the findings against Chamilo's own source, including a byte-level diff against the vendor's actual fix, and confirmed the identical unpatched flaw in Chamilo 2.0.0 to 2.0.3, matching the advisory's affected range.
Finding it
The authors' approach to any Chamilo audit starts by finding the pages that explicitly tolerate a visitor with no account, because that is the widest door into the application. They grepped for the anonymous-access helper in the survey directory:
grep -rn "api_is_anonymous" main/survey/
main/survey/fillsurvey.php came back immediately. Chamilo intentionally lets surveys accept anonymous responses, so the interesting question was not whether anonymous people can answer surveys, but what actually stops someone from answering as somebody else.
Reading the file for whatever gated access, one comment on an unrelated function stopped them:
function api_get_unique_id() { ... }
Chamilo's own source names the mistake to look for. Hunting for token generation nearby, they found that the actual access-control token for surveys, the invitation code, is built two different ways, one of them not even as strong as the flawed function the comment warns about:
if ($isAnonymous) {
$autoInvitationcode = 'auto-ANONY_'.md5(time())."-$surveyCode";
} else {
$autoInvitationcode = "auto-$userid-$surveyCode";
}
The second line contains no secret material at all: it is a template filled in from a sequential user ID and a survey code that Chamilo lists to anonymous visitors elsewhere. From there the authors traced forward to what validates the code and what can be done once it is accepted.
Exploitation
Step 1: obtain an invitation without an account
GET /main/survey/fillsurvey.php?course=POCSURVEYCOURSE&invitationcode=auto&scode=POCSURVEY HTTP/1.1
The server mints auto-ANONY_[MD5]-POCSURVEY on the spot and inserts it as a valid invitation. No credentials are presented. The attacker does not need to guess anything: the endpoint issues a brand-new, fully valid code to anyone who asks.
Step 2: submit the payload as that invitation
POST /main/survey/fillsurvey.php?...&invitationcode=auto-ANONY_[MD5]-POCSURVEY&show=1 HTTP/1.1
question1=[INJECTED_PAYLOAD_HERE]
The answer text is submitted under the freshly minted invitation. The authors confirmed directly in the database that the raw bytes sent are the raw bytes stored, with no security sanitisation functions and no HTML character escaping:
SELECT option_id FROM c_survey_answer WHERE survey_id=1 AND question_id=1; — [INJECTED_PAYLOAD_HERE]
The value lands in c_survey_answer.option_id, a longtext column with no length cap.
Step 3: wait for an administrator to open the routine report
GET /main/survey/reporting.php?survey_id=1&action=completereport HTTP/1.1
This is ordinary usage, not a special trick. The response contains the payload verbatim inside a live document body:
[DIV_ELEMENT_WITH_PAYLOAD]
That script executes in the administrator's session. In the authors' lab it created the backdoor administrator described below.
Step 4: turn the XSS into a persistent administrator account
The session cookie is HttpOnly, so this is not cookie theft. The XSS runs same-origin in whichever browser opens the poisoned report, which means it can drive any request that browser's session is authorised to make. In the lab, the payload used that access to fetch() Chamilo's own main/admin/user_add.php, read its CSRF token from the same page, and POST a new account with admin[platform_admin]=1. That produced a working, persistent platform-administrator account from a single anonymous HTTP request, and the account survives even after the XSS itself is patched. This is the "backdoor account creation" that VulnCheck's advisory refers to.
The authors are precise about the boundary: the vulnerability is stored XSS reachable pre-authentication. Admin-account creation is the specific, demonstrated consequence of that primitive in an administrator's session, not a separate flaw, and not evidence that credentials or session tokens were extracted directly.
A note on which report view is opened
reporting.php has a third view of the same stored answer, action=userreport (the per-respondent report), which happens to escape correctly because it renders the value through a form textarea that HTML-encodes its default. That is a different action from the two the authors tested: action=completereport and action=questionreport, both of which they confirmed render the payload unescaped. Severity depends on which of the three an administrator happens to open.
Root cause
The invitation code is an authorization credential, and the flaw is that possessing it was treated as sufficient, with no check binding it to the person presenting it. The validation query only asks whether the code exists:
$sql = "SELECT * FROM $table_survey_invitation WHERE c_id=$course_id AND invitation_code='$code'";
if (Database::num_rows($result) < 1) {
api_not_allowed(true, get_lang('WrongInvitationCode'));
}
The two invitation-code variants fail this in different ways:
auto-$userid-$surveyCode(a real, already-invited user): the code carries no secret at all. Anyone who knows or enumerates a course code, survey code and target user ID can reconstruct it and answer as that person, without ever logging in.auto-ANONY_<md5(time)>-$surveyCode(a fresh anonymous respondent): the attacker does not even need to guess anything, because the endpoint mints a brand-new, fully valid code for anyone who asks. Self-service anonymous response is intentional; the bug is that the same "does this code exist" check also gated the first case.
Either path lands in the same place: c_survey_answer.option_id stores the submitted text completely unsanitised, next to a reporting page that renders it with none of the escaping Chamilo already applies to the question text on the very same page.
A smaller companion bug sits in the same code path. The "already answered" guard, $survey_invitation['answered'] == 1 && !isset($_GET['user_id']), is skipped entirely by appending &user_id=1, so an attacker is not limited to first-answer submissions either.
Impact
The primitive on its own is stored XSS, nothing more. What raises the stakes beyond a typical Medium-rated bug is what the authors did with that primitive, and they are careful about the boundary between the two.
Because the cookie is HttpOnly, this is not cookie theft. The script runs same-origin in the browser of whoever opens the poisoned report, so it can drive any request that session is authorised to make. In an administrator's session that includes creating a platform administrator through main/admin/user_add.php, using the CSRF token read from the same page. The resulting account is persistent and survives patching of the XSS itself.
The authors do not claim extraction of credentials or session tokens directly.
Fix
The authors diffed the vendor's actual patch, the 1.11.x branch head carrying the 1.11.42 fix ahead of a formal tag, against the vulnerable release rather than taking the advisory's word for it. It is three coordinated changes, addressing all three angles above.
- The anonymous code is now unguessable:
- $autoInvitationcode = ‘auto-ANONY_’.md5(time()).”-$surveyCode”;
+ $autoInvitationcode = ‘auto-ANONY_’.api_generate_secure_token(16).”-$surveyCode”;
- The user-specific code now has to belong to whoever is asking. The deterministic
auto-$userid-$surveyCodeformat was not removed; it is now checked against the requester's actual session:
$isInvitedUser = $currentUserId > 0 && (string) $currentUserId === $invitedUser;
if (0 === strpos($invitation_code, ‘auto-’) && ctype_digit($invitedUser) && (int) $invitedUser > 0 && !$isInvitedUser) { api_not_allowed(true, get_lang(‘WrongInvitationCode’));}
- Both output sinks the authors exploited now escape on the way out:
- echo $row[‘option_id’].’<hr noshade=”noshade” size=”1" />’;
+ echo Security::remove_XSS($row[‘option_id’]).’<hr noshade=”noshade” size=”1" />’;
The identical fix was applied in the complete-report row builder.
Chamilo 3.0.0 took a more radical approach for the same class of bug: rather than patch the sink, the entire legacy endpoint was retired. main/survey/fillsurvey.php in 3.0.0 is a stub that unconditionally denies access, with a comment stating that answering now happens through a new API that verifies the invitation belongs to the requester.
Operators should update to 1.11.42 or later, or migrate to 3.0.0.
Variants to test
- Other anonymous-capable endpoints with invitation or token parameters. Grep for the anonymous-access helper across other modules, as the authors did with
grep -rn "api_is_anonymous" main/survey/. A positive result is a handler that accepts a visitor with no account and gates access on a code or token rather than on a session identity. - Deterministic token formats built from public values. Look for tokens assembled from user IDs, course codes, survey codes or timestamps. A positive result is a token you can reconstruct for a target user from data the application shows to anonymous visitors, and then use to act as that user.
- Self-service token minting. Request a token with a placeholder value such as
invitationcode=autoand see whether the server issues a fresh valid one. A positive result is a new, usable credential returned to an unauthenticated client. - Existence-only validation queries. Read the validation code for checks that only count rows (
num_rows($result) < 1) without comparing the credential to the requester. A positive result is a query that would accept any valid code regardless of who presents it. - Stored input rendered in privileged views. Submit a marker into longtext fields and open every report or listing view that displays it. A positive result is the marker appearing verbatim in a live document body in one view while being encoded in another, which is exactly the split the authors found between
action=completereportandaction=questionreporton one side andaction=userreporton the other. - Guard parameters that can be added to skip checks. Try appending parameters such as
&user_id=1to endpoints with "already answered" or similar guards. A positive result is the guard being bypassed and a second submission being accepted.
What happened, in plain words
Two brothers, Jon and Leon Bytyçi, found a security bug in Chamilo LMS, a piece of software that schools and organisations install on their own servers to run online courses. They reported it, the people who maintain Chamilo fixed it, and the bug was published as CVE-2026-82535. The bug is patched, so nothing in this article is a live attack against anyone today.
The short version: Chamilo has a survey feature. A teacher creates a survey, and Chamilo deliberately lets people answer it without having an account. To answer, you need an "invitation code". Chamilo checks that the code you present exists, but it never checks that the code belongs to you. So an attacker can answer a survey while pretending to be somebody else, and the text they submit is stored exactly as typed. Later, when a teacher or administrator opens the page that shows the survey results, that text is placed into the page without being made safe. If the text contains a small piece of JavaScript (the language web pages use to run code in your browser), the browser runs it. Because the page is open in the administrator's own logged-in browser, that code can do anything the administrator can do, including creating a brand-new administrator account. That account keeps working even after the original bug is fixed.

The image is the article's title card, showing the CVE identifier CVE-2026-82535.
The basics you need first
Before the details, here are the ideas this article uses, explained from zero.
What Chamilo LMS is. LMS stands for Learning Management System. It is software a school installs on a server so that teachers can create courses, upload material, set quizzes and surveys, and students can log in and take part. "Open source" means the code is public and anyone can read it, which is exactly what the researchers did. The authors put Chamilo at roughly 70,000+ self-hosted installations with 21M+ user accounts across them.
What a survey is here. A teacher creates a survey with questions. Students, or even visitors without an account, fill it in. The answers are saved in a database, and the teacher can open a report page to read them.
What a database is. Think of it as a very large set of spreadsheets kept by the server. Each table has rows and columns. Chamilo keeps survey answers in a table called c_survey_answer, in a column called option_id.
What a server and a request are. Your browser is the client. The computer that runs Chamilo is the server. When you open a page or submit a form, your browser sends a request to the server, and the server sends back a response, usually a web page. A request has a method: GET means "give me this page", POST means "here is some data, please store or process it".
What a URL and its parameters are. A URL like /main/survey/fillsurvey.php?course=X&scode=Y has a path (/main/survey/fillsurvey.php) and then a question mark followed by parameters: name equals value pairs joined by &. They are like the fields of a form, but written into the address.
What a cookie is. When you log in, the server sends your browser a small piece of text called a session cookie. Your browser sends it back with every later request, and that is how the server knows who you are. If someone steals your cookie, they can act as you. A cookie can be marked "HttpOnly", which means JavaScript running in the page is not allowed to read it. That matters later.
What a token or code is. A token is a short string the server gives you to prove you were allowed to do something, a bit like a cloakroom ticket: whoever holds the ticket gets the coat. An invitation code in Chamilo is exactly that: a ticket that lets you answer a particular survey.
What an API is. An API is a way for one piece of software to talk to another, or for a page to ask the server for data or actions without a human clicking. In this story, JavaScript in the browser uses the browser's own built-in way of talking to the server (fetch()) to send requests on the administrator's behalf.
What XSS is. XSS stands for Cross-Site Scripting. It means getting your own code (usually JavaScript) into a page that other people view, so that their browsers run it. "Stored" XSS means the malicious text is saved on the server first, for example in a database, and then shown to victims later. The danger is that the code runs with the permissions of whoever is viewing the page.
What escaping is. When a web page shows text that came from a user, the server should convert special characters into harmless versions. For example, < becomes <, so the browser displays a literal less-than sign instead of treating it as the start of an HTML tag. If the server skips this step, user text can become live HTML and JavaScript. That skipped step is the core of XSS.
What an authorization check is. Authentication asks "who are you?". Authorization asks "are you allowed to do this?". This bug is an authorization failure: the server knew the code was valid, but never asked whether the person presenting it was the right person.
What CWE and CVE mean. CWE is a catalogue of weakness types; CWE-79 is Cross-Site Scripting, and CWE-639 is "Authorization Bypass Through User-Controlled Key", meaning the server trusts an identifier the user supplies. CVE is a public identifier for one specific reported vulnerability, so people can refer to it unambiguously. CNA is the organisation authorised to assign CVEs; here it was VulnCheck.
What CVSS is. A scoring system for how serious a vulnerability is. The report gives CVSS v4.0 5.3 Medium and v3.1 6.1 Medium.
The facts of the case
| Field | Value |
|---|---|
| CVE | CVE-2026-82535 |
| Product | Chamilo LMS |
| Affected | 1.11.0 to 1.11.40 and 2.0.0 to 2.0.3 |
| Fixed in | 1.11.42 and 3.0.0 |
| Weakness | CWE-79 (Stored XSS) via CWE-639 (Authorization Bypass Through User-Controlled Key) |
| Severity | CVSS v4.0 5.3 Medium; v3.1 6.1 Medium |
| CNA | VulnCheck |
In one sentence, as the authors put it: Chamilo's survey feature checks that an invitation code exists, but not that it belongs to the person presenting it, so an attacker can submit an answer attributed to someone else, which is then rendered without escaping to whoever reviews the results.
How the test was set up
The researchers built a fresh Chamilo 1.11.40 installation in a lab, meaning a test copy on their own machine, and created a survey with anonymous responses enabled. They stress that anonymous responses are an intentional feature, not a misconfiguration: Chamilo really does mean to let people without accounts answer surveys. The end-to-end proof was run in a real browser. They also read Chamilo's own source code and compared the vendor's actual fix line by line against the vulnerable version. They confirmed the same unpatched flaw exists in Chamilo 2.0.0 to 2.0.3, matching the advisory's affected range.
How they found it
Their method for auditing Chamilo starts with the pages that explicitly allow a visitor with no account, because that is the widest door into the application: if a page is designed to be used by strangers, it is the most likely place for a missing check. They searched the survey folder for the helper function Chamilo uses to mark a page as anonymous-friendly:
grep -rn "api_is_anonymous" main/survey/
Line by line: grep is a command-line tool that searches text. -r means search recursively, through every file in every subfolder. -n means show the line number of each match. "api_is_anonymous" is the exact string being searched for, the name of a function in Chamilo's code. main/survey/ is the folder to search. The result is a list of files and line numbers where that function is used.
main/survey/fillsurvey.php came back immediately. That is the page that lets someone fill in a survey. Since anonymous answering is intended, the interesting question was not "can anonymous people answer surveys" but "what actually stops someone from answering as somebody else?".
Reading the file to see what gated access, one comment on an unrelated function caught their eye:
function api_get_unique_id() { ... }
This is the start of a function definition. function declares it, api_get_unique_id is its name, the parentheses hold its inputs (none shown), and the braces hold its body, abbreviated here with .... The point is that a comment in Chamilo's own source stopped them and sent them looking for token generation nearby.
Hunting for how tokens are generated, they found that the invitation code for surveys is built in two different ways, one of them not even as strong as the flawed function the comment warns about:
if ($isAnonymous) {
$autoInvitationcode = 'auto-ANONY_'.md5(time())."-$surveyCode";
} else {
$autoInvitationcode = "auto-$userid-$surveyCode";
}
Line by line: if ($isAnonymous) asks whether the person answering is anonymous. If yes, the code is built as the literal text auto-ANONY_, followed by md5(time()), followed by a hyphen and the survey code. md5 is an old hashing function that turns any input into a fixed-length string; time() returns the current time as a number of seconds. So the anonymous code is essentially a scrambled timestamp, and as we will see, it is simply handed out. If the person is not anonymous, the code is auto-, then the user's numeric ID, then the survey code. That second line contains no secret material at all: it is a template filled in from a sequential user ID and a survey code that Chamilo lists to anonymous visitors elsewhere. From there the researchers traced forward: what validates this code, and what can you do once it is accepted?
The root cause: it checks the code exists, not who owns it
It is tempting to call the invitation code "proof of identity", but that overstates what it was designed to be. It is an authorization credential, and the flaw is that possessing it was treated as sufficient, with no check binding it to the person presenting it. Here is the validation query:
$sql = "SELECT * FROM $table_survey_invitation WHERE c_id=$course_id AND invitation_code='$code'";
if (Database::num_rows($result) < 1) {
api_not_allowed(true, get_lang('WrongInvitationCode'));
}
Line by line: the first line builds a database query. SELECT * means "give me every column". FROM $table_survey_invitation is the table of invitations. WHERE c_id=$course_id AND invitation_code='$code' narrows it to rows for this course whose invitation code equals the code supplied. The second line runs the query and asks how many rows came back. Database::num_rows($result) < 1 means "fewer than one row", in other words no match. If that is true, the third line calls api_not_allowed, which stops the request and shows the message "WrongInvitationCode". Notice what is missing: nowhere does the query compare the code to the identity of the person making the request. Any valid code is accepted from anyone.
The two invitation-code variants fail this in different ways, and it matters which is which:
auto-$userid-$surveyCode(a real, already-invited user): the code carries no secret at all. Anyone who knows or can enumerate a course code, a survey code and a target user ID can reconstruct it and answer as that person, without ever logging in. "Enumerate" means trying values in order, for example user IDs 1, 2, 3, until you find the one you want.auto-ANONY_<md5(time)>-$surveyCode(a fresh anonymous respondent): the attacker does not even need to guess anything, because the endpoint mints a brand-new, fully valid code for anyone who asks. Self-service anonymous response is intentional; the bug is that the same "does this code exist" check also gated the first case.
Either path lands in the same place: c_survey_answer.option_id, a longtext column with no length cap, stores the submitted text completely unsanitised, next to a reporting page that renders it with none of the escaping Chamilo already applies to the question text on the very same page. "Longtext" just means a database column that can hold a lot of text. "Unsanitised" means nothing was cleaned or filtered before saving.
There is a smaller companion bug in the same code path. The "already answered" guard, $survey_invitation['answered'] == 1 && !isset($_GET['user_id']), is skipped entirely by appending &user_id=1 to the request. In plain words: the code says "if this invitation is already marked as answered and no user_id was supplied, block it". Supplying a user_id parameter makes the second half false, so the whole condition is false and the block never happens. An attacker is therefore not limited to first-answer submissions.
Exploitation, step by step
Step 1: get an invitation without an account
GET /main/survey/fillsurvey.php?course=POCSURVEYCOURSE&invitationcode=auto&scode=POCSURVEY HTTP/1.1
Line by line: GET is the request method, asking the server for a page. /main/survey/fillsurvey.php is the survey filling page. course=POCSURVEYCOURSE names the course. invitationcode=auto is a placeholder value, not a real code. scode=POCSURVEY is the survey code. HTTP/1.1 states the protocol version. No cookie or login is sent with this request.
The server mints auto-ANONY_[MD5]-POCSURVEY on the spot and inserts it as a valid invitation. No credentials are presented. The attacker does not need to guess anything: the endpoint issues a brand-new, fully valid code to anyone who asks. This step exists to show that the first half of the attack needs no account at all.
Step 2: submit the payload under that invitation
POST /main/survey/fillsurvey.php?...&invitationcode=auto-ANONY_[MD5]-POCSURVEY&show=1 HTTP/1.1
question1=[INJECTED_PAYLOAD_HERE]
Line by line: POST means "here is data to store". The path is the same survey page; ... stands for the other parameters the page expects. invitationcode=auto-ANONY_[MD5]-POCSURVEY is the code the server just issued. show=1 is a parameter the page uses. The blank line separates the request headers from the body. question1=[INJECTED_PAYLOAD_HERE] is the body: the answer to question 1, where the placeholder stands for the malicious text. The researchers confirmed directly in the database that the raw bytes sent are the raw bytes stored, with no security sanitisation functions and no HTML character escaping:
SELECT option_id FROM c_survey_answer WHERE survey_id=1 AND question_id=1; — [INJECTED_PAYLOAD_HERE]
Line by line: SELECT option_id asks for one column, the stored answer. FROM c_survey_answer is the answers table. WHERE survey_id=1 AND question_id=1 picks the row for survey 1, question 1. The comment after the dash shows what came back: the payload exactly as sent. This step matters because it proves the storage layer did no cleaning; whatever the attacker typed is now sitting in the database.
Step 3: wait for an administrator to open the routine report
GET /main/survey/reporting.php?survey_id=1&action=completereport HTTP/1.1
Line by line: this is the request an administrator's browser makes when they open the survey results. reporting.php is the report page, survey_id=1 selects the survey, and action=completereport selects the full report view. This is ordinary usage, not a special trick: a teacher checking answers would do exactly this. The response contains the payload verbatim inside a live document body:
[DIV_ELEMENT_WITH_PAYLOAD]
This placeholder stands for the HTML element containing the stored payload. Because the server did not escape it, the browser treats it as part of the page and runs any script inside it, in the administrator's session. In the researchers' lab it created the backdoor administrator described next.
Step 4: turn the XSS into a permanent administrator account
The session cookie is HttpOnly, so this is not cookie theft: the script cannot read the cookie. But the script runs same-origin, meaning it runs as part of the Chamilo site itself, in whichever browser opens the poisoned report. That means it can drive any request that browser's session is authorised to make. In the lab, the payload used that access to fetch() Chamilo's own main/admin/user_add.php, read its CSRF token from the same page, and POST a new account with admin[platform_admin]=1.
A few terms there. fetch() is the browser's built-in function for sending a request from JavaScript. main/admin/user_add.php is Chamilo's own page for creating a user. A CSRF token is a random value the server puts into a form to prove the form was really loaded from the site and not forged from elsewhere; the script reads it from the page so its forged request looks legitimate. admin[platform_admin]=1 is the field that marks the new account as a platform administrator.
The result was a working, persistent platform-administrator account created from a single anonymous HTTP request, and the account survives even after the XSS itself is patched. This is the "backdoor account creation" that VulnCheck's advisory refers to. The authors are precise about the boundary: the vulnerability is stored XSS reachable before authentication. Admin-account creation is the specific, demonstrated consequence of that primitive in an administrator's session, not a separate flaw, and not evidence that credentials or session tokens were extracted directly.
A note on which report view is opened
reporting.php has a third view of the same stored answer, action=userreport (the per-respondent report), which happens to escape correctly because it renders the value through a form textarea that HTML-encodes its default. A textarea is a multi-line text box; when the server fills it in, it encodes special characters, so the payload shows as text instead of running. That is a different action from the two the researchers tested: action=completereport and action=questionreport, both of which they confirmed render the payload unescaped. Severity depends on which of the three an administrator happens to open.
Impact
The primitive on its own is stored XSS, nothing more. What raises the stakes beyond a typical Medium-rated bug is what the researchers did with that primitive, and they are careful about the boundary between the two. Because the cookie is HttpOnly, this is not cookie theft. The script runs same-origin in the browser of whoever opens the poisoned report, so it can drive any request that session is authorised to make. In an administrator's session that includes creating a platform administrator through main/admin/user_add.php, using the CSRF token read from the same page. The resulting account is persistent and survives patching of the XSS itself.
The authors do not claim extraction of credentials or session tokens directly.
The fix
The researchers compared the vendor's actual patch, the 1.11.x branch head carrying the 1.11.42 fix ahead of a formal tag, against the vulnerable release, rather than taking the advisory's word for it. It is three coordinated changes, addressing all three angles above.
- The anonymous code is now unguessable:
- $autoInvitationcode = ‘auto-ANONY_’.md5(time()).”-$surveyCode”;
+ $autoInvitationcode = ‘auto-ANONY_’.api_generate_secure_token(16).”-$surveyCode”;
Line by line: the minus line is the old code, the plus line is the new one. The only change is that md5(time()), a scrambled timestamp, is replaced by api_generate_secure_token(16), which asks Chamilo for a random token of 16 units. A timestamp can be predicted; a random token cannot.
- The user-specific code now has to belong to whoever is asking. The deterministic
auto-$userid-$surveyCodeformat was not removed; it is now checked against the requester's actual session:
$isInvitedUser = $currentUserId > 0 && (string) $currentUserId === $invitedUser;
if (0 === strpos($invitation_code, ‘auto-’) && ctype_digit($invitedUser) && (int) $invitedUser > 0 && !$isInvitedUser) { api_not_allowed(true, get_lang(‘WrongInvitationCode’));}
Line by line: the first line sets a true or false value. $currentUserId > 0 means someone is logged in. (string) $currentUserId === $invitedUser compares the logged-in user's ID, converted to text, with the user ID embedded in the invitation, using strict equality. Both must hold for $isInvitedUser to be true. The second line is the gate: if the invitation code starts with auto- (strpos(...) === 0), and the embedded user ID is all digits, and it is greater than zero, and the requester is not that invited user, then the request is refused with "WrongInvitationCode". This is the identity check that was missing.
- Both output sinks the researchers exploited now escape on the way out:
- echo $row[‘option_id’].’<hr noshade=”noshade” size=”1" />’;
+ echo Security::remove_XSS($row[‘option_id’]).’<hr noshade=”noshade” size=”1" />’;
Line by line: echo prints text into the page. The old line printed the stored answer directly, then a horizontal rule. The new line wraps the answer in Security::remove_XSS(...), which cleans dangerous HTML out of the value before printing it. The identical fix was applied in the complete-report row builder.
Chamilo 3.0.0 took a more radical approach for the same class of bug: rather than patch the sink, the entire legacy endpoint was retired. main/survey/fillsurvey.php in 3.0.0 is a stub that unconditionally denies access, with a comment stating that answering now happens through a new API that verifies the invitation belongs to the requester. Operators should update to 1.11.42 or later, or migrate to 3.0.0.
What this teaches
- Checking that a credential exists is not the same as checking who holds it. The fix did not remove the predictable code format; it added a binding check against the requester's actual identity. That is a different, stronger fix than "make the token longer".
- A feature built for one trust level can leak into another. Anonymous self-service answering was intentional; letting the same code format authorise answering as a known, already-invited user was not.
- Fix the sink and the source. This bug needed both a missing identity check and missing output escaping; the vendor's patch closes both.
- A recently audited codebase can still hide a bug in an unglamorous corner. Chamilo had just been through a large coordinated public security review. Surveys were not part of it.
Variants to test
- Other anonymous-capable endpoints with invitation or token parameters. Search for the anonymous-access helper across other modules, as the researchers did with
grep -rn "api_is_anonymous" main/survey/. A positive result is a handler that accepts a visitor with no account and gates access on a code or token rather than on a session identity. - Deterministic token formats built from public values. Look for tokens assembled from user IDs, course codes, survey codes or timestamps. A positive result is a token you can reconstruct for a target user from data the application shows to anonymous visitors, and then use to act as that user.
- Self-service token minting. Request a token with a placeholder value such as
invitationcode=autoand see whether the server issues a fresh valid one. A positive result is a new, usable credential returned to an unauthenticated client. - Existence-only validation queries. Read the validation code for checks that only count rows (
num_rows($result) < 1) without comparing the credential to the requester. A positive result is a query that would accept any valid code regardless of who presents it. - Stored input rendered in privileged views. Submit a marker into longtext fields and open every report or listing view that displays it. A positive result is the marker appearing verbatim in a live document body in one view while being encoded in another, which is exactly the split the researchers found between
action=completereportandaction=questionreporton one side andaction=userreporton the other. - Guard parameters that can be added to skip checks. Try appending parameters such as
&user_id=1to endpoints with "already answered" or similar guards. A positive result is the guard being bypassed and a second submission being accepted.
Conclusion
Nothing here required breaking cryptography or finding a memory-safety bug, just an authorization check answering the wrong question. "Does this invitation exist?" instead of "does it belong to you?" sat one unescaped output away from a script running in an administrator's browser. The vendor's fix confirms which question mattered: they did not just encode the output, they added the identity check that should have been there from the start.
Glossary
- API: a defined way for one piece of software to talk to another, or for a page to ask the server for data or actions.
- Authentication: the process of proving who you are, usually by logging in.
- Authorization: the process of deciding whether an identified person is allowed to do a particular thing.
- Backdoor account: an account an attacker creates for later access, which keeps working after the original bug is fixed.
- Chamilo LMS: open-source e-learning software that organisations install on their own servers to run courses, quizzes and surveys.
- CNA: the organisation authorised to assign CVE identifiers; here, VulnCheck.
- Cookie: a small piece of text a server gives your browser so it can recognise you on later requests.
- CSRF token: a random value placed in a form to prove the form was genuinely loaded from the site and not forged elsewhere.
- CVE: a public identifier for one specific reported vulnerability.
- CVSS: a scoring system for the severity of a vulnerability.
- CWE: a catalogue of weakness types, such as CWE-79 for Cross-Site Scripting.
- Database: organised storage on the server, made of tables with rows and columns.
- Deterministic: built by a fixed rule, so the same inputs always produce the same output and it can be predicted.
- Endpoint: a specific address on a server that accepts requests, such as a particular page or script.
- Escaping: converting special characters in user text into harmless versions so the browser shows them as text instead of running them.
- Existence check: a check that something is present in the database, without checking who it belongs to.
- fetch(): the browser's built-in JavaScript function for sending a request to a server.
- GET: an HTTP method meaning "give me this page or data".
- grep: a command-line tool that searches text files for a pattern.
- Hash (md5): a function that turns any input into a fixed-length string; md5 is an old one and is not suitable for secrets.
- HttpOnly: a cookie setting that stops JavaScript in the page from reading the cookie.
- Invitation code: the token Chamilo requires before accepting a survey answer.
- JavaScript: the programming language browsers run inside web pages.
- Longtext: a database column type that can hold a large amount of text.
- Origin: the combination of scheme, host and port that identifies a site; same-origin code runs with that site's permissions.
- Parameter: a name equals value pair in a URL or request body, such as
survey_id=1. - POST: an HTTP method meaning "here is data to store or process".
- Request: a message a browser sends to a server asking for a page or an action.
- Response: the message the server sends back.
- Sanitisation: cleaning input to remove anything dangerous before storing or displaying it.
- Session: the server's record of your logged-in state, tied to your cookie.
- SQL: the language used to query databases.
- Stored XSS: Cross-Site Scripting where the malicious text is saved on the server and shown to victims later.
- Survey code: the short identifier for a particular survey in Chamilo.
- Token: a short string issued by a server that grants some permission when presented.
- User ID: the number that identifies a user account in the database.
- XSS (Cross-Site Scripting): getting your own code into a page other people view, so their browsers run it with their permissions.