I Audited the Entire CMS, 73 Vulnerabilities Were Waiting | Cotonti
The Cotonti CMS has numerous missing CSRF checks, including in the URL Editor plugin, which allows an attacker to write arbitrary Apache directives to .htaccess. Combined with an unrestricted file upload, this can lead to remote code execution.
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
Cotonti is a PHP content management framework that has been around since 2008 and is used to build community and content-heavy sites. It has a modular plugin system, and version 1.0.0 was released in 2024 and is still current. The audit described here covers the 1.0.0 line and earlier (the Siena branch), tested at commit f43f1fc, which was current master at the time.
The framework ships its own anti-CSRF mechanism: a function called cot_check_xg() in system/functions.php. It is supposed to be called before state-changing requests to verify the CSRF token. Whether it is called is opt-in, and that design choice is the thread running through most of what follows.
This post is the public reference for coordinated CVE assignment of all findings described. All vulnerabilities were discovered by the researcher and had not been reported to the vendor at the time of writing; disclosure was being coordinated through VulnCheck CNA. It follows three earlier posts on the same CMS: one on a PHP object injection sink, one on six further vulnerabilities found on a second pass, and one on CVE assignments, an incomplete fix caught by another researcher, and the corrected PR.

Setup
The audit was a systematic, file-by-file review of commit f43f1fc, not a second or third pass. 75 IDs were reviewed: 73 were confirmed vulnerabilities and 2 were invalid (one false positive, one with no exploitable path found). The severity split was 1 Critical, 11 High, 50 Medium, 8 Low and 3 Informational.
| Severity | Count | IDs |
|---|---|---|
| Critical (9.0) | 1 | C45 |
| High (7.0-8.9) | 11 | C13, C14, C18, C23, C24, C25, C33, C52, C78, C79, C84 |
| Medium (4.0-6.9) | 50 | all remaining confirmed IDs |
| Low (0.1-3.9) | 8 | C8, C15, C21, C22, C27, C46, C50, C57 |
| Informational | 3 | C16, C28, C71 |
C20 was a false positive and C58 had no exploitable path. No fixed version existed at the time of writing, and all findings apply to Cotonti at commit f43f1fc.
Finding it
The starting observation is structural rather than a single suspicious line. Cotonti has a working CSRF defence, but calling it is opt-in, and it was forgotten in the majority of state-changing handlers across the codebase. Once that pattern is visible, each admin handler becomes a candidate: does it mutate state, and does it call cot_check_xg() before doing so?
The most serious result came from combining two separate weaknesses. The URL Editor plugin lets admins manage .htaccess directives from the admin panel. Its save handler, plugins/urleditor/urleditor.admin.php, has no CSRF token, and the custom_htaccess field is imported with NOC, Cotonti's raw, unsanitized import mode, then written directly to .htaccess with file_put_contents. On its own that is C33, a High: an attacker can forge a POST to an admin's session and write arbitrary Apache directives into the site's .htaccess. Combined with the Personal File System (PFS), where users can upload files, it becomes remote code execution.
Exploitation
Step 1: write the handler mapping through CSRF
The forged request makes the URL Editor write this directive to .htaccess:
AddType application/x-httpd-php .jpg
This tells Apache to hand .jpg files to the PHP handler.
Step 2: upload a PHP shell
A PHP shell is uploaded through PFS as shell.jpg. PFS does not strip this extension.
Step 3: request the shell
Requesting BASE/path/to/shell.jpg makes Apache execute the file as PHP.
The chain has three preconditions: an admin victim who clicks a malicious link, Apache with AllowOverride not set to None, and .htaccess being writable by PHP. The researcher notes that all three are realistic on typical shared hosting or default Apache deployments.
The CVSS 3.1 vector is AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H, and the score is 9.0 Critical. The weakness chain is CWE-352 to CWE-94, with the admin as victim.
C33: the base of the chain
CSRF plus a raw .htaccess write with no token, at plugins/urleditor/urleditor.admin.php, CVSS 8.2. Even without the RCE chain, an attacker can modify routing, add or remove redirects, or break availability by corrupting .htaccess.
C13: privilege escalation to superadmin
The admin panel for managing user accounts and group assignments, system/admin/admin.users.php, has no cot_check_xg() call anywhere in the file. A single forged POST can change any user's group to COT_GROUP_SUPERADMINS (group 5):
POST /admin.php?m=users&a=edit&id=TARGET rusermaingrp=5
No token is required. The admin only has to be logged in when their browser sends the request, via an image tag, an auto-submitting form, or any other cross-site trigger. CVSS 8.0.
C14: per-item rights
system/admin/admin.rightsbyitem.php is the same class of bug. The per-item rights editor writes permission rows from request parameters with no CSRF token, so an attacker can grant arbitrary access rights to any group on any item against an admin session. CVSS 8.0.
C18: structure add/update, and stored XSS
In system/admin/admin.structure.php, the delete and resyncall actions check the CSRF token; add and update do not. A forged structure add can write a title containing an XSS payload, which then executes for every visitor of the category list through C77, where structure titles are rendered unescaped in page.list.php. CVSS 8.0.
C23: unauthenticated installer update path
If install.php is left in place after installation, which the install process does not enforce removal of, any unauthenticated visitor can trigger the update path:
curl -s BASE/install.php
There is no login and no admin check. The update path re-runs cot_extension_install() for every module and plugin and truncates the cache table, repeatably, as many times as anyone on the internet wants. The database migration paths (COT_UPGRADE) and the config.php rewrite are gated separately, so this does not modify the database schema on a current install, but it resets extension setup and wipes the cache on every call. CVSS 7.5, CWE-306.
C24: extra-field admin, the setup step for C52
Extra fields are how Cotonti adds custom data columns to pages, users and other entities. The admin interface for creating and editing them, system/admin/admin.extrafields.php, has no CSRF token. A forged extra-field add request against an admin session can create a file-type extra-field with empty variants, which is the setup step for the conditional RCE in C52. CVSS 8.0.
C25 / C78: extension install, update and pause
In system/admin/admin.extensions.php, the uninstall action checks cot_check_xg(false); install, update and pause do not. A GET request is enough to force installation or update of any extension:
GET BASE/admin.php?m=extensions&b=update&x=EXT
Forcing a reinstall via CSRF against an admin session can reset extension configuration or trigger re-execution of install scripts. CVSS 8.0.
C52: file extra-field accepts any extension
In system/extrafields.php plus datas/.htaccess, an extra-field created with type file and empty variants accepts any extension on upload. The datas/ directory's .htaccess denies only .dat and .php, not .phtml, .php7, .php8, .phar or .shtml. A writer can upload evil.phtml containing PHP code to a web-reachable path and request it; Apache maps .phtml to the PHP handler by default. This can be reached directly by an admin, or set up via the C24 CSRF against an admin session. CVSS 8.5, CWE-434.
C79: site configuration
system/admin/admin.config.php has no CSRF token on its configuration update and reset handler. An attacker can alter any site configuration setting against an admin session: disabling security features, changing email settings, modifying upload rules. CVSS 8.0.
C84: global rights editor
system/admin/admin.rights.php writes permission rows with no token, the same story as C13 and C14: privilege escalation against an admin session. CVSS 8.0.
C47: unauthenticated reflected XSS via search highlight
In plugins/search/search.header.php, the highlight parameter is imported with the TXT filter, with the < character stripping commented out in the source, then interpolated directly into a JavaScript new RegExp() call without escaping:
// search.page.first.php:16cot_import('highlight', 'G', 'TXT');
// search.header.php:36new RegExp('{$wordsToHighlight}', "gi")
The payload:
GET BASE/index.php?e=page&id=1&highlight=%27);alert(document.domain);//
No login is required and the script executes in the victim's browser. A crafted link sent to an admin can be used to steal their CSRF token and chain into any of the admin CSRF bugs above. CVSS 6.1.
C72: unauthenticated reflected XSS via message.php lng
In message.php, for msg=920, if the lng parameter does not match a key in the language array, the value itself is used as the message body and rendered unescaped:
$body = isset($L[$lng]) ? $L[$lng] : $lng;
The payload:
GET BASE/message.php?msg=920&lng=<script>alert(document.domain)</script>
This is unauthenticated and works on any Cotonti install. The fix is to accept only lng values that are existing keys in $L and to pass the body through htmlspecialchars(). CVSS 6.1.
C44: unauthenticated open redirect via message.php error pages
For error codes 400/401/403/404/500, the redirect parameter is base64-decoded and placed in a <meta http-equiv="refresh"> tag with no URL validation. The base64 alphabet contains no colon, so the entry filter that strips : does not block it:
GET BASE/message.php?msg=404&redirect=aHR0cHM6Ly9ldmlsLmNvbQ==
This produces a meta-refresh to https://evil.com. No login is required, and it works as a phishing or token-relay vector. CVSS 6.1.
C49: first registrant becomes superadmin
In modules/users/inc/users.functions.php:
elseif (Cot::$db->countRows($db_users) == 0) { $tmp2 = COT_GROUP_SUPERADMINS;}
The count check and the insert are not atomic. On a fresh database, or after all users have been removed, any registration creates a superadmin account, and two concurrent registrations in that window can both be elevated. This is a race condition plus privilege escalation. CVSS 6.5.
C53: client IP spoofing via proxy headers
In system/functions.php, the client IP is read from HTTP_CLIENT_IP, then X-Forwarded-For, then REMOTE_ADDR, with no trusted-proxy gate. Any request can present an arbitrary IP address:
X-Forwarded-For: [redacted]
This bypasses IP bans, rate limits and IP-based deduplication, including the poll vote dedup in C26, and poisons logs. The fix is to trust forwarded headers only from configured, known proxy IPs. CVSS 5.3.
C26: poll double-vote race
In modules/polls/inc/polls.functions.php, a check-then-insert with no UNIQUE constraint on (pv_pollid, pv_userid) means concurrent vote requests can each pass the existence check before either inserts, producing multiple vote rows from the same account. Guest dedup uses IP, which is spoofable via C53. CVSS 4.3.
C77: stored XSS via structure title
In modules/page/inc/page.list.php, category titles at lines 308 and 439 are assigned to template variables without htmlspecialchars(). A title set to an XSS payload, either directly by anyone with structure-write access or via the C18 CSRF, executes for every visitor who loads the category list. CVSS 5.4.
Root cause
Cotonti's anti-CSRF mechanism works: when cot_check_xg() is called, requests without a valid token are rejected. The problem is that calling it is opt-in, and it was forgotten in the majority of state-changing handlers. The full list of files where CSRF protection is missing on mutating actions:
| ID | File | What an attacker can forge |
|---|---|---|
| C11 | modules/pfs/inc/pfs.edit.php |
Edit/rename files/folders |
| C12 | plugins/i18n/inc/i18n.page.php, i18n.structure.php |
Translation mutations |
| C13 | system/admin/admin.users.php |
Privilege escalation to superadmin |
| C14 | system/admin/admin.rightsbyitem.php |
Permission changes |
| C17 | plugins/contact/contact.tools.php |
Contact moderation |
| C18 | system/admin/admin.structure.php |
Structure add/edit (→ XSS) |
| C19 / C68 | plugins/comments/controllers/actions/CreateAction.php |
Post comments |
| C24 | system/admin/admin.extrafields.php |
Create/modify data fields (→ RCE) |
| C25 / C78 | system/admin/admin.extensions.php |
Install/update extensions |
| C29 | modules/page/inc/page.edit.php |
Edit any page |
| C30 / C67 | modules/page/inc/page.add.php |
Create pages |
| C31 | plugins/banlist/banlist.admin.php |
Add/remove bans |
| C32 / C60 | plugins/ratings/ratings.ajax.php |
Forge ratings |
| C33 | plugins/urleditor/urleditor.admin.php |
Write .htaccess (→ RCE) |
| C36 / C62 | modules/pm/inc/pm.send.php |
Send private messages |
| C37 / C61 | modules/forums/inc/forums.newtopic.php |
Create forum topics |
| C38 / C61 | modules/forums/inc/forums.posts.php |
Create forum posts |
| C39 | plugins/referers/referers.admin.php |
Wipe referer data |
| C40 | modules/pm/inc/pm.list.php |
Star/flag messages |
| C41 | plugins/autoalias2/autoalias2.admin.php |
Bulk rewrite page aliases |
| C48 | plugins/userimages/userimages.admin.php |
Modify user-image config |
| C51 | plugins/comments/controllers/actions/EditAction.php |
Edit comments (+ object injection) |
| C59 | plugins/i18n/inc/i18n.page.php, i18n.structure.php |
Translation mutations (duplicate ID from different file) |
| C64 | plugins/contact/contact.php |
Forge contact submissions |
| C65 | PFS upload/newfolder handlers | Upload files to victim's file store |
| C70 | modules/polls/inc/polls.functions.php |
Forge poll votes |
| C79 | system/admin/admin.config.php |
Change site configuration |
| C84 | system/admin/admin.rights.php |
Modify access rights |
The admin-facing ones (C13, C14, C24, C25, C33, C78, C79, C84) are the most dangerous because they enable privilege escalation and site takeover. An attacker who can get any admin to load a malicious page, through a crafted link, an image in a forum post or a spoofed email, can chain these.
A second root cause is token generation. Cotonti generates validation tokens in three places using the same pattern:
$validationKey = md5(microtime());
microtime() returns the current server time in microseconds and md5() is fast, so an attacker who knows roughly when a request was made can brute-force the token window in seconds. The Date response header hands them the server time. The affected flows are password recovery (users.passrecover.php), new account registration (users.functions.php) and email address change (users.profile.php). All three write to the user_lostpass column, which is the only thing standing between an attacker and a successful account takeover via the recovery flow.
Separately, cot_unique() in system/functions.php generates tokens using sha1(mt_rand()). mt_rand() is a Mersenne Twister, not a CSPRNG, and its state can be recovered with enough output samples, making tokens derived from it predictable.
Impact
The headline impact is the C45 chain: an admin victim who clicks a malicious link can be made to write an Apache directive that turns a PFS-uploaded .jpg into executable PHP, giving remote code execution under the stated preconditions. Short of that, the admin CSRF bugs allow privilege escalation to superadmin (C13), arbitrary permission changes (C14, C84), arbitrary site configuration changes (C79), extension install/update (C25/C78) and the setup of the C52 upload path (C24).
The most urgent unauthenticated issues are C23 (installer update path, repeatable by anyone), C44 (open redirect), C47 and C72 (reflected XSS). C47 is particularly useful to an attacker because a crafted link sent to an admin can steal their CSRF token and chain into the admin CSRF bugs.
Other confirmed findings worth naming:
- C55: WhosOnline exposes real IP addresses to non-admins. The
online_ipfield is assigned to template variables visible to any user who can view the WhosOnline plugin, not just admins; only the clickable IP-search link is gated to admins. - C15: the session cookie is set with a leading-dot domain (
'.' . domain), sharing it across every subdomain, so a compromise of any subdomain such assub.example.comcan access the main site's session cookie. - C43 / C69:
cot_user_authorize()never callssession_regenerate_id(true). If an attacker can pre-set a known session ID in the victim's browser (session fixation), the victim's login authenticates that known ID. - C85: the contact page accepts a
tplGET parameter and passes it tocot_tplfile()without restricting to known template names; path traversal with../can reference other.tplfiles outside the expected directory. - C86: any token derived from
cot_unique()is predictable if enoughmt_rand()output is observable. It is used in session and authentication token generation.
Fix
No fixed version existed at the time of writing. The report gives the following recommendations:
- For C45 and C33: require
cot_check_xg()on the URL Editor save, do not write raw, unvalidated.htaccesscontent, and keep.htaccessnon-writable by the web process. - For C72: accept only
lngvalues that are existing keys in$L, and pass the body throughhtmlspecialchars(). - For C53: trust forwarded headers only from configured, known proxy IPs.
- For the token generation issues: use
bin2hex(random_bytes(32)).
For operators running Cotonti while awaiting patches, the most urgent items are the unauthenticated bugs (C23, C44, C47, C72) and the admin-CSRF chains that lead to RCE (C33, C45). For C23, remove install.php from the web root. For C47 and C72, WAF rules blocking the PoC parameters are a stopgap, not a fix.
Variants to test
- Missing
cot_check_xg()on mutating admin handlers. Enumerate every admin action that writes state and check whether the token is verified. A positive result is a forged cross-site request that changes data while the admin is logged in, with no token in the request. - Raw import modes feeding file writes. Look for fields imported with
NOC(or equivalent raw modes) that end up infile_put_contentsor similar. A positive result is attacker-controlled content appearing verbatim in a configuration or.htaccessfile. - Extension denylists that name only a few suffixes. Compare the denylist against what the web server actually maps to a handler (
.phtml,.php7,.php8,.phar,.shtml). A positive result is an uploaded file with a non-denied suffix being executed. - Base64-encoded redirect parameters. Check whether a filter that strips
:is bypassed by base64, which contains no colon. A positive result is a meta-refresh to an external host. - Language or message parameters used as fallback content. Supply a key that does not exist and see whether the raw value is reflected. A positive result is unescaped script execution.
- Non-atomic count-then-insert checks. Look for
countRows(...) == 0style guards before inserts. A positive result is two concurrent requests both succeeding where only one should. - Trusting
X-Forwarded-Forwithout a proxy allowlist. Send a spoofed header and observe whether bans, rate limits or deduplication are bypassed. - Time-based tokens (
md5(microtime())). Where a token is derived from server time, check whether theDateheader narrows the search space enough to brute-force it. A positive result is a valid token recovered within a plausible window. - Session cookies scoped to a parent domain. Check the
Domainattribute for a leading dot. A positive result is the cookie being sent to, and usable from, a sibling subdomain. - Login flows without
session_regenerate_id(true). A positive result is a pre-set session ID remaining valid after authentication.
What happened, in plain words
A security researcher sat down and read through the entire source code of a piece of software called Cotonti, line by line, looking for mistakes. Cotonti is a free, open-source toolkit written in PHP (a programming language used to build websites) that people use to build community sites and content-heavy sites. It has been around since 2008, and version 1.0.0 came out in 2024 and is still the current version.
The researcher did not just glance at it. He went through the code file by file at one specific saved state of the project, identified by a short code called a commit, f43f1fc. He reviewed 75 candidate issues. 73 of them turned out to be real vulnerabilities (weaknesses an attacker could abuse). Two were not: one was a false alarm, and one had no way for an attacker to actually reach it.
The worst of the 73 is rated 9.0 out of 10 on a standard scoring system called CVSS, and it can end with an attacker running their own code on the victim's web server. That is called remote code execution, or RCE.

