Summary
ChurchCRM's backup restore feature can be abused to place attacker-controlled PHP files into a web-accessible directory with no file type or extension filtering.
An authenticated administrator, or an attacker leveraging CSRF against one, can upload a crafted backup archive that results in a webshell being deployed and executed remotely as the web server user.
Affected context
This vulnerability affects ChurchCRM deployments where the backup restore functionality is enabled and accessible to administrator accounts.
During restoration, archive contents are extracted and files from the Images/ directory are recursively copied into a web-accessible document root without validating file types, extensions, or execution risk.
The restore endpoint also does not enforce CSRF token checks, so exploitation may occur via a crafted web page if an administrator is logged in and has permission to restore backups.
Exploit preconditions
- Attack surface: HTTP(S) interface exposing the ChurchCRM admin backup restore endpoint.
- Required access:
- Direct exploit: Authenticated ChurchCRM administrator with permission to perform backup restore operations, or
- Indirect exploit: Ability to perform CSRF against an authenticated administrator's browser.
- Trigger point: Uploading a specially crafted backup archive that includes a malicious PHP file inside the
Images/directory, then initiating a restore operation. - Why exploitation is possible:
- The
recursiveCopyDirectory()routine copies files from the extractedImages/directory into the web root without any extension or MIME filtering. - The restored PHP file ends up in a publicly accessible path and can be invoked directly via HTTP, allowing arbitrary PHP code execution as the web server user.
- Lack of CSRF token validation on the restore endpoint allows an attacker to trigger the restore workflow without the administrator's explicit intent.
Why this happens
The core issue is a combination of unrestricted file upload/placement and missing request integrity controls.
The restore mechanism trusts the contents and structure of uploaded backup archives and uses recursiveCopyDirectory() to move files from the Images/ directory into a web-accessible location without validating file types, disallowing executable content, or constraining destination paths.
This aligns with CWE-434: Unrestricted Upload of File with Dangerous Type, where user-controlled input is allowed to become an executable resource in the application's runtime environment.
Additionally, the absence of CSRF protection on the restore endpoint means state-changing operations can be triggered cross-origin, mapping to an authorization and request-forgery weakness rather than a single logic bug.
Together, these design flaws create a path from an authenticated or CSRF-coerced action to arbitrary code execution.
Potential impact
- Remote execution of arbitrary PHP code as the web server user.
- Installation of persistent webshells for ongoing access.
- Access to and exfiltration of sensitive application and database data.
- Tampering with or deletion of ChurchCRM records and stored assets.
- Lateral movement within the hosting environment, depending on server configuration.
- Use of the compromised site as a pivot point for further attacks on users or internal systems.
General mitigation guidance
Effective mitigation focuses on tightening file handling and strengthening request integrity for sensitive operations:
- Restrict the types of files that can be restored into web-accessible directories, explicitly blocking executable extensions such as
.php,.php5,.phtml, and similar. - Treat backup archives as untrusted input and validate extracted contents against an allowlist of safe directories and file extensions before copying.
- Separate storage for user-restored content from executable code paths, for example by placing restored images and documents on non-executable volumes or behind indirect access mechanisms.
- Enforce strong server-side CSRF protections on all state-changing administrative endpoints, including backup restore operations.
- Apply least-privilege principles to the web server user so that, even if files are written, their ability to impact the broader system is constrained.
- Log and monitor administrative backup and restore actions, including file paths affected, to support rapid detection and response to misuse.
How teams detect issues like this
Organizations can detect this class of issue and its exploitation using layered approaches:
- Static analysis and code review:
- Flag recursive directory copy utilities used in conjunction with user-uploaded archives, especially where destinations are web-accessible.
- Identify file write operations that lack extension/mime checks or rely solely on client-side validation.
- Verify that administrative endpoints performing state-changing actions invoke CSRF token validation and robust permission checks.
- Configuration and policy enforcement:
- Enforce web server rules that prevent execution of scripts from upload or media directories (e.g., disabling PHP execution in image or document paths).
- Use security policies or frameworks that require explicit opt-in for executable locations.
- Runtime and log-based monitoring:
- Monitor web server logs for requests to unexpected
.phpfiles under image or upload directories. - Alert on unusual backup restore activity patterns or large numbers of files written into public directories.
- Automated SAST/DAST and secure code review tools can be configured to highlight unrestricted file upload paths, missing CSRF protections, and executable content in public file trees.

