Summary
Cotonti 1.0.0's Personal File Storage module is vulnerable to Cross-Site Request Forgery due to missing anti-CSRF validation on the file upload action.
An attacker who tricks a logged-in user into loading a malicious page can silently trigger a forged multipart upload, placing arbitrary files into the victim's PFS area.
Affected context
The vulnerability appears in the Personal File Storage (PFS) module of Cotonti 1.0.0 (master branch, commit f43f1fc3).
It is relevant when:
- Users are authenticated in Cotonti and have access to PFS
- The web application relies on browser-based sessions or cookies for authentication
- The
a=uploadaction inmodules/pfs/inc/pfs.main.phpis reachable over HTTP(S) without additional confirmation steps
Other PFS actions, such as file deletion, do call CSRF validation helpers, but the upload action omits this check, leaving a specific gap in protection.
Exploit preconditions
- Attack surface: The PFS file upload endpoint (
a=upload) exposed via HTTP(S). - Required access: The victim must be an authenticated Cotonti user with an active session and permission to use PFS.
- User interaction: The victim must be induced to visit or interact with an attacker-controlled web page (e.g., via link, embedded content, or compromised site).
- Trigger point: The malicious page causes the victim's browser to send a crafted multipart/form-data POST request to the PFS upload URL.
- Why exploitation is possible: The upload handler processes requests without verifying an anti-CSRF token (e.g., via
cot_check_xg()), so the application cannot distinguish a legitimate upload from a cross-site forged request.
Why this happens
This vulnerability stems from missing CSRF protection on a state-changing endpoint in a session-based web application.
While some PFS actions correctly call cot_check_xg() to validate anti-CSRF tokens, the a=upload action in pfs.main.php does not perform this check before processing uploaded files.
As a result, the application trusts any cross-origin POST that includes valid session cookies, matching CWE-352: Cross-Site Request Forgery (CSRF), where an application fails to require a per-request proof of user intent.
Potential impact
- Attackers may cause arbitrary files to be uploaded into a victim's PFS storage under the victim's account.
- Uploaded content can be used for phishing, social engineering, or to mislead other users who trust files in the victim's storage.
- Storage quotas could be exhausted by forced uploads, impacting availability of PFS for the victim.
- If other features allow sharing or publishing from PFS, forced uploads could lead to unintended exposure or distribution of attacker-controlled content.
General mitigation guidance
Effective mitigation focuses on enforcing robust CSRF defenses for all state-changing endpoints:
- Ensure every form or endpoint that modifies server-side state, including file uploads, enforces anti-CSRF token checks.
- Use framework-level CSRF middleware or centralized helpers and apply them consistently across all controller actions.
- Bind tokens to user sessions and validate them server-side, rejecting requests with missing or invalid tokens.
- Favor secure-by-default routing or controller patterns where new actions inherit CSRF protection automatically, reducing the chance of omissions.
- Complement token checks with same-site cookie attributes and, where appropriate, additional confirmation flows for sensitive actions.
How teams detect issues like this
To detect similar issues, organizations can:
- Perform code reviews focused on state-changing handlers, verifying that each such route uses a standard CSRF validation routine.
- Employ static analysis or security linting rules that flag POST/PUT/DELETE handlers not invoking the project's CSRF check function or middleware.
- Use automated integration or security tests that attempt cross-origin requests against sensitive endpoints and confirm they are rejected.
- Maintain architectural security guidelines that mandate use of centralized CSRF protection mechanisms and periodically audit legacy modules for compliance.