This article is the public record used while the vulnerabilities are being assigned official CVE numbers (CVE is a public catalogue number given to a known security flaw). At the time of writing the researcher had not yet told the vendor (the people who make Cotonti), and the disclosure process was being coordinated through an organisation called VulnCheck CNA. It follows three earlier articles he wrote about the same software: one about a PHP object injection sink, one about six more bugs found on a second pass, and one about CVE assignments, an incomplete fix caught by another researcher, and the corrected fix.
The numbers
The audit was a systematic review, not a second or third pass. Of the 75 IDs reviewed, 73 were confirmed vulnerabilities and 2 were invalid. The severity split was 1 Critical, 11 High, 50 Medium, 8 Low and 3 Informational.
| Severity | Count | IDs |
|---|---|---|
| Critical (9.0) | 1 | C45 |
| High (7.0-8.9) | 11 | C13, C14, C18, C23, C24, C25, C33, C52, C78, C79, C84 |
| Medium (4.0-6.9) | 50 | all remaining confirmed IDs |
| Low (0.1-3.9) | 8 | C8, C15, C21, C22, C27, C46, C50, C57 |
| Informational | 3 | C16, C28, C71 |
C20 was a false positive and C58 had no exploitable path. No fixed version existed at the time of writing, and all findings apply to Cotonti at commit f43f1fc.
Severity here is a rough measure of how much damage a bug allows and how easy it is to trigger. "Informational" means it is worth knowing about but is not, on its own, a practical attack.
What Cotonti is, and the one design choice behind most of this
Cotonti is a PHP content management framework: a base that other people build websites on top of. It has a modular plugin system, meaning features are added as separate plug-in pieces.
The framework ships its own defence against a very common web attack called CSRF, short for cross-site request forgery. To understand CSRF, imagine you are logged in to your bank in one browser tab. In another tab you open a random website. That random website can quietly make your browser send a request to the bank, and because your browser automatically attaches your login cookie (a small piece of data the bank gave your browser to prove who you are), the bank thinks the request came from you. The attacker never sees your password; they just borrow your logged-in browser.
The standard defence is a token: a random value the site gives your browser and expects back with any request that changes something. A malicious site cannot guess it, so the forged request is rejected. Cotonti has a function for exactly this, called cot_check_xg(), in system/functions.php. It works: when it is called, requests without a valid token are refused.
The catch is that calling it is opt-in. A developer has to remember to put it in front of every action that changes data. In Cotonti, that reminder was forgotten in the majority of such handlers. That single design choice is the thread running through most of what follows.
Finding it
The starting point was not one suspicious line of code but a pattern. Cotonti has a working CSRF defence, but it is opt-in, and it was left out of most handlers that change state. Once you see that, every admin handler becomes a question: does it change something, and does it call cot_check_xg() first?
The most serious result came from combining two separate weaknesses. Cotonti has a URL Editor plugin that lets administrators manage .htaccess directives from the admin panel. .htaccess is a small configuration file that tells an Apache web server (the software that serves the website) how to behave for a folder: redirects, access rules, and which file types get handled by which program. Its save handler, plugins/urleditor/urleditor.admin.php, has no CSRF token, and the custom_htaccess field is imported with NOC, Cotonti's raw, unsanitized import mode, then written straight to .htaccess with file_put_contents (a PHP function that writes text into a file).
On its own that is C33, a High: an attacker can forge a POST (a request that submits data) to an admin's session and write arbitrary Apache directives into the site's .htaccess. Combined with the Personal File System (PFS), where users can upload files, it becomes remote code execution.
Exploitation
Step 1: write the handler mapping through CSRF
The forged request makes the URL Editor write this directive to .htaccess:
AddType application/x-httpd-php .jpg
Line by line: AddType is an Apache instruction that says "treat files of this type in this way". application/x-httpd-php is the internal name Apache uses for the PHP interpreter. .jpg is the file extension being reassigned. The whole line means: any file ending in .jpg should be handed to PHP and run as a program, instead of being shown as a picture. Normally a .jpg is harmless because the server just sends the bytes to the browser. After this line, the server executes them.
Step 2: upload a PHP shell
A PHP shell is uploaded through PFS as shell.jpg. PFS does not strip this extension. A "shell" here means a small script that, once it runs on the server, lets the attacker run commands there.
Step 3: request the shell
Requesting BASE/path/to/shell.jpg makes Apache execute the file as PHP. BASE stands for the site's address; the rest is wherever the uploaded file landed.
The chain has three preconditions: an admin victim who clicks a malicious link, Apache with AllowOverride not set to None, and .htaccess being writable by PHP. AllowOverride is the Apache setting that decides whether .htaccess files are allowed to change behaviour at all; if it is None, the trick does nothing. The researcher notes that all three are realistic on typical shared hosting or default Apache deployments.
The CVSS 3.1 vector is AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H, and the score is 9.0 Critical. That string is a compact score recipe: network reachable, high attack complexity, no privileges needed, the user must interact, scope changed, and high impact on confidentiality, integrity and availability. The weakness chain is CWE-352 (CSRF) to CWE-94 (code injection), with the admin as victim.
C33: the base of the chain
CSRF plus a raw .htaccess write with no token, at plugins/urleditor/urleditor.admin.php, CVSS 8.2. Even without the RCE chain, an attacker can modify routing (which address leads to which page), add or remove redirects, or break availability by corrupting .htaccess.
C13: privilege escalation to superadmin
The admin panel for managing user accounts and group assignments, system/admin/admin.users.php, has no cot_check_xg() call anywhere in the file. A single forged POST can change any user's group to COT_GROUP_SUPERADMINS (group 5):
POST /admin.php?m=users&a=edit&id=TARGET rusermaingrp=5
Line by line: POST is the request type used to submit data. /admin.php is the admin page. m=users selects the users module, a=edit selects the edit action, and id=TARGET says which account to change. rusermaingrp=5 sets that account's group to group 5, the superadmin group. No token is required. The admin only has to be logged in when their browser sends the request, via an image tag, an auto-submitting form, or any other cross-site trigger. CVSS 8.0.
C14: per-item rights
system/admin/admin.rightsbyitem.php is the same class of bug. The per-item rights editor writes permission rows from request parameters with no CSRF token, so an attacker can grant arbitrary access rights to any group on any item against an admin session. CVSS 8.0.
C18: structure add/update, and stored XSS
In system/admin/admin.structure.php, the delete and resyncall actions check the CSRF token; add and update do not. A forged structure add can write a title containing an XSS payload, which then executes for every visitor of the category list through C77, where structure titles are rendered unescaped in page.list.php. CVSS 8.0.
XSS, cross-site scripting, means getting a site to send an attacker's JavaScript to other people's browsers. "Stored" means the malicious text is saved on the server and served to everyone who loads the page, rather than being reflected back only to the person who sent it.
C23: unauthenticated installer update path
If install.php is left in place after installation, which the install process does not enforce removal of, any unauthenticated visitor can trigger the update path:
curl -s BASE/install.php
Line by line: curl is a command-line tool for fetching a web address. -s means silent, so it does not print progress noise. BASE/install.php is the installer script still sitting on the server. There is no login and no admin check. The update path re-runs cot_extension_install() for every module and plugin and truncates the cache table, repeatably, as many times as anyone on the internet wants. The database migration paths (COT_UPGRADE) and the config.php rewrite are gated separately, so this does not modify the database schema on a current install, but it resets extension setup and wipes the cache on every call. CVSS 7.5, CWE-306 (missing authentication for a critical function).
C24: extra-field admin, the setup step for C52
Extra fields are how Cotonti adds custom data columns to pages, users and other entities. The admin interface for creating and editing them, system/admin/admin.extrafields.php, has no CSRF token. A forged extra-field add request against an admin session can create a file-type extra-field with empty variants, which is the setup step for the conditional RCE in C52. CVSS 8.0.
C25 / C78: extension install, update and pause
In system/admin/admin.extensions.php, the uninstall action checks cot_check_xg(false); install, update and pause do not. A GET request is enough to force installation or update of any extension:
GET BASE/admin.php?m=extensions&b=update&x=EXT
Line by line: GET is the ordinary request type used when you load a page. BASE/admin.php is the admin page. m=extensions selects the extensions module, b=update selects the update action, and x=EXT names the extension. Because a GET can be triggered simply by loading an address, an attacker does not even need a form. Forcing a reinstall via CSRF against an admin session can reset extension configuration or trigger re-execution of install scripts. CVSS 8.0.
C52: file extra-field accepts any extension
In system/extrafields.php plus datas/.htaccess, an extra-field created with type file and empty variants accepts any extension on upload. The datas/ directory's .htaccess denies only .dat and .php, not .phtml, .php7, .php8, .phar or .shtml. A writer can upload evil.phtml containing PHP code to a web-reachable path and request it; Apache maps .phtml to the PHP handler by default. This can be reached directly by an admin, or set up via the C24 CSRF against an admin session. CVSS 8.5, CWE-434 (unrestricted upload of a dangerous file type).
C79: site configuration
system/admin/admin.config.php has no CSRF token on its configuration update and reset handler. An attacker can alter any site configuration setting against an admin session: disabling security features, changing email settings, modifying upload rules. CVSS 8.0.
C84: global rights editor
system/admin/admin.rights.php writes permission rows with no token, the same story as C13 and C14: privilege escalation against an admin session. CVSS 8.0.
C47: unauthenticated reflected XSS via search highlight
In plugins/search/search.header.php, the highlight parameter is imported with the TXT filter, with the < character stripping commented out in the source, then interpolated directly into a JavaScript new RegExp() call without escaping:
// search.page.first.php:16cot_import('highlight', 'G', 'TXT');
Line by line: the // marks a comment, so the code shown is the line at line 16 of search.page.first.php. cot_import is Cotonti's function for reading a value from the request. 'highlight' is the name of the value being read, 'G' says it comes from the GET parameters (the part of the address after the question mark), and 'TXT' is the filter applied. The comment in the source notes that stripping < was disabled.
// search.header.php:36new RegExp('{$wordsToHighlight}', "gi")
Line by line: this is line 36 of search.header.php. new RegExp(...) builds a JavaScript pattern used for matching text. {$wordsToHighlight} is where the user-supplied value is dropped in, unescaped. "gi" sets the pattern to global and case-insensitive matching. Because the value is pasted into code rather than treated as plain text, characters that mean something to JavaScript are obeyed.
The payload:
GET BASE/index.php?e=page&id=1&highlight=%27);alert(document.domain);//
Line by line: GET loads the page. BASE/index.php is the site's main entry script. e=page selects the page component, id=1 picks a page, and highlight= carries the attack. %27 is the URL-encoded form of a single quote, which closes the string in the JavaScript. ); closes the function call, alert(document.domain) pops up a box showing the site's domain, and // comments out whatever follows so the rest of the original code does not cause an error. No login is required and the script executes in the victim's browser. A crafted link sent to an admin can be used to steal their CSRF token and chain into any of the admin CSRF bugs above. CVSS 6.1.
C72: unauthenticated reflected XSS via message.php lng
In message.php, for msg=920, if the lng parameter does not match a key in the language array, the value itself is used as the message body and rendered unescaped:
$body = isset($L[$lng]) ? $L[$lng] : $lng;
Line by line: $body is the variable that will hold the message text. isset($L[$lng]) asks whether the language array $L contains an entry for the requested language key $lng. The ? ... : ... is a compact if/else: if it exists, use the stored translation $L[$lng]; otherwise use the raw $lng value the visitor supplied. That fallback is the flaw: an unknown key is echoed back as-is.
The payload:
GET BASE/message.php?msg=920&lng=<script>alert(document.domain)</script>
Line by line: GET loads the page. BASE/message.php is the message script. msg=920 selects the message type. lng= is the language key, and instead of a real key it carries a script tag. Because the fallback uses the value directly, the browser runs it. This is unauthenticated and works on any Cotonti install. The fix is to accept only lng values that are existing keys in $L and to pass the body through htmlspecialchars() (a PHP function that turns characters like < into harmless text). CVSS 6.1.
C44: unauthenticated open redirect via message.php error pages
For error codes 400/401/403/404/500, the redirect parameter is base64-decoded and placed in a <meta http-equiv="refresh"> tag with no URL validation. Base64 is a way of writing any data using only letters, digits and a few symbols; it contains no colon. The entry filter that strips : therefore does not block it:
GET BASE/message.php?msg=404&redirect=aHR0cHM6Ly9ldmlsLmNvbQ==
Line by line: GET loads the page. BASE/message.php is the message script. msg=404 selects the "not found" error page. redirect= carries aHR0cHM6Ly9ldmlsLmNvbQ==, which is base64 for https://evil.com. The server decodes it and puts it in a meta-refresh tag, which tells the browser to go to that address. This produces a meta-refresh to https://evil.com. No login is required, and it works as a phishing or token-relay vector. CVSS 6.1.
C49: first registrant becomes superadmin
In modules/users/inc/users.functions.php:
elseif (Cot::$db->countRows($db_users) == 0) { $tmp2 = COT_GROUP_SUPERADMINS;}
Line by line: elseif continues a chain of conditions. Cot::$db->countRows($db_users) counts the rows in the users table of the database. == 0 checks whether that count is zero, meaning nobody has registered yet. If so, $tmp2 is set to COT_GROUP_SUPERADMINS, the top-level group. The count check and the insert are not atomic: there is a gap between checking and writing. On a fresh database, or after all users have been removed, any registration creates a superadmin account, and two concurrent registrations in that window can both be elevated. This is a race condition plus privilege escalation. CVSS 6.5.
C53: client IP spoofing via proxy headers
In system/functions.php, the client IP is read from HTTP_CLIENT_IP, then X-Forwarded-For, then REMOTE_ADDR, with no trusted-proxy gate. An IP address is the number that identifies a machine on a network. X-Forwarded-For is a header (a labelled line of extra information sent with a request) that proxies use to say who the original visitor was. Any request can present an arbitrary IP address:
X-Forwarded-For: [redacted]
Line by line: the header name is X-Forwarded-For and the value is [redacted], a made-up address. Because the server believes it without checking whether the request came from a trusted proxy, the visitor can claim to be anyone. This bypasses IP bans, rate limits and IP-based deduplication, including the poll vote dedup in C26, and poisons logs. The fix is to trust forwarded headers only from configured, known proxy IPs. CVSS 5.3.
C26: poll double-vote race
In modules/polls/inc/polls.functions.php, a check-then-insert with no UNIQUE constraint on (pv_pollid, pv_userid) means concurrent vote requests can each pass the existence check before either inserts, producing multiple vote rows from the same account. A UNIQUE constraint is a database rule that refuses a second identical row. Without it, two requests racing each other both succeed. Guest dedup uses IP, which is spoofable via C53. CVSS 4.3.
C77: stored XSS via structure title
In modules/page/inc/page.list.php, category titles at lines 308 and 439 are assigned to template variables without htmlspecialchars(). A title set to an XSS payload, either directly by anyone with structure-write access or via the C18 CSRF, executes for every visitor who loads the category list. CVSS 5.4.
Root cause
Cotonti's anti-CSRF mechanism works: when cot_check_xg() is called, requests without a valid token are rejected. The problem is that calling it is opt-in, and it was forgotten in the majority of state-changing handlers. The full list of files where CSRF protection is missing on mutating actions:
| ID | File | What an attacker can forge |
|---|---|---|
| C11 | modules/pfs/inc/pfs.edit.php |
Edit/rename files/folders |
| C12 | plugins/i18n/inc/i18n.page.php, i18n.structure.php |
Translation mutations |
| C13 | system/admin/admin.users.php |
Privilege escalation to superadmin |
| C14 | system/admin/admin.rightsbyitem.php |
Permission changes |
| C17 | plugins/contact/contact.tools.php |
Contact moderation |
| C18 | system/admin/admin.structure.php |
Structure add/edit (→ XSS) |
| C19 / C68 | plugins/comments/controllers/actions/CreateAction.php |
Post comments |
| C24 | system/admin/admin.extrafields.php |
Create/modify data fields (→ RCE) |
| C25 / C78 | system/admin/admin.extensions.php |
Install/update extensions |
| C29 | modules/page/inc/page.edit.php |
Edit any page |
| C30 / C67 | modules/page/inc/page.add.php |
Create pages |
| C31 | plugins/banlist/banlist.admin.php |
Add/remove bans |
| C32 / C60 | plugins/ratings/ratings.ajax.php |
Forge ratings |
| C33 | plugins/urleditor/urleditor.admin.php |
Write .htaccess (→ RCE) |
| C36 / C62 | modules/pm/inc/pm.send.php |
Send private messages |
| C37 / C61 | modules/forums/inc/forums.newtopic.php |
Create forum topics |
| C38 / C61 | modules/forums/inc/forums.posts.php |
Create forum posts |
| C39 | plugins/referers/referers.admin.php |
Wipe referer data |
| C40 | modules/pm/inc/pm.list.php |
Star/flag messages |
| C41 | plugins/autoalias2/autoalias2.admin.php |
Bulk rewrite page aliases |
| C48 | plugins/userimages/userimages.admin.php |
Modify user-image config |
| C51 | plugins/comments/controllers/actions/EditAction.php |
Edit comments (+ object injection) |
| C59 | plugins/i18n/inc/i18n.page.php, i18n.structure.php |
Translation mutations (duplicate ID from different file) |
| C64 | plugins/contact/contact.php |
Forge contact submissions |
| C65 | PFS upload/newfolder handlers | Upload files to victim's file store |
| C70 | modules/polls/inc/polls.functions.php |
Forge poll votes |
| C79 | system/admin/admin.config.php |
Change site configuration |
| C84 | system/admin/admin.rights.php |
Modify access rights |
The admin-facing ones (C13, C14, C24, C25, C33, C78, C79, C84) are the most dangerous because they enable privilege escalation and site takeover. An attacker who can get any admin to load a malicious page, through a crafted link, an image in a forum post or a spoofed email, can chain these.
A second root cause is token generation. Cotonti generates validation tokens in three places using the same pattern:
$validationKey = md5(microtime());
Line by line: $validationKey is the variable holding the token. microtime() returns the current server time in microseconds. md5() turns that into a short fingerprint. The problem is that the input is guessable and the fingerprint is fast to compute. microtime() returns the current server time in microseconds and md5() is fast, so an attacker who knows roughly when a request was made can brute-force the token window in seconds. The Date response header hands them the server time. The affected flows are password recovery (users.passrecover.php), new account registration (users.functions.php) and email address change (users.profile.php). All three write to the user_lostpass column, which is the only thing standing between an attacker and a successful account takeover via the recovery flow.
Separately, cot_unique() in system/functions.php generates tokens using sha1(mt_rand()). mt_rand() is a Mersenne Twister, a random number generator that is fast but not cryptographically secure, and its state can be recovered with enough output samples, making tokens derived from it predictable. A CSPRNG is a random generator designed so its output cannot be predicted from earlier output.
Impact
The headline impact is the C45 chain: an admin victim who clicks a malicious link can be made to write an Apache directive that turns a PFS-uploaded .jpg into executable PHP, giving remote code execution under the stated preconditions. Short of that, the admin CSRF bugs allow privilege escalation to superadmin (C13), arbitrary permission changes (C14, C84), arbitrary site configuration changes (C79), extension install/update (C25/C78) and the setup of the C52 upload path (C24).
The most urgent unauthenticated issues are C23 (installer update path, repeatable by anyone), C44 (open redirect), C47 and C72 (reflected XSS). C47 is particularly useful to an attacker because a crafted link sent to an admin can steal their CSRF token and chain into the admin CSRF bugs.
Other confirmed findings worth naming:
- C55: WhosOnline exposes real IP addresses to non-admins. The
online_ipfield is assigned to template variables visible to any user who can view the WhosOnline plugin, not just admins; only the clickable IP-search link is gated to admins. - C15: the session cookie is set with a leading-dot domain (
'.' . domain), sharing it across every subdomain, so a compromise of any subdomain such assub.example.comcan access the main site's session cookie. - C43 / C69:
cot_user_authorize()never callssession_regenerate_id(true). If an attacker can pre-set a known session ID in the victim's browser (session fixation), the victim's login authenticates that known ID. - C85: the contact page accepts a
tplGET parameter and passes it tocot_tplfile()without restricting to known template names; path traversal with../can reference other.tplfiles outside the expected directory. - C86: any token derived from
cot_unique()is predictable if enoughmt_rand()output is observable. It is used in session and authentication token generation.
Fix
No fixed version existed at the time of writing. The report gives the following recommendations:
- For C45 and C33: require
cot_check_xg()on the URL Editor save, do not write raw, unvalidated.htaccesscontent, and keep.htaccessnon-writable by the web process. - For C72: accept only
lngvalues that are existing keys in$L, and pass the body throughhtmlspecialchars(). - For C53: trust forwarded headers only from configured, known proxy IPs.
- For the token generation issues: use
bin2hex(random_bytes(32)).random_bytes(32)produces 32 bytes from a secure random source, andbin2hexturns them into readable characters.
For operators running Cotonti while awaiting patches, the most urgent items are the unauthenticated bugs (C23, C44, C47, C72) and the admin-CSRF chains that lead to RCE (C33, C45). For C23, remove install.php from the web root. For C47 and C72, WAF rules blocking the PoC parameters are a stopgap, not a fix. A WAF is a web application firewall, a filter placed in front of a site that blocks known bad requests.
Variants to test
- Missing
cot_check_xg()on mutating admin handlers. Enumerate every admin action that writes state and check whether the token is verified. A positive result is a forged cross-site request that changes data while the admin is logged in, with no token in the request. - Raw import modes feeding file writes. Look for fields imported with
NOC(or equivalent raw modes) that end up infile_put_contentsor similar. A positive result is attacker-controlled content appearing verbatim in a configuration or.htaccessfile. - Extension denylists that name only a few suffixes. Compare the denylist against what the web server actually maps to a handler (
.phtml,.php7,.php8,.phar,.shtml). A positive result is an uploaded file with a non-denied suffix being executed. - Base64-encoded redirect parameters. Check whether a filter that strips
:is bypassed by base64, which contains no colon. A positive result is a meta-refresh to an external host. - Language or message parameters used as fallback content. Supply a key that does not exist and see whether the raw value is reflected. A positive result is unescaped script execution.
- Non-atomic count-then-insert checks. Look for
countRows(...) == 0style guards before inserts. A positive result is two concurrent requests both succeeding where only one should. - Trusting
X-Forwarded-Forwithout a proxy allowlist. Send a spoofed header and observe whether bans, rate limits or deduplication are bypassed. - Time-based tokens (
md5(microtime())). Where a token is derived from server time, check whether theDateheader narrows the search space enough to brute-force it. A positive result is a valid token recovered within a plausible window. - Session cookies scoped to a parent domain. Check the
Domainattribute for a leading dot. A positive result is the cookie being sent to, and usable from, a sibling subdomain. - Login flows without
session_regenerate_id(true). A positive result is a pre-set session ID remaining valid after authentication.
Glossary
- Admin panel: the private part of a website where administrators manage users, settings and content.
- Apache: the web server software that receives browser requests and sends back pages; it reads
.htaccessfiles for per-folder rules. - Base64: a way of encoding any data using only letters, digits and a few symbols, so it can travel safely in text; it contains no colon.
- Brute-force: trying many possibilities quickly until one works.
- Cache: a store of precomputed results so the site does not have to rebuild them every time.
- Commit: a saved snapshot of a code project, identified by a short code such as
f43f1fc. - Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
- CSRF (cross-site request forgery): tricking a logged-in user's browser into sending a request the user did not intend.
- CSPRNG: a random number generator designed so its output cannot be predicted from earlier output.
- CVSS: a standard 0 to 10 score for how serious a vulnerability is.
- CVE: a public catalogue number assigned to a known security flaw.
- CWE: a catalogue of weakness types, such as CWE-352 for CSRF or CWE-79 for XSS.
- Extension / plugin / module: an add-on piece of software that adds features to the main product.
- GET / POST: the two common request types; GET is used to load a page, POST to submit data.
- Header: a labelled line of extra information sent with a web request or response.
.htaccess: an Apache configuration file in a folder that can change how that folder is served.- HTML escaping (
htmlspecialchars()): turning characters like<into harmless text so they are displayed rather than executed. - IP address: the number that identifies a machine on a network.
- JavaScript: the programming language browsers run, which can read and change a page.
- Meta-refresh: an HTML tag that tells the browser to load another address after a moment.
- Open redirect: a flaw where a site can be made to send visitors to an address the attacker chooses.
- Parameter: a named value in a request, such as
highlightorlng. - PHP: a programming language widely used to build websites.
- Privilege escalation: gaining more permissions than you are supposed to have.
- Race condition: a flaw where two actions happening at the same moment produce a result neither would alone.
- RCE (remote code execution): making a server run code the attacker supplied.
- Reflected XSS: an attack where the malicious script is echoed back in the response to the person who sent it.
- Session: the server-side record of a logged-in user, tied to a cookie or token.
- Session fixation: tricking a victim into using a session ID the attacker already knows.
- Shell: a small script that, once running on a server, lets an attacker run commands there.
- Stored XSS: an attack where the malicious script is saved on the server and served to every visitor.
- Superadmin: the highest permission level, able to do anything on the site.
- Token: a random value used to prove a request is legitimate and not forged.
- Vendor: the people or company who make the software.
- Vulnerability: a weakness an attacker can abuse.
- WAF (web application firewall): a filter in front of a site that blocks known bad requests.
- XSS (cross-site scripting): getting a site to deliver an attacker's JavaScript to other people's browsers.